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

相关推荐
Naylor15 小时前
只借不占:Rust 的引用与借用
后端·rust
对象存储与RustFS20 小时前
RustFS 后台扫描器与自愈调参:五档速度、位腐检测周期与并发上限
后端·rust·开源
q平面人1 天前
【总工笔记】mindoc平板、桌面端笔记软件,发布到mindoc服务端
rust·tauri·华为平板·mindoc·总工笔记
MC皮蛋侠客1 天前
Tauri 2.x 系列(九):安全模型——Capabilities、Permissions、Scope 与 CSP
rust·tauri
Source.Liu1 天前
【Dioxus】Windows 环境下 Rust + Dioxus 安装配置笔记
windows·rust·dioxus
zLLM_Lab2 天前
不装 Python/PyTorch:8.1 MB Rust 程序在 MacBook Air M5 跑多模态大模型
rust
梦醒沉醉2 天前
std1.97.1——result模块细览
rust
Thneonl2 天前
同一资源、不同 ID:多源拓扑的 Identity Resolution
架构·rust
绍磊leo2 天前
【保姆级】dora-rs 一键安装脚本:类ros2的fishros 风格交互菜单 + 国内镜像加速,把坑都替你踩完了
rust·dora-rs
Ramble_Naylor2 天前
只借不占:Rust 的引用与借用
开发语言·rust