Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
RISC-V emulator with WebAssembly generated by Rust
Rust JavaScript Other
Branch: master
Clone or download
Latest commit 3e1f77f Feb 1, 2020

README.md

rvemu

Build Status
RISC-V online emulator with WebAssembly generated by Rust. The instruction sets in this emulator complies "The RISC-V Instruction Set ManualVolume I: Unprivileged ISADocument Version 20191213".

NOTE: This project is currently under intensely development. The source code might be changed dramatically.

https://riscvemu.web.app/

Supports the following RISC-V ISA features (RV64G):

  • RV32I (v2.1): supports 37/40 instructions (except FENCE, ECALL, and EBREAK)
  • RV64I (v2.1): supports 12/12 instructions (SLLI, SRLI, and SRAI are included in RV32I)
  • RV32M/RV64M (v2.0): supports 13/13 instructions
  • RV32A/RV64A (v2.0): supports 22/22 instructions (no unittests and no atomicity)
  • RV32F/RV64F (v2.2): supports 30/30 instructions
  • RV32D/RV64D (v2.2): supports 32/32 instructions
  • Zifencei (v2.0): supports 0/1 instructions (FENCE.i doesn't do anything for now)
  • Zicsr (v2.0):

Usage

The emulator supports the following commands:

  • upload: Upload a local RISC-V binary/local RISC-V binaries for an execution on the emulator.
  • ls: List the files you uploaded.
  • run [file]: Execute a file.
  • help: Print all commands you can use.

Demo

Roadmap

Supports "The RISC-V Instruction Set ManualVolume I: Unprivileged ISADocument Version 20191213"

  • RV64G ISA

Supports "The RISC-V Instruction Set ManualVolume II: Privileged ArchitectureDocument Version 20190608-Priv-MSU-Ratified"

  • Machine CSRs
  • Machine-Mode privileged instructions
  • Supervisor CSRs
  • Supervisor instructions
  • Page-Based Virtual-Memory System

Build and Run

The wasm-pack build command generates a pkg directory and makes Rust source code into .wasm binary. It also generates the JavaScript API for using our Rust-generated WebAssembly. The toolchain's supported target is wasm32-unknown-unknown. You need to execute this command whenever you change your Rust code.

$ wasm-pack build --out-dir public/pkg --target web

This command installs dependencies in the node_modules directory. Need npm install --save in the public directory at the first time and whenever you change dependencies in package.json.

$ npm install --save // at the public directory

You can see the website via http://localhost:8000. npm start is the alias of python3 -m http.server so you need Python3 in your environment.

$ npm start // at the public directory

Test

$ wasm-pack test --firefox --headless

Publish

$ firebase deploy

Dependencies

  • rust toolchain
    • rustup
    • rustc
    • cargo
      • cargo-generate
  • wasm-pack
  • npm
  • firebase CLI

Resources

Articles about this project

You can’t perform that action at this time.