WGrav01/riscv.zig
WIP RISC-V emulator written in Zig
riscv.zig is a work in progress RISC-V emulator, soon-to-be available as both a library that can be implemented in other projects and as a standalone application. The goal is to be as flexible as reasonably possible, supporting most (if not all) major ISA extensions. It also aims to be performant, at least for an interpreted emulator. (I plan to implement JIT compilation using GNU Lightning, and maybe even KVM later on.)
WARNING riscv.zig is currently in heavy development, and is not in a usable state whatsoever. It probably can't even compile yet. As such, until I can get it into a usable state, all pushes and commits will be put into the main branch.
The project tracks the latest stable releases of Zig, currently at 0.15.1. You will need the relevant version to use, and I strongly recommend you use anyzig to help with that. To clone and compile:
# You can also use ssh if you want:
git clone https://github.com/WGrav01/riscv.zig.git
cd riscv.zig
# To compile the library and executable (the exe is not implemented yet!):
zig build
# To run tests:
zig test
# To run the exe:
./zig-out/bin/riscv_zig
zig fetch --save https://github.com/WGrav01/riscv.zig.git
. You should then see the library in your build.zig.zon
.build.zig
:const riscv = b.dependency("riscv_zig", .{
.target = target,
.optimize = optimize,
});
And, before installArtifact
is called: (this assumes your main module is called exe
)exe.root_module.addImport("riscv", riscv.module("riscv_zig"));
const riscv = @import("riscv");
Coming soon, once I have an actual implementation of the library.
Feature | Status |
---|---|
RV32 support | In progress |
RV32i support | Planned |
RV64 support | Planned |
RV128 support | Planned |
ISA extensions | Status table coming soon |
JIT compilation | Planned |
libvirt | Possibly? Stretch goal |
GDB server | Likely, not sure yet |
Assembler | Possibly? Stretch goal |
Disassembler | Possibly? Stretch goal |
PRs and help is welcome! Please open an issue however before any major contributions however.
I will be happy to help you. However, please do not open an issue unless you are confident that your problem is an enhancement, bug, or something to change. Use discussions instead.
This project is licensed under the MIT License. You can view it in this repository here.