mirror of
https://github.com/openhwgroup/cva6.git
synced 2025-04-20 04:07:36 -04:00
Add detailed simulation flow installation info & helper scripts (#740)
* Add information for verilator flow setup to README.md * Prevent re-download if RISCV64_UNKNOWN_ELF_GCC already exists. Use variable for archive version. * Add RISC-V proxy kernel and bootloader install script * Integrate tool installation into getting-started section * Remove $ sign in command snippets to allow command copy & paste * Add information for verilator flow setup to README.md * Prevent re-download if RISCV64_UNKNOWN_ELF_GCC already exists. Use variable for archive version. * Add RISC-V proxy kernel and bootloader install script * Integrate tool installation into getting-started section * Remove $ sign in command snippets to allow command copy & paste * Replace manual install command for riscv-pk by script * Fix README.md merge conflict mismatches * Fix script name Co-authored-by: Nils Wistoff <nwistoff@iis.ee.ethz.ch> Co-authored-by: Nils Wistoff <nwistoff@iis.ee.ethz.ch>
This commit is contained in:
parent
6cd1cfe796
commit
206916d706
3 changed files with 82 additions and 59 deletions
118
README.md
118
README.md
|
@ -60,7 +60,10 @@ Table of Contents
|
|||
* [CVA6 RISC-V CPU](#cva6-risc-v-cpu)
|
||||
* [Table of Contents](#table-of-contents)
|
||||
* [Getting Started](#getting-started)
|
||||
* [Running User-Space Applications](#running-user-space-applications)
|
||||
* [Checkout Repo](#checkout-repo)
|
||||
* [Install Verilator Simulation Flow](#install-verilator-simulation-flow)
|
||||
* [Build Model and Run Simulations](#build-model-and-run-simulations)
|
||||
* [Running User-Space Applications](#running-user-space-applications)
|
||||
* [FPGA Emulation](#fpga-emulation)
|
||||
* [Programming the Memory Configuration File](#programming-the-memory-configuration-file)
|
||||
* [Preparing the SD Card](#preparing-the-sd-card)
|
||||
|
@ -77,52 +80,50 @@ Table of Contents
|
|||
|
||||
Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)
|
||||
|
||||
## Tool Requirements
|
||||
|
||||
* `verilator >= 4.002`
|
||||
|
||||
> There is currently a known issue with version 4.106 and 4.108. 4.106 does not
|
||||
> compile and 4.108 hangs after a couple of cycles simulation time.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Go and get the [RISC-V tools](https://github.com/riscv/riscv-tools).
|
||||
Make sure that your `RISCV` environment variable points to your RISC-V installation (see the RISC-V tools and related projects for further information).
|
||||
<br><br>
|
||||
Checkout the repository and initialize all submodules:
|
||||
### Checkout Repo
|
||||
|
||||
Checkout the repository and initialize all submodules
|
||||
```
|
||||
$ git clone -b cva6_reorg https://github.com/openhwgroup/cva6.git cva6_reorg
|
||||
$ cd cva6_reorg
|
||||
$ git submodule update --init --recursive
|
||||
git clone https://github.com/openhwgroup/cva6.git
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
Build the Verilator model of the COREV-APU by using the Makefile:
|
||||
### Install Verilator Simulation Flow
|
||||
|
||||
1. Setup install directory `RISCV` environment variable i.e. `export RISCV=/YOUR/TOOLCHAIN/INSTALLATION/DIRECTORY`
|
||||
2. Run `./ci/setup.sh` to install all required tools (i.e. verilator, device-tree-compiler, riscv64-unknown-elf-*, ..)
|
||||
|
||||
You can install verilator from source using `./ci/install-verilator.sh` or by manually installing `verilator >= 4.002`
|
||||
Note: There is currently a known issue with version 4.106 and 4.108. 4.106 does not compile and 4.108 hangs after a
|
||||
couple of cycles simulation time.)
|
||||
|
||||
|
||||
### Build Model and Run Simulations
|
||||
|
||||
Build the Verilator model of CVA6 by using the Makefile:
|
||||
```
|
||||
$ make verilate
|
||||
make verilate
|
||||
```
|
||||
|
||||
To build the verilator model with support for vcd files run
|
||||
```
|
||||
$ make verilate DEBUG=1
|
||||
make verilate DEBUG=1
|
||||
```
|
||||
|
||||
This will create a C++ model of the core including a SystemVerilog wrapper and link it against a C++ testbench (in the `tb` subfolder).
|
||||
The binary can be found in the `work-ver` and accepts a RISC-V ELF binary as an argument, e.g.:
|
||||
This will create a C++ model of the core including a SystemVerilog wrapper and link it against a C++ testbench (in the `tb` subfolder). The binary can be found in the `work-ver` and accepts a RISC-V ELF binary as an argument, e.g.:
|
||||
|
||||
```
|
||||
$ work-ver/Variane_testharness rv64um-v-divuw
|
||||
work-ver/Variane_testharness rv64um-v-divuw
|
||||
```
|
||||
|
||||
The Verilator testbench makes use of the `riscv-fesvr`.
|
||||
This means that you can use the `riscv-tests` repository as well as `riscv-pk` out-of-the-box.
|
||||
As a general rule of thumb the Verilator model will behave like Spike (exception for being orders of magnitudes slower).
|
||||
The Verilator testbench makes use of the `riscv-fesvr`. This means that you can use the `riscv-tests` repository as well as `riscv-pk` out-of-the-box. As a general rule of thumb the Verilator model will behave like Spike (exception for being orders of magnitudes slower).
|
||||
|
||||
Both the Verilator model as well as the Questa simulation will produce trace logs.
|
||||
The Verilator trace is more basic but you can feed the log to `spike-dasm` to resolve instructions to mnemonics.
|
||||
Unfortunately value inspection is currently not possible for the Verilator trace file.
|
||||
Both, the Verilator model as well as the Questa simulation will produce trace logs. The Verilator trace is more basic but you can feed the log to `spike-dasm` to resolve instructions to mnemonics. Unfortunately value inspection is currently not possible for the Verilator trace file.
|
||||
|
||||
```
|
||||
$ spike-dasm < trace_hart_00.dasm > logfile.txt
|
||||
spike-dasm < trace_hart_00.dasm > logfile.txt
|
||||
```
|
||||
|
||||
To build, compile and run the CVA6 core-only in its example testbench using Verilator (known to work with V4.108):
|
||||
|
@ -135,37 +136,38 @@ $ make veri_run
|
|||
|
||||
### Running User-Space Applications
|
||||
|
||||
It is possible to run user-space binaries on CVA6 with `riscv-pk` ([link](https://github.com/riscv/riscv-pk)).
|
||||
It is possible to run user-space binaries on CVA6 with ([RISC-V Proxy Kernel and Boot Loader](https://github.com/riscv/riscv-pk)).
|
||||
RISC-V PK can be installed by running: `./ci/install-riscvpk.sh`
|
||||
|
||||
```
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ ../configure --prefix=$RISCV --host=riscv64-unknown-elf
|
||||
$ make
|
||||
$ make install
|
||||
mkdir build
|
||||
cd build
|
||||
../configure --prefix=$RISCV --host=riscv64-unknown-elf
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
Then to run a RISC-V ELF using the Verilator model do:
|
||||
|
||||
```
|
||||
$ echo '
|
||||
echo '
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
printf("Hello CVA6!\\n");
|
||||
return 0;
|
||||
}' > hello.c
|
||||
$ riscv64-unknown-elf-gcc hello.c -o hello.elf
|
||||
riscv64-unknown-elf-gcc hello.c -o hello.elf
|
||||
```
|
||||
|
||||
```
|
||||
$ make verilate
|
||||
$ work-ver/Variane_testharness $RISCV/riscv64-unknown-elf/bin/pk hello.elf
|
||||
make verilate
|
||||
work-ver/Variane_testharness $RISCV/riscv64-unknown-elf/bin/pk hello.elf
|
||||
```
|
||||
|
||||
If you want to use QuestaSim to run it you can use the following command:
|
||||
```
|
||||
$ make sim elf-bin=$RISCV/riscv64-unknown-elf/bin/pk target-options=hello.elf batch-mode=1
|
||||
make sim elf-bin=$RISCV/riscv64-unknown-elf/bin/pk target-options=hello.elf batch-mode=1
|
||||
```
|
||||
|
||||
> Be patient! RTL simulation is way slower than Spike. If you think that you ran into problems you can inspect the trace files.
|
||||
|
@ -202,7 +204,7 @@ The first stage bootloader will boot from SD Card by default. Get yourself a sui
|
|||
|
||||
Connect a terminal to the USB serial device opened by the FTDI chip e.g.:
|
||||
```
|
||||
$ screen /dev/ttyUSB0 115200
|
||||
screen /dev/ttyUSB0 115200
|
||||
```
|
||||
|
||||
Default baudrate set by the bootlaoder and Linux is `115200`.
|
||||
|
@ -214,7 +216,7 @@ After you've inserted the SD Card and programmed the FPGA you can connect to the
|
|||
To generate the FPGA bitstream (and memory configuration) yourself for the Genesys II board run:
|
||||
|
||||
```
|
||||
$ make fpga
|
||||
make fpga
|
||||
```
|
||||
|
||||
This will produce a bitstream file and memory configuration file (in `fpga/work-fpga`) which you can permanently flash by running the above commands.
|
||||
|
@ -239,7 +241,8 @@ Bus 005 Device 019: ID 0403:6010 Future Technology Devices International, Ltd FT
|
|||
If this is the case, you can go on and start openocd with the `fpga/ariane.cfg` configuration file:
|
||||
|
||||
```
|
||||
$ openocd -f fpga/ariane.cfg
|
||||
openocd -f fpga/ariane.cfg
|
||||
|
||||
Open On-Chip Debugger 0.10.0+dev-00195-g933cb87 (2018-09-14-19:32)
|
||||
Licensed under GNU GPL v2
|
||||
For bug reports, read
|
||||
|
@ -261,7 +264,8 @@ Info : accepting 'gdb' connection on tcp/3333
|
|||
Then you will be able to either connect through `telnet` or with `gdb`:
|
||||
|
||||
```
|
||||
$ riscv64-unknown-elf-gdb /path/to/elf
|
||||
riscv64-unknown-elf-gdb /path/to/elf
|
||||
|
||||
(gdb) target remote localhost:3333
|
||||
(gdb) load
|
||||
Loading section .text, size 0x6508 lma 0x80000000
|
||||
|
@ -306,7 +310,7 @@ The core has been developed with a full licensed version of QuestaSim. If you ha
|
|||
|
||||
To specify the test to run use (e.g.: you want to run `rv64ui-p-sraw` inside the `tmp/risc-tests/build/isa` folder:
|
||||
```
|
||||
$ make sim elf-bin=path/to/rv64ui-p-sraw
|
||||
make sim elf-bin=path/to/rv64ui-p-sraw
|
||||
```
|
||||
|
||||
If you call `sim` with `batch-mode=1` it will run without the GUI. QuestaSim uses `riscv-fesvr` for communication as well.
|
||||
|
@ -320,17 +324,17 @@ If you would like to run the CI test suites locally on your machine, follow any
|
|||
Once everything is set up and installed, you can run the tests suites as follows (using Verilator):
|
||||
|
||||
```
|
||||
$ make verilate
|
||||
$ make run-asm-tests-verilator
|
||||
$ make run-benchmarks-verilator
|
||||
make verilate
|
||||
make run-asm-tests-verilator
|
||||
make run-benchmarks-verilator
|
||||
```
|
||||
|
||||
In order to run randomized Torture tests, you first have to generate the randomized program prior to running the simulation:
|
||||
|
||||
```
|
||||
$ ./ci/get-torture.sh
|
||||
$ make torture-gen
|
||||
$ make torture-rtest-verilator
|
||||
./ci/get-torture.sh
|
||||
make torture-gen
|
||||
make torture-rtest-verilator
|
||||
```
|
||||
This runs the randomized program on Spike and on the RTL target, and checks whether the two signatures match. The random instruction mix can be configured in the `./tmp/riscv-torture/config/default.config` file.
|
||||
|
||||
|
@ -345,12 +349,12 @@ This will dump a file called `trace_hart_*_*_commit.log`.
|
|||
This can be helpful for debugging long traces (e.g.: torture traces). To compile Spike with the commit log feature do:
|
||||
|
||||
```
|
||||
$ apt-get install device-tree-compiler
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ ../configure --prefix=$RISCV --with-fesvr=$RISCV --enable-commitlog
|
||||
$ make
|
||||
$ [sudo] make install
|
||||
apt-get install device-tree-compiler
|
||||
mkdir build
|
||||
cd build
|
||||
../configure --prefix=$RISCV --with-fesvr=$RISCV --enable-commitlog
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
### Memory Preloading
|
||||
|
@ -362,7 +366,7 @@ to a binary which will be preloaded.
|
|||
> You will loose all `riscv-fesvr` communcation like sytemcalls and eoc capabilities.
|
||||
|
||||
```
|
||||
$ make sim preload=elf
|
||||
make sim preload=elf
|
||||
```
|
||||
|
||||
<!-- ### Tandem Verification with Spike
|
||||
|
|
16
ci/install-riscvpk.sh
Executable file
16
ci/install-riscvpk.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
PATH=$RISCV/bin:/bin:$PATH
|
||||
|
||||
cd $ROOT/tmp
|
||||
|
||||
echo "Installing RISC-V Proxy Kernel and Boot Loader"
|
||||
git clone https://github.com/riscv-software-src/riscv-pk.git
|
||||
cd riscv-pk
|
||||
mkdir -p build
|
||||
cd build
|
||||
../configure --prefix=$RISCV --host=riscv64-unknown-elf
|
||||
make
|
||||
make install
|
|
@ -15,7 +15,10 @@ sudo apt install verilator-4.100 device-tree-compiler
|
|||
|
||||
ci/make-tmp.sh
|
||||
sudo mkdir -p $RISCV && sudo chmod 777 $RISCV
|
||||
wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2020.04.0-x86_64-linux-ubuntu14.tar.gz
|
||||
tar -x -f riscv64-unknown-elf-gcc-8.3.0-2020.04.0-x86_64-linux-ubuntu14.tar.gz --strip-components=1 -C $RISCV
|
||||
RISCV64_UNKNOWN_ELF_GCC=riscv64-unknown-elf-gcc-8.3.0-2020.04.0-x86_64-linux-ubuntu14.tar.gz
|
||||
if [ ! -f "$RISCV64_UNKNOWN_ELF_GCC" ]; then
|
||||
wget https://static.dev.sifive.com/dev-tools/$RISCV64_UNKNOWN_ELF_GCC
|
||||
fi
|
||||
tar -x -f $RISCV64_UNKNOWN_ELF_GCC --strip-components=1 -C $RISCV
|
||||
ci/install-fesvr.sh
|
||||
ci/build-riscv-tests.sh
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue