In the base RV32I ISA, there are four core instruction formats (R/I/S/U).
typedef struct {
union {
struct {
uint32_t opcode1_0 : 2;
uint32_t opcode6_2 : 5;
uint32_t rd : 5;
uint32_t funct3 : 3;
uint32_t rs1 : 5;
uint32_t rs2 : 5;
uint32_t funct7 : 7;
} r;
struct {
uint32_t opcode1_0 : 2;
uint32_t opcode6_2 : 5;
uint32_t rd : 5;
uint32_t funct3 : 3;
uint32_t rs1 : 5;
int32_t simm11_0 :12;
} i;
struct {
uint32_t opcode1_0 : 2;
uint32_t opcode6_2 : 5;
uint32_t imm4_0 : 5;
uint32_t funct3 : 3;
uint32_t rs1 : 5;
uint32_t rs2 : 5;
int32_t simm11_5 : 7;
} s;
struct {
uint32_t opcode1_0 : 2;
uint32_t opcode6_2 : 5;
uint32_t rd : 5;
uint32_t imm31_12 :20;
} u;
uint32_t val;
} instr;
} RISCV32_Instruction;The base ISA has IALIGN=32, meaning that instructions must be aligned on a four-byte boundary in memory.