A RISC-V emulator supoorting RV32I instruction set written in Rust

Related tags

Emulators rv_emu_rs
Overview

32-bit RISC-V Emulator in Rust

This is a RISC-V emulator supoorting RV32I instruction set written in Rust, inspired by Francis Stokes's RISC-V Emulator in Typescript. (He made a fascinating series of videos on this topic!) You can either run this repository as a stand-alone binary or a WASM package, which can be embeded to a website. Try it out here!


Usage

Make sure you have rust developing environment installed. RISC-V GNU Toolchain is not necessary. If the toolchain is not found in your PATH, a docker image containing the toolchain will be pulled automatically.

Stand alone binary

The emulator supports running customized C program. To run your own C program, perform the following steps:

  1. Put the C file in test_payloads/src directory
  2. Run make in the top directory
  3. Run cargo run test_payloads/build/[filename].bin

Note:

  • The only output method is using register/memory dump. Currently no privileged level is supported so no syscall can be handled, which means functions like printf are not allowed.
  • Memory starts at 0x8000_0000
  • .bin suffix is necessary, which will be automatically generated along with the elf file.

WASM Package

The emulator can also be compiled into a WASM lib. Run make in the top directory and you will get a pkg directory containing the library. To use the library inside JS/TS, copy the pkg directory to your project and import it as the following:

{ // your codes here... ... // romArray is a u8 array containing binary codes // memSize is the length of memory dump emulate(romArray, memSize); ... }); ">
import init, { emulate } from "./pkg/rv_emu_rs.js";

init()
    .then(() => {
        // your codes here...

        ...
        // romArray is a u8 array containing binary codes
        // memSize is the length of memory dump
        emulate(romArray, memSize);
        ...
    });
You might also like...
ZX Spectrum emulator written in Rust
ZX Spectrum emulator written in Rust

rustzx ZX Spectrum emulator which I writing in rust. I develop this project just for fun and for learning the basics of computer architecture. License

CHIP-8 emulator written in Rust
CHIP-8 emulator written in Rust

CHIP-8 emulator written in Rust. This is intended to be a project for gaining experience writing emulators and practice Rust.

A 6502 emulator written in Rust.

v6502 This package contains an emulator for the 6502 microprocessor. It doesn't support binary decimal (BCD) mode yet. To run the debug version: cargo

Spaghetti Chip8 Emulator Written In Rust

How to run? Command is simple: cargo run FILENAME. files are stored in the /c8games folder, use one of them. Example: cargo run INVADERS Keymap use 1

Non cycle-accurate emulator of the 6502 cpu, written in pure rust

CPU 6502 A non cycle-accurate emulator implementing all legal 6502 opcodes. What does non cycle-accurate mean? Every instruction on the 6502 takes a n

Experimental Nintendo Switch Emulator written in Rust

Kaminari Experimental Nintendo Switch Emulator written in Rust Usage You'll need to install Rust. rusc = 1.55.0 rustup = 1.24.3 Disclaimer Kaminari

A barely functional terminal emulator written in Rust. For nothing but fun.

Nothing much to say now. The basic architecture (kind of) so far is: ┌────────┐ ┌──────────────────┐ │ ptm │◀──────▶│ device::Shell │ └─┬

A Chip8 Emulator written in Rust

Chipper: Chipper is a Chip8 Emulator written in Rust. It currently supports a few known quirks of the Chip8 varieties. I intend on making it support t

A CHIP-8 emulator written in Rust

damn8 A CHIP-8 emulator written in Rust To run, pass a path to a rom in the command line. TODO: Use function pointers to handle opcodes instead of a l

Owner
null
Nes-emulator - A NES emulator made to learn the Rust programming language

nes-emulator Building $ rustc --version rustc 1.32.0 (9fda7c223 2019-01-16) $ cargo --version cargo 1.32.0 (8610973aa 2019-01-02) $ cargo build --rel

Michael Burge 225 Dec 23, 2022
Assured Confidential Execution (ACE) for RISC-V

Assured Confidential Execution (ACE) for RISC-V ACE-RISCV is an open-source project, whose goal is to deliver a confidential computing framework with

International Business Machines 12 Oct 6, 2023
NES emulator written in Rust to learn Rust

OxideNES A NES emulator in Rust. CPU should be accurate, PPU is mostly accurate, timing between the 2 is off for some corner cases and hardware qui

null 37 Nov 7, 2022
Chip8 emulator written in pure rust, using rust-sdl2 for graphics

Rust-8 chip8 emulator written in rust, using rust-sdl2 for graphics. Features Fully implemented all 35 original chip8 opcodes. This emulator does NOT

Chris Hinson 7 Dec 28, 2022
Commodore 64 emulator written in Rust

Rust64 - a C64 emulator written in Rust This is my attempt to study the Rust programming language and have fun at the same time. The goal is to presen

Krzysztof Kondrak 214 Dec 27, 2022
A Flash Player emulator written in Rust

website | demo | nightly builds | wiki Ruffle Ruffle is an Adobe Flash Player emulator written in the Rust programming language. Ruffle targets both t

Ruffle 11.2k Jan 8, 2023
A Game Boy research project and emulator written in Rust

Mooneye GB Mooneye GB is a Game Boy research project and emulator written in Rust. The main goals of this project are accuracy and documentation. Some

Joonas Javanainen 802 Dec 28, 2022
RustBoyAdvance-NG is a Nintendo™ Game Boy Advance emulator and debugger, written in the rust programming language.

RustBoyAdvance-NG Nintendo GameBoy Advance ™ emulator and debugger, written in rust. WebAssembly Demo: https://michelhe.github.io/rustboyadvance-ng/ P

MishMish 510 Dec 30, 2022
An NES emulator written in Rust

Pinky Pinky is an NES emulator written in Rust completely from scratch based only on publicly available documentation. You can run it in your Web brow

Koute 709 Dec 23, 2022
NES emulator written in Rust

sprocketnes is an emulator for the Nintendo Entertainment System written in the Rust programming language. Its purpose is to serve as a technology dem

Patrick Walton 725 Dec 27, 2022