riscv-rust 是一个用 Rust 编写并编译为 WebAssembly 的RISC-V处理器和外围设备模拟器项目

riscv-rust



riscv-rust is a RISC-V processor and peripheral devices emulator project written in Rust and compiled to WebAssembly. You can import RISC-V emulator into your Rust or JavaScript project. Refer to the Slides for more detail.

Online 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
  • Linux OpenSBI and legacy BBL boot support
  • Runnable locally
  • Also runnable in browser with WebAssembly
  • Debugger
  • You can import RISC-V emulator into your Rust or JavaScript project

Instructions/Features support status

  • RV32/64I
  • RV32/64M
  • RV32/64F (almost)
  • RV32/64D (almost)
  • RV32/64Q
  • RV32/64A (almost)
  • RV64C/32C (almost)
  • RV32/64Zifencei (almost)
  • RV32/64Zicsr (almost)
  • CSR (almost)
  • SV32/39
  • SV48
  • Privileged instructions (almost)
  • PMP

etc...

The emulator supports almost all instructions listed above but some instructions which are not used in Linux or xv6 are not implemented yet. Your contribution is very welcome.

How to import into your Rust project

The emulator module is released at crates.io. Add the following line into Cargo.toml of your Rust project.

复制代码
[dependencies]
riscv_emu_rust = "0.2.0"

Refer to Document for the API.

How to build core library locally

sh 复制代码
$ git clone https://github.com/takahirox/riscv-rust.git
$ cd riscv-rust
$ cargo build --release

How to run Linux or xv6 as desktop application

sh 复制代码
$ cd riscv-rust/cli
# Run Linux
$ cargo run --release ../resources/linux/opensbi/fw_payload.elf -f ../resources/linux/rootfs.img
# Run xv6
$ cargo run --release ../resources/xv6/kernel -f ../resources/xv6/fs.img

How to run riscv-tests

Prerequirements

sh 复制代码
$ cd riscv-rust/cli
$ cargo run $path_to_riscv_tets/isa/rv32ui-p-add -n

How to import and use WebAssembly RISC-V emulator in a web browser

See wasm/web

How to install and use WebAssembly RISC-V emulator npm package

See wasm/npm

Linux RISC-V port

Running 64- and 32-bit RISC-V Linux on QEMU

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.

Specifications

相关推荐
液态不合群1 天前
rust程序静态编译的两种方法总结
开发语言·后端·rust
明月看潮生1 天前
青少年编程与数学 02-019 Rust 编程基础 02课题、开始编程
开发语言·算法·青少年编程·rust·编程与数学
sinovoip2 天前
Banana Pi BPI-CM6 是一款八核 RISC-V 模块,兼容 Raspberry Pi CM 载板
risc-v
rayylee2 天前
Ubuntu也开始锈化了?Ubuntu 计划在 25.10 版本开始引入 Rust Coreutils
linux·ubuntu·rust
Source.Liu2 天前
【PhysUnits】2.2 Scalar<T> 标量元组结构体(scalar/mod.rs)
rust
vivo互联网技术2 天前
FunProxy - 使用 Rust 构建跨平台全链路测试抓包代理工具
软件测试·rust·抓包·代理
@PHARAOH2 天前
WHAT - Rust 静态派发(Static Dispatch)和 动态派发(Dynamic Dispatch)
开发语言·后端·rust
Source.Liu2 天前
【PhysUnits】2 Scalar<T> 标量元组结构体(scalar/mod.rs)
rust
muyouking112 天前
Rust 中 Arc 的深度分析:从原理到性能优化实践
开发语言·性能优化·rust
muyouking112 天前
Rust 与 Golang 深度对决:从语法到应用场景的全方位解析
rust