57 lines
956 B
Rust
57 lines
956 B
Rust
|
pub struct Instruction {
|
||
|
value : u64,
|
||
|
|
||
|
opcode : u8,
|
||
|
rs1 : u8,
|
||
|
rs2 : u8,
|
||
|
rs3 : u8,
|
||
|
rd : u8,
|
||
|
funct7 : u8,
|
||
|
funct7_smaller : u8,
|
||
|
funct3 : u8,
|
||
|
shamt : u8,
|
||
|
|
||
|
imm12_I : u16,
|
||
|
imm12_S : u16,
|
||
|
|
||
|
imm12_I_signed : i16,
|
||
|
imm12_S_signed : i16,
|
||
|
imm13 : i16,
|
||
|
imm13_signed : i16,
|
||
|
|
||
|
imm31_12 : u32,
|
||
|
imm21_1 : u32,
|
||
|
|
||
|
imm31_12_signed : i32,
|
||
|
imm21_1_signed : i32,
|
||
|
}
|
||
|
|
||
|
pub fn decode(val : u64) -> Instruction {
|
||
|
Instruction {
|
||
|
value : val,
|
||
|
|
||
|
opcode : 0,
|
||
|
rs1 : 0,
|
||
|
rs2 : 0,
|
||
|
rs3 : 0,
|
||
|
rd : 0,
|
||
|
funct7 : 0,
|
||
|
funct7_smaller : 0,
|
||
|
funct3 : 0,
|
||
|
shamt : 0,
|
||
|
|
||
|
imm12_I : 0,
|
||
|
imm12_S : 0,
|
||
|
|
||
|
imm12_I_signed : 0,
|
||
|
imm12_S_signed : 0,
|
||
|
imm13 : 0,
|
||
|
imm13_signed : 0,
|
||
|
|
||
|
imm31_12 : 0,
|
||
|
imm21_1 : 0,
|
||
|
|
||
|
imm31_12_signed : 0,
|
||
|
imm21_1_signed : 0,
|
||
|
}
|
||
|
}
|