#ifndef SRC_ASM_HPP_ #define SRC_ASM_HPP_ #include enum class type_t {R, I, S, U, B, J}; struct r_type { uint32_t funct7 : 7; uint32_t rs2 : 5; uint32_t rs1 : 5; uint32_t funct3 : 3; uint32_t rd : 5; uint32_t opcode : 7; }; struct i_type { uint32_t imm : 12; uint32_t rs1 : 5; uint32_t funct3 : 3; uint32_t rd : 5; uint32_t opcode : 7; }; struct s_type { uint32_t imm_hi : 7; uint32_t rs2 : 5; uint32_t rs1 : 5; uint32_t funct3 : 3; uint32_t imm_lo : 5; uint32_t opcode : 7; }; struct u_type { uint32_t imm : 10; uint32_t rd : 5; uint32_t opcode : 7; }; struct b_type { uint32_t a : 1; uint32_t imm_hi : 6; uint32_t rs2 : 5; uint32_t rs1 : 5; uint32_t funct3 : 3; uint32_t imm_lo : 4; uint32_t b : 1; uint32_t opcode : 7; }; struct j_type { uint32_t a : 1; uint32_t imm_lo : 10; uint32_t b : 1; uint32_t imm_hi : 8; uint32_t rd : 5; uint32_t opcode : 7; }; struct instruction_t { type_t t; union { r_type r; i_type i; s_type s; u_type u; b_type b; j_type j; uint32_t value; }; }; #endif // SRC_ASM_HPP_