8000 GitHub - Cosby5/rv64: RISC-V RV64IMAFDC(RV64GC) Emulator
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Cosby5/rv64

 
 

Repository files navigation

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, complete the build with the following commands:

$ 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
$ 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

$ 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:

$ 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.

int fib(int n) {
    if (n <= 1) {
        return n;
    }
    return fib(n - 1) + fib(n - 2);
}

int main() {
    return fib(10);
}
$ /opt/riscv/bin/riscv64-unknown-elf-gcc -o /tmp/fib ./res/program/fib.c
$ ./bin/rv64 -- /tmp/fib
$ echo $?
# 55

Licence

WTFPL.

About

RISC-V RV64IMAFDC(RV64GC) Emulator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 99.3%
  • C 0.7%
0