5.1.7 · D1Instruction Set Architecture (ISA)

Foundations — RISC-V base ISA (RV32I - RV64I)

2,628 words12 min readBack to topic

Before you can read a single line of the parent RISC-V base ISA (RV32I - RV64I) note, you need a toolbox. This page builds every tool from nothing. Each item: what it means in plain words, the picture it makes, and why the topic can't live without it.


1. A bit — the atom of everything

Why does the topic need this? Because every instruction in RV32I is literally "32 switches set to a specific pattern." The whole chapter is about what those switches mean.


2. A bit-string and its width — counting boxes

So a 4-bit string like 1011 means, place by place:

A bit-string is all the parent's data ever is: a register holds one (its width is called XLEN, built in §7), and an instruction is a 32-wide one. Next we learn how to point at part of such a string.


3. Notation inst[31:20] — slicing a bit-string

Why the topic needs it: the six instruction formats (R, I, S, B, U, J) are nothing but named rules for which slice means opcode, which means rd, which means the constant baked into the instruction. Learn the slice notation and the formats become readable. (Those field names get their meanings and bit-widths in §10.)


4. Hexadecimal — bits in bite-sized groups

Why the topic needs it: the parent writes constants like 0xDEADBEEF and 0xEEF. Without hex you'd drown in 32-digit binary.


5. Unsigned vs signed — can a number be negative?

But computers must also represent negative numbers, and they only have 0s and 1s — no minus-sign switch. The trick is Two's Complement.

Why the topic needs it: the parent's whole "why 0xDEADC not 0xDEADB" argument only makes sense once you know 0xEEF (top bit set) is a negative number under two's complement.


6. Sign-extension and the sext notation — growing a number without changing it

Why the topic needs it: every immediate in RV32I is stored narrow (12 or 20 bits) and sign-extended to the register width XLEN (defined next). Miss this and half the worked examples break.


7. XLEN — one symbol for "how wide"


8. Register, register file, and x0

Why the topic needs it: instructions name their inputs and output by register number (fields rs1, rs2, rd), so you must know what a register is before you can decode a format.


9. pc — the "you are here" marker


10. opcode, funct3/funct7, rd/rs1/rs2, immediate — the field vocabulary (with widths)

Why the topic needs it: these are the words on every format diagram in the parent. funct7 | rs2 | rs1 | funct3 | rd | opcode is just this vocabulary, laid out in bit order with the widths above.


Prerequisite map

The arrows below say "you must understand the box at the tail before the box at the head makes sense," and each edge label names what flows along it — so you can trace, e.g., how "powers of two" is the single idea that unlocks both hex and the signed range.

line them up

weight each box

group by four

largest value

top bit goes negative

copy the sign bit

point at a chunk

widen to XLEN

name each chunk

fixed field layout

how wide is a register

32 boxes of storage

an address register

decoded operands

decoded fields

control flow

readable constants

Bit: one 0 or 1

Bit-string and width

Place values powers of two

Hexadecimal

Unsigned range

Two's complement

Sign-extension sext

Slice notation

Immediate fields

Formats R I S B U J

XLEN

Register file and x0

pc and branch target

RISC-V base ISA

All roads drain into the parent RISC-V base ISA (RV32I - RV64I). Related big-picture context lives in Instruction Set Architecture (ISA), RISC vs CISC, Pipelining, and Assembler & Pseudo-instructions.


Equipment checklist

Try to answer each before revealing. If any stumps you, re-read that section above.

What is a bit, in one sentence?
A single box holding one of two values, 0 or 1.
What is the place value of bit number (counting from the right, from 0)?
.
How many distinct patterns can bits hold?
.
What does the slice mean?
The 12 bits from box 31 down to box 20 of the string inst.
Convert 0xE to 4 bits and to a decimal number.
1110, which is .
In two's complement, which bit tells you the sign, and what does 1 mean there?
The leftmost (most significant) bit; 1 means the number is negative.
Negate 4-bit 0001 by invert-and-add-one; what pattern and value do you get?
Flip to 1110, add 1 → 1111, which is .
What is the signed range of a 12-bit two's-complement field?
.
What does do?
Widens the narrow signed bit-string to 32 bits by copying its sign bit leftward, keeping the value the same.
When you sign-extend a negative number to a wider width, what do you pad with?
Copies of the sign bit, i.e. 1s (0s if the number is positive).
What does XLEN stand for, and its two values?
The register width in bits; 32 for RV32I, 64 for RV64I.
How many registers does RISC-V have, and which one is special?
32 (x0x31); x0 is hardwired to zero.
Why is the rd field exactly 5 bits wide?
Because , just enough to name one of the 32 registers.
How wide are opcode, funct3, funct7, and an I-type immediate?
7, 3, 7, and 12 bits respectively.
What does the pc hold?
The address of the current instruction.
Which field is the destination register, and which are the sources?
rd is destination; rs1, rs2 are the sources.