Writing a RV32I emulator (work in progress)
The goal of this project is to learn how the RISC-V architecture works, by writing an emulator. So far, this project emulates the RV32I instruction set, with work on the M extension being in progress and Zicsr planned.
This repository provides the source code of the emulator (in the vm_src folder), as well as an example C program which can be compiled and ran on the emulator.
Both the emulator and example program are build by running make. To build and run the program inside the emulator, run make test. The compiled program binary will be called rv_app.bin. The program filename is passed to the emulator as a command line argument (emulator [filename]). In order to compile the program, riscv64-unknown-elf-gcc must be available.
The RISC-V Instruction Set Manual has been the main source of documentation when developing the emulator.
The very small libc provided in the RISC-V example program barelibc.c is heavily based on ch32v003fun.c by cnlohr