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

相关推荐
Rust语言中文社区10 小时前
【Rust日报】用 Rust 重写的 Turso 是一个更好的 SQLite 吗?
开发语言·数据库·后端·rust·sqlite
小杍随笔20 小时前
【Rust 半小时速成(2024 Edition 更新版)】
开发语言·后端·rust
Source.Liu20 小时前
【office2pdf】office2pdf 纯 Rust 实现的 Office 转 PDF 库
rust·pdf·office2pdf
洛依尘20 小时前
深入浅出 Rust 生命周期:它不是语法负担,而是借用关系的说明书
后端·rust
Rust研习社21 小时前
通过示例学习 Rust 模式匹配
rust
PaytonD21 小时前
基于 GPUI 实现 WebScoket 服务端之服务篇
后端·rust
OpenAnolis小助手21 小时前
玄铁 C950 发布!龙蜥社区加速 RISC-V 云计算落地
云计算·操作系统·龙蜥社区·risc-v
Source.Liu21 小时前
【Acadrust】Rust 语言的高性能 CAD 库
rust·acadrust
Bruce20489981 天前
2026 云原生安全:Rust 编写微服务网关与零信任实践
安全·云原生·rust
迷藏4941 天前
**发散创新:基于 Rust的开源权限管理系统设计与实战**在现代软件架构中,**权限控制**早已不
java·开发语言·rust·开源