The Base Integer ISA (RV32I/RV64I)
RISC-V Architecture Deep Dive · CPU Architectures track
4 min read
In this module
Intentional Minimalism
The RISC-V base integer instruction set (RV32I for 32-bit, RV64I for 64-bit) is deliberately tiny. With 40 instructions in the current specification (older versions counted 47, before the CSR and FENCE.I instructions moved out into the separate Zicsr and Zifencei extensions), it contains everything you need to write a general-purpose program — and nothing else. Every other capability comes in through optional extensions, keeping the base simple enough that a student can implement it in hardware as a semester project.
The Register File
RISC-V provides 32 integer registers, named x0 through x31:
- x0 - hardwired to zero. Reads always return 0. Writes are silently discarded.
- x1 (ra) - return address (by convention).
- x2 (sp) - stack pointer (by convention).
- x3 (gp) - global pointer.
- x4 (tp) - thread pointer.
- x5-x7 (t0-t2) - temporary registers.
- x8-x9 (s0-s1) - saved registers (callee-saved).
- x10-x17 (a0-a7) - function arguments and return values.
- x18-x27 (s2-s11) - more saved registers.
- x28-x31 (t3-t6) - more temporaries.
In RV32I, each register is 32 bits wide. In RV64I, each is 64 bits.
Hardwiring x0 to zero is one of RISC-V's most elegant design decisions. It eliminates the need for dedicated instructions to load zero, negate a value, or discard a result. ADD x5, x6, x0 copies x6 to x5 (move). SUB x5, x0, x6 negates x6. Any instruction that writes x0 does nothing; the official no-op, NOP, is ADDI x0, x0, 0. One simple hardware constraint replaces several instructions that other ISAs must define separately.
Fixed 32-Bit Instructions
Like ARM's AArch64, RISC-V base instructions are always 32 bits wide. The fixed width simplifies fetch and decode: the CPU always knows where the next instruction boundary sits.
Compare with our teaching ISA's fixed 16-bit instructions. Same principle, just wider; the extra bits make room for larger immediates and more register specifiers.
Instruction Formats
RISC-V defines six instruction formats, each with a consistent layout:
| Format | Used For | Structure |
|---|---|---|
| R-type | Register-register operations (ADD, SUB, AND) | opcode + rd + funct3 + rs1 + rs2 + funct7 |
| I-type | Immediate operations, loads (ADDI, LW) | opcode + rd + funct3 + rs1 + imm[11:0] |
| S-type | Stores (SW, SB) | opcode + imm[4:0] + funct3 + rs1 + rs2 + imm[11:5] |
| B-type | Conditional branches (BEQ, BNE) | opcode + imm + funct3 + rs1 + rs2 + imm |
| U-type | Upper immediate (LUI, AUIPC) | opcode + rd + imm[31:12] |
| J-type | Unconditional jumps (JAL) | opcode + rd + imm |
One sharp design choice runs through all of this: the opcode always lives in the same bit positions (bits 0-6), and when present, the destination register (rd) and source registers (rs1, rs2) sit in the same fields too. The decoder can start reading the register file before it has even finished decoding the instruction, which the pipeline loves.
Here are two real encodings, bits 31 down to 0 from left to right. add x5, x6, x7 is R-type and assembles to 0x007302B3; addi x5, x6, -1 is I-type and assembles to 0xFFF30293. Notice that rd, funct3, rs1 and the opcode land in exactly the same bit positions in both. The I-type simply reuses the funct7 and rs2 bits as a 12-bit immediate.
Core Instructions
The base RV32I provides the essential building blocks:
- Arithmetic: ADD, SUB, ADDI (no multiply or divide - those are in the M extension).
- Logic: AND, OR, XOR, and their immediate variants.
- Shifts: SLL, SRL, SRA (logical left, logical right, arithmetic right).
- Comparison: SLT, SLTU (set less than).
- Loads/stores: LW, LH, LB, SW, SH, SB (word, half-word, byte).
- Branches: BEQ, BNE, BLT, BGE, BLTU, BGEU.
- Jumps: JAL (jump and link), JALR (jump and link register).
- Upper immediate: LUI (load upper immediate), AUIPC (add upper immediate to PC).
This is what a "real" clean RISC ISA looks like — the same design principles you saw in our teaching ISA, refined and battle-tested in production.