Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mohanson/rv64
RISC-V RV64IMAFDC(RV64GC) Emulator
https://github.com/mohanson/rv64
emulator golang riscv
Last synced: 3 months ago
JSON representation
RISC-V RV64IMAFDC(RV64GC) Emulator
- Host: GitHub
- URL: https://github.com/mohanson/rv64
- Owner: mohanson
- Created: 2020-02-16T06:34:17.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-07T00:19:39.000Z (almost 2 years ago)
- Last Synced: 2024-06-20T12:49:06.231Z (8 months ago)
- Topics: emulator, golang, riscv
- Language: Go
- Homepage:
- Size: 60.5 KB
- Stars: 12
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RISC-V RV64IMAFDC Emulator
An outstanding RISC-V RV64IMAFDC(RV64GC) simulator.
# Install riscv-gnu-toolchain
First of all, riscv gnu toolchain must be installed. Source repo is at [https://github.com/riscv/riscv-gnu-toolchain](https://github.com/riscv/riscv-gnu-toolchain), complete the build with the following commands:
```sh
$ apt install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
``````sh
$ git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
$ cd riscv-gnu-toolchain
$ git submodule update --init --recursive
$ ./configure --prefix=/opt/riscv --with-arch=rv64gc
$ make
```# Install rv64
```sh
$ git clone https://github.com/mohanson/rv64
$ cd rv64
$ go run cmd/make/main.go
```The binary file `rv64` will be located at the `./bin` directory. Could test it with the following command:
```sh
$ export RISCV=/opt/riscv
$ ./bin/make test[ok] $ ./bin/rv64 /tmp/riscv-tests/isa/rv64ua-u-amoadd_d
[ok] $ ./bin/rv64 /tmp/riscv-tests/isa/rv64ua-u-amoadd_w
# Many lines ...
[ok] $ ./bin/rv64 /tmp/riscv-tests/isa/rv64um-u-remuw
[ok] $ ./bin/rv64 /tmp/riscv-tests/isa/rv64um-u-remw
```# Lick it
Let's compile a simple C file, which implements the fibonacci function.
```c
int fib(int n) {
if (n <= 1) {
return n;
}
return fib(n - 1) + fib(n - 2);
}int main() {
return fib(10);
}
``````sh
$ /opt/riscv/bin/riscv64-unknown-elf-gcc -o /tmp/fib ./res/program/fib.c
$ ./bin/rv64 -- /tmp/fib
$ echo $?
# 55
```# Licence
WTFPL.