diff --git a/src/main.rs b/src/main.rs index 44c72ca..c8b2e5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ -use std::io::Read; -use std::io::BufReader; use std::fs::File; +use std::io::BufReader; +use std::io::Read; const XLEN: usize = 32; @@ -40,13 +40,13 @@ impl Default for Bus { } struct Instruction { - opcode: u8, - rd: u8, - rs1: u8, - rs2: u8, - funct3: u8, - funct7: u8, - imm: u32, + opcode: Byte, + rd: Byte, + rs1: Byte, + rs2: Byte, + funct3: Byte, + funct7: Byte, + imm: Word, } struct VMRV32I { @@ -98,6 +98,7 @@ fn main() { println!("VM Starting Up"); let mut cpu = VMRV32I::new(); - cpu.load_prog("test.bin"); + cpu.load_prog("./test/test.bin"); cpu.init_cpu(); } + diff --git a/test/test b/test/test new file mode 100755 index 0000000..46c25ad Binary files /dev/null and b/test/test differ diff --git a/test/test.bin b/test/test.bin new file mode 100755 index 0000000..469e604 Binary files /dev/null and b/test/test.bin differ diff --git a/test/test.s b/test/test.s new file mode 100644 index 0000000..2af7076 --- /dev/null +++ b/test/test.s @@ -0,0 +1,22 @@ + .file "test.c" + .option nopic + .attribute arch, "rv32i2p1" + .attribute unaligned_access, 0 + .attribute stack_align, 16 + .text + .align 2 + .globl main + .type main, @function +main: + addi sp,sp,-32 + sw s0,28(sp) + addi s0,sp,32 + li a5,3 + sw a5,-20(s0) + li a5,0 + mv a0,a5 + lw s0,28(sp) + addi sp,sp,32 + jr ra + .size main, .-main + .ident "GCC: (g2ee5e430018) 12.2.0"