decode & struct Instruction

This commit is contained in:
Baptiste 2022-10-19 16:39:38 +02:00
parent 0be10b9f82
commit 9748b0f2dc
3 changed files with 67 additions and 0 deletions

7
Cargo.lock generated Normal file
View 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
View 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,
}
}

View File

@ -1,3 +1,6 @@
mod decode;
fn main() { fn main() {
let instr = decode::decode(98);
println!("Hello, world!"); println!("Hello, world!");
} }