2 unstable releases
Uses old Rust 2015
0.2.0 | May 22, 2020 |
---|---|
0.1.0 | May 6, 2020 |
#566 in WebAssembly
185KB
5K
SLoC
riscv-rust
riscv-rust is a RISC-V processor emulator project written in Rust.
Demo
You can run Linux or xv6 on the emulator in your browser. Online demo is here
Screenshots
Documents
Features
- Emulate RISC-V processor and peripheral devices
- Stable as Linux and xv6-riscv run on it
- Runnable locally
- Also runnable in browser with WebAssembly
- Debugger
Instructions/Features support status
- RV32/64I
- RV32/64M
- RV32/64F (partially)
- RV32/64D (partially)
- RV32/64Q
- RV32/64A (partially)
- RV64C/32C (partially)
- RV32/64Zifencei (partially)
- RV32/64Zicsr (partially)
- CSR (partially)
- SV32/39
- SV48
- Privileged instructions (partially)
- PMP
etc...
How to import into your Rust project
This module is released at crates.io. Add the following line into Cargo.toml of your Rust project.
[dependencies]
riscv_emu_rust = "0.1.0"
Refer to cli/src/main.rs as sample code.
How to build core library
$ git clone https://github.com/takahirox/riscv-rust.git
$ cd riscv-rust
$ cargo build --release
How to run Linux or xv6 as CLI application
$ cd riscv-rust/cli
# Run Linux
$ cargo run --release ../resources/linux/bbl -f ../resources/linux/busybear.bin -d ../resources/linux/dtb.dtb
# Run xv6
$ cargo run --release ../resources/xv6/kernel -f ../resources/xv6/fs.img
How to build WebAssembly and run in the browser
Prerequirements
- Install wasm-bindgen client
$ cd riscv-rust/wasm
$ bash build.sh
# boot local server and access riscv-rust/wasm/web/index.html
How to install WebAssembly npm package
$ npm install riscv_emu_rust_wasm
How to run riscv-tests
Prerequirements
- Install riscv-gnu-toolchain
- Install riscv-tests
$ cd riscv-rust/cli
$ cargo run $path_to_riscv_tets/isa/rv32ui-p-add -n
Links
Linux RISC-V port
xv6-riscv
xv6-riscv is the RISC-V port of xv6 which is UNIX V6 rewritten by MIT for x86 in the current C language.