riscv-emu

command module
v0.0.0-...-cb89455 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

README

riscv-emu

This is a toy RISC-V emulator. See the godoc for information how to use it.

I created this project in order to learn more about RISC-V. Don't use it in production.

This is not an officially supported Google product.

Installation

riscv-emu requires a supported release of Go.

go get -u github.com/LMMilewski/riscv-emu

Usage

To execute a RISC-V program:

riscv-emu --argv=a,hello,world --env=A=B,LANG=en_US.UTF-8 --prog=PATH_TO_RISCV_BINARY

To exeute RISC-V instructions form stdin:

echo -n -e "\x9b\x87\xa7\x02" | riscv-emu # executes "addiw a5,a5,42"

Comparing results with spike

riscv-emu has a mode that allows emulating one RISC-V instruction at a time and comparing results with the official RISC-V ISA simulator (spike). This mode requires

Usage:

riscv-emu --argv=a,hello,world --env=A=B,LANG=en_US.UTF-8 --prog=PATH_TO_RISCV_BINARY --spike=PATH_TO_SPIKE_BINARY

Documentation

Overview

riscv-emu is a toy risc-v (https://riscv.org/) emulator.

DO NOT USE THIS IN PRODUCTION. This project exists as a way for me to learn RISC-V.

riscv-emu can:

  • execute a risc-v program (ELF file) this mode has no dependencies beyond the standard library

  • execute risc-v instructions from stdin starts with registers and memory set to zero

  • step through a risc-v program and compare the state with the spike simulator

  • this mode requires:

  • Linux (for PTY)

  • cgo (https://golang.org/cmd/cgo/ for PTY)

  • spike (https://github.com/riscv/riscv-isa-sim)

To execute the program:

riscv-emu --argv=a,hello,world --env=A=B,LANG=en_US.UTF-8 --prog=PATH_TO_RISCV_BINARY

To execute instructions from stdin:

echo -n -e "\x9b\x87\xa7\x02" | riscv-emu  # executes "addiw a5,a5,42"

To compare with spike:

riscv-emu --argv=a,hello,world --env=A=B,LANG=en_US.UTF-8 --prog=PATH_TO_RISCV_BINARY --spike=PATH_TO_SPIKE_BINARY

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL