This commit is contained in:
Benjamin Kyd
2023-05-22 19:52:12 +01:00
parent 28ae5df372
commit 3669d8a02d
4 changed files with 33 additions and 10 deletions

View File

@@ -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();
}

BIN
test/test Executable file

Binary file not shown.

BIN
test/test.bin Executable file

Binary file not shown.

22
test/test.s Normal file
View File

@@ -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"