Skip to content

dc-tw/rv32emu

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RISC-V RV32I[MAC] emulator with ELF support

Emulator was originally created by Fabrice Bellard and then modified and shared on Hackaday by Frank Buss as a single C-file. Shaos added some additional statistics and macros.

Requires libelf-dev:

$ sudo apt-get install libelf-dev

How to compile it:

$ gcc -O3 -Wall -lelf emu-rv32i.c -o emu-rv32i

or

$ make emu-rv32i

Passed RV32I compliance tests from https://github.com/riscv/riscv-compliance

$ make RISCV_TARGET=spike RISCV_DEVICE=rv32i TARGET_SIM=/full/path/emulator variant

Compiling and running simple code:

$ make test1

then

$ ./emu-rv32i test1
Hello RISC-V!
  • RV32M and RV32A instructions may be enabled by commenting #define STRICT_RV32I.

Passed RV32C compliance tests from https://github.com/riscv/riscv-compliance

make C-ADDI.log

If there is no accident, it will output the TEST PASSED

  • RV32C instructions can be enabled by commenting #define RV32C

How to build RISC-V toolchain from scratch

https://github.com/riscv/riscv-gnu-toolchain

64-bit universal version (riscv64-unknown-elf-* that can build 32-bit code too):

$ ./configure --prefix=/opt/riscv
$ make

32-bit version (riscv32-unknown-elf-*):

$ ./configure --prefix=/opt/riscv32 --with-arch=rv32i --with-abi=ilp32
$ make

About

RISC-V RV32I[MA] emulator with ELF support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 99.4%
  • Makefile 0.6%