Documentation ¶
Overview ¶
riscv-emu is a toy risc-v (https://riscv.org/) emulator.
DO NOT USE THIS IN PRODUCTION. This project exists as a way for me to learn RISC-V.
riscv-emu can:
execute a risc-v program (ELF file) this mode has no dependencies beyond the standard library
execute risc-v instructions from stdin starts with registers and memory set to zero
step through a risc-v program and compare the state with the spike simulator
this mode requires:
Linux (for PTY)
cgo (https://golang.org/cmd/cgo/ for PTY)
To execute the program:
riscv-emu --argv=a,hello,world --env=A=B,LANG=en_US.UTF-8 --prog=PATH_TO_RISCV_BINARY
To execute instructions from stdin:
echo -n -e "\x9b\x87\xa7\x02" | riscv-emu # executes "addiw a5,a5,42"
To compare with spike:
riscv-emu --argv=a,hello,world --env=A=B,LANG=en_US.UTF-8 --prog=PATH_TO_RISCV_BINARY --spike=PATH_TO_SPIKE_BINARY
Click to show internal directories.
Click to hide internal directories.