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

相关推荐
KENYCHEN奉孝3 小时前
Rust征服字节跳动:高并发服务器实战
服务器·开发语言·rust
明天好,会的10 小时前
跨平台ZeroMQ:在Rust中使用zmq库的完整指南
开发语言·后端·rust
liulun11 小时前
在浏览器中使用SQLite(官方sqlite3.wasm)
数据库·sqlite·wasm
寻月隐君14 小时前
Rust 网络编程实战:用 Tokio 手写一个迷你 TCP 反向代理 (minginx)
后端·rust·github
芳草萋萋鹦鹉洲哦1 天前
【vue3+tauri+rust】如何实现下载文件mac+windows
windows·macos·rust
寻月隐君1 天前
Rust 异步编程实践:从 Tokio 基础到阻塞任务处理模式
后端·rust·github
萧曵 丶1 天前
Rust 中的返回类型
开发语言·后端·rust
浪裡遊1 天前
Sass详解:功能特性、常用方法与最佳实践
开发语言·前端·javascript·css·vue.js·rust·sass
受之以蒙2 天前
Rust & WASM 之 wasm-bindgen 基础:让 Rust 与 JavaScript 无缝对话
前端·笔记·rust
Elixin2 天前
第一章:环境搭建
rust