⇡ lowRISC tagged memory tutorial
Simulating the Verilog (ASIC target) generated by Chisel
Here we describe how to simulate the Verilog RTL generated by Chisel using the Synopsys VCS tool. We do not currently support alternatives to VCS.
To compile the RTL simulator:
# requirements: riscv-gnu-toolchain, riscv-fesvr
# set up the RISCV environment variables
# set up the VCS environment variables
cd $TOP/vsim
make
This will generate the executable simulator as
simv-DefaultVLSIConfig
assuming the Default configuration is
used. As was the case for the Chisel emulator, for simulating a
different lowRISC configuration, TAGW32S2T4
for example, you can
either change the CONFIG variable in the Makefile or temporarily run
make as:
CONFIG=TAGW32S2T4 make
Note: if you temporarily redefine CONFIG
as above, remember to do
this before all make commands (e.g. make debug
, make run-asm-tests-vpd
,
make run-tag-tests-vpd
).
However, if you decide to the temporary CONFIG target, you need to add
the temporary target before all make commands, such as make run
.
If the VCD/VPD waveform is needed, run the following instead.
# set up the RISCV environment variables
# set up the VCS environment variables
cd $TOP/vsim
make debug
There are multiple pre-build test cases to test the Rocket Core. To run the pre-built tests:
# set up the VCS environment variables
# build and run the basic ISA test cases
make run-asm-tests
# build and run the bench-mark tests
make run-bmarks-test
# build and run the tag cache tests
make run-tag-tests
# build and run all the above tests in a single run
make run
# when VCD is required
make run-asm-tests-vcd
make run-bmarks-test-vcd
make run-tag-tests-vcd
# all tests in a single run
make run-vcd
# when VPD is required
make run-asm-tests-vpd
make run-bmarks-test-vpd
make run-tag-tests-vpd
# all tests in a single run
make run-vpd
To simulate the hello program in the three different modes (assuming
the correct type of binary has been produced, i.e. .bare
, .pk
and .linux
):
Bare metal mode
Pre-requirement: riscv-isa-sim, riscv-fesvr, riscv-gnu-toolchain
# set up the RISCV environment variables
# set up the VCS environment variables
# No VCD/VPD file
./simv-DefaultVLSIConfig -q +ntb_random_seed_automatic +dramsim \
+verbose +max-cycles=100000000 $TOP/riscv-tools/hello/hello.bare \
3>&1 1>&2 2>&3 | spike-dasm > hello.out && [ $PIPESTATUS -eq 0 ]
# VCD file
./simv-DefaultVLSIConfig-debug -q +ntb_random_seed_automatic \
+dramsim +verbose +vcdfile=hello.vcd +max-cycles=100000000 \
$TOP/riscv-tools/hello/hello.bare 3>&1 1>&2 2>&3 | \
spike-dasm > hello.out && [ $PIPESTATUS -eq 0 ]
# VPD file
./simv-DefaultVLSIConfig-debug -q +ntb_random_seed_automatic \
+dramsim +verbose +vcdplusfile=hello.vpd +max-cycles=100000000 \
$TOP/riscv-tools/hello/hello.bare 3>&1 1>&2 2>&3 | \
spike-dasm > hello.out && [ $PIPESTATUS -eq 0 ]
With proxy kernel and newlib
Requirements: riscv-isa-sim
, riscv-fesvr
, riscv-pk
, riscv-gnu-toolchain
# set up the RISCV environment variables
# set up the VCS environment variables
# No VCD/VPD file
./simv-DefaultVLSIConfig -q +ntb_random_seed_automatic +dramsim \
+verbose +max-cycles=100000000 pk $TOP/riscv-tools/hello/hello.pk \
3>&1 1>&2 2>&3 | spike-dasm > hello.out && [ $PIPESTATUS -eq 0 ]
# VCD file
./simv-DefaultVLSIConfig-debug -q +ntb_random_seed_automatic \
+dramsim +verbose +vcdfile=hello.vcd +max-cycles=100000000 \
pk $TOP/riscv-tools/hello/hello.pk 3>&1 1>&2 2>&3 | \
spike-dasm > hello.out && [ $PIPESTATUS -eq 0 ]
# VPD file
./simv-DefaultVLSIConfig-debug -q +ntb_random_seed_automatic \
+dramsim +verbose +vcdplusfile=hello.vpd +max-cycles=100000000 \
pk $TOP/riscv-tools/hello/hello.pk 3>&1 1>&2 2>&3 | \
spike-dasm > hello.out && [ $PIPESTATUS -eq 0 ]
With a full Linux OS
Pre-requirement: riscv-isa-sim, riscv-fesvr, riscv-gcc, riscv-linux, root.bin
# set up the RISCV environment variables
# set up the VCS environment variables
# boot the linux
./simv-DefaultVLSIConfig -q +ntb_random_seed_automatic +dramsim \
+verbose +max-cycles=1000000000 \
+disk=../riscv-tools/busybox-1.21.1/root.bin \
../riscv-tools/linux-3.14.13/vmlinux 3>&1 1>&2 2>&3 | \
spike-dasm > vmlinux.out && [ $PIPESTATUS -eq 0 ]
# in the booted linux
# /hello
The full Linux test can take HOURS and use up MULTIPLE GB space for log files.