RISC-V is an open standard instruction set architecture (ISA) based on reduced instruction set computing (RISC) principles. RV64 is the 64-bit version, supporting 64-bit registers, addresses, and data types. It is widely used in modern processors for its simplicity, extensibility, and open ecosystem.
This tutorial covers the basics and lets you interactively explore and test your knowledge!
Type | Fields | Description |
---|---|---|
R-type | opcode, rd, funct3, rs1, rs2, funct7 | Register-register operations |
I-type | opcode, rd, funct3, rs1, imm[11:0] | Immediate, loads, jalr, system |
S-type | opcode, imm[4:0], funct3, rs1, rs2, imm[11:5] | Stores |
B-type | opcode, imm[11], imm[4:1], funct3, rs1, rs2, imm[10:5], imm[12] | Branches |
U-type | opcode, rd, imm[31:12] | LUI, AUIPC |
J-type | opcode, rd, imm[20|10:1|11|19:12] | JAL |
RV64I adds 64-bit operations and immediate fields are sign-extended to 64 bits where applicable.
Name | Format | Description |
---|---|---|
ADD, SUB | R | rd = rs1 + rs2 / rd = rs1 - rs2 |
SLL, SRL, SRA | R | Shift left/right logical/arithmetic |
SLT, SLTU | R | Set if less than (signed/unsigned) |
AND, OR, XOR | R | Bitwise logic |
ADDI, SLLI, SRLI, SRAI | I | Immediate arithmetic/shift |
SLTI, SLTIU | I | Set if less than immediate |
ANDI, ORI, XORI | I | Immediate bitwise logic |
LB/LH/LW/LWU/LD | I | Load byte/half/word/word unsigned/double |
SB/SH/SW/SD | S | Store byte/half/word/double |
BEQ/BNE/BLT/BGE/BLTU/BGEU | B | Conditional branches |
LUI/AUIPC | U | Load upper immediate / Add upper immediate to PC |
JAL/JALR | J/I | Jump and link / Jump and link register |
ECALL/EBREAK | I | System call / Break |
64-bit only: ADDIW, SLLIW, SRLIW, SRAIW | R/I | Word (32-bit) arithmetic/shift, sign-extended to 64 bits |
Register | ABI Name | Description |
---|---|---|
x0 | zero | Zero constant |
x1 | ra | Return address |
x2 | sp | Stack pointer |
x3 | gp | Global pointer |
x4 | tp | Thread pointer |
x5-x7 | t0-t2 | Temporaries |
x8 | s0/fp | Saved/frame pointer |
x9 | s1 | Saved register |
x10-x11 | a0-a1 | Function args/return values |
x12-x17 | a2-a7 | Function args |
x18-x27 | s2-s11 | Saved registers |
x28-x31 | t3-t6 | Temporaries |