34 lines
916 B
Markdown
34 lines
916 B
Markdown
# A simple RISC-V emulator
|
|
|
|
This is a toy emulator for RISC-V, made for educational purposes.
|
|
The goal is to have a base rv32i instruction set (the bare minimum) plus a M-extension for division and multiplication. In theory, it should be enough to execute simple C programs compiled with GCC and sprinkled with a few linker scripts. Of course, no libc because there's no OS.
|
|
|
|
## Compiling and running
|
|
|
|
You'd need nix. Install it and run:
|
|
|
|
```sh
|
|
nix develop
|
|
|
|
eval "$configurePhase"
|
|
ninja
|
|
```
|
|
|
|
As a result you should get an executable called `rve`
|
|
|
|
## Cross-toolchain and an example program in C
|
|
|
|
There is an example program which you can compile. It requires some custom toolchain so currently not built with CMake. To compile it:
|
|
|
|
```sh
|
|
cd example
|
|
make
|
|
```
|
|
|
|
As a result, you'll get an `example.raw` binary. To execute it:
|
|
|
|
```sh
|
|
./rve ../example/example.raw
|
|
```
|
|
|
|
The expected output of the example program is `269`.
|