Spike is the canonical RISC-V ISA simulator. It supports several ISA extensions, including some that are not yet ratified. See the README on GitHub for more information.

It is available from ports as emulators/riscv-isa-sim.

Building From Source

setenv PREFIX $HOME/riscv

git clone https://github.com/freebsd-riscv/riscv-isa-sim
cd riscv-isa-sim
mkdir build && cd build
../configure --prefix=$PREFIX
gmake install

Build a small rootfs for Spike to be used as mdroot (memory disk)

Spike has no network or disk controller, so the only way to get a root filesystem is to embed one in the kernel.

Build a memory disk with a basic set of files:

fetch https://raw.githubusercontent.com/bukinr/riscv-tools/master/image/basic.files
tools/tools/makeroot/makeroot.sh -s 32m -f basic.files mdroot.img $DESTDIR

Add the following to your kernel config to include the memory disk:

options         MD_ROOT
options         MD_ROOT_SIZE=32768      # 32MB ram disk
makeoptions     MFS_IMAGE=/path/to/mdroot.img
options         ROOTDEVNAME=\"ufs:/dev/md0\"

Run Spike

spike -m2048 -p2 /path/to/bbl

riscv/Spike (last edited 2021-06-08 18:59:51 by MitchellHorne)