Skip to content

Tiny RISC-V emulator optimized for understanding and learning

License

Notifications You must be signed in to change notification settings

ianmkim/riscvem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RISCVem

Tiny RISCV emulator written in C. Started off as a python implementation following geohot's twitchcore and ultimately evolved into a more in-depth C/C++ implementation.

Status: passes all tests!

alt text

Installations

Requirements

You first need to build the tests for RISC-V emulators. This particular repo only implements rv32ui - RV32, user level, integer only. The test suite only runs the p environment which disables the use of virtual memory and only allows for one core.

Clone and build the submodules of this repository:

git submodule update --init --recursive
cd riscv-tests
./configure
make -j

Now you should be able to see the RISCV tests listed in the directory riscv-tests/isa/

If you got an error during the make stage, make sure you have the RISCV toolkit installed on your operating system.

RISCVem

Installation for RISCVem is simple:

mkdir build
cd build
cmake ..
make

Usage

If you wish to run an automated test of the emulator, run the included test binary which performs all tests for RV32UI single mode, raw memory, privileged mode of RISCV:

./rv32ui_tests

If you have your own ELF binary, then run:

./riscvem -f <path to your ELF> -v 1

Note that by default, verbosity level is set to 0. So you will only know if your code ran through the return value of the program. There are three levels of verbosity you can use. The highest level: 2 will print a dump of the 8 words of memory near the program counter address + values of all registers at each step of execution.

About

Tiny RISC-V emulator optimized for understanding and learning

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published