9 releases

✓ Uses Rust 2018 edition

0.0.9 Mar 20, 2020
0.0.8 Mar 15, 2020

#21 in Emulators

Download history 62/week @ 2020-03-02 48/week @ 2020-03-09 87/week @ 2020-03-16

56 downloads per month

MIT license

2.5K SLoC

RISC-V emulator core implementation

Build Status Actions Status docs.rs crate.io License

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

How to use

Create an Emulator object, place a binary data in DRAM and set the program counter to DRAM_BASE. The binary data must contain no headers for now. The example is here:

use rvemu::bus::DRAM_BASE;
use rvemu::emulator::Emulator;

fn main() {
    // Create a dummy binary data.
    let data = vec![
        0x93, 0x0f, 0xa0, 0x02, // addi x31, x0, 42

    // Create an emulator object.
    let mut emu = Emulator::new();
    // Place the binary data in the beginning of DRAM.
    // Set the program counter to 0x8000_0000, which is the address DRAM starts.
    // Start the emulator.

    // `IllegalInstruction` is raised for now because of the termination condition of the emulator,
    // but the register is successfully updated.
    assert_eq!(42, emu.cpu.xregs.read(31));

See the example usage in rvemu/lib/rvemu-cli/src/main.rs.


Now, supports the following features (will be added in the future):

  • RV64G ISAs
  • Privileged ISAs
  • Control and status registers (CSRs)
  • Virtual memory system (Sv39)
  • Devices
    • UART: universal asynchronous receiver-transmitter
    • CLINT: core local interruptor
    • PLIC: platform level interrupt controller
    • Virtio


~37K SLoC