decode & struct Instruction
This commit is contained in:
parent
0be10b9f82
commit
9748b0f2dc
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "burritos"
|
||||||
|
version = "0.1.0"
|
57
src/decode.rs
Normal file
57
src/decode.rs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
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,
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,6 @@
|
|||||||
|
mod decode;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let instr = decode::decode(98);
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user