Vproc_n1/examples/riscv
2024-07-27 13:17:14 +01:00
..
include Updated rv32 libraries and headers to ISS release 1.0 2024-07-18 15:35:40 +01:00
interrupt Added RISC-V test example executable and source 2024-04-10 11:31:19 +01:00
lib Updated rv32 libraries and headers to latest (0.38) 2024-07-17 09:56:41 +01:00
src Removed redundant variable. 2024-07-03 08:40:12 +01:00
files.verilator Added FreeRTOS to RISC-V demonstration example code 2024-06-21 11:51:38 +01:00
main.exe Added FreeRTOS to RISC-V demonstration example code 2024-06-21 11:51:38 +01:00
makefile Updated makefiles to default to building for Questa and 64-bit compilations. Updated regression script to use makefile in place of makefile.questa and makefile HDL=VHDL in place of makefile.vhd. 2024-07-27 13:17:14 +01:00
makefile.verilator Removed optimisation flag from Verilator make file. 2024-07-03 08:39:39 +01:00
mtimer.v Added FreeRTOS to RISC-V demonstration example code 2024-06-21 11:51:38 +01:00
README.md Update README.md with added setup diagram 2024-06-21 12:07:36 +01:00
riscVsim.v Added FreeRTOS to RISC-V demonstration example code 2024-06-21 11:51:38 +01:00
test.v Corrected header information 2024-07-05 10:32:26 +01:00
test.vc Added FreeRTOS to RISC-V demonstration example code 2024-06-21 11:51:38 +01:00
uart.v Added FreeRTOS to RISC-V demonstration example code 2024-06-21 11:51:38 +01:00
vusermain.cfg Updated rv32 ISS to latest version (v0.32) 2024-07-04 08:39:34 +01:00

RISC-V ISS model demonstration example

This directory contains an example of co-simulating a RISC-V instruction set simulator C++ model on VProc with a simple test HDL environment with models for memory, timer, and a terminal model with UART interface to display text, capable of running a program in the FreeRTOS operating system. The setup is shown in the diagram below:

Simple assembly code test

To run the simple assembly code test to generate an interrupt and invoke an ISR, vusermain.cfg should be configured as follows:

vusermain0 -rbH -D disassem.log -t ./interrupt/test.exe

The -r option enables run-time disassembler output, with the -D option directing this to the file disassem.log. The -b option specifies to halt at a specific address (defaulting to 0x00000040) and the -H option specifies to halt on decoding an unimplemented instruction. The -t option selects the compiled RISC-V test executable to be loaded and run.

To run the test, use the make command:

make [-f makefile.verilator] run

FreeRTOS test (verilator only)

This example uses the demo code fro the rv32 RISC-V ISS repository found on github: https://github.com/wyvernSemi/riscV/tree/main/freertos. An executable is provided in this directory (main.exe), but to compile the code from the ISS repository use the folllowing make command:

make USRFLAGS="-DCOSIM"

This compiles the demo program (demo/main.c), support functions and FreeRTOS configuration (rv32/*.[ch]) and FreeRTOS operating system. The resultant executable's text and read-only data is compiled at offset 0x00000000, data and BSS at 0x00080000, and with heap above and stack top at 0x00082000. The mtime timer registers are configured in FreeRTOS to start from 0xaffffffe0, and the UART driver code expects the terminal to start at 0x80000000.

To run FreeRTOS demo, vusermain.cfg must be set as follows:

vusermain0 -T -t ./main.exe

The -T option specifies to use an external model for the mtime/mtimecmp timer, rather than the internal ISS model for the timer. This directs accesses to the timer to the memory mapped bus, and the HDL timer model is then accessed.

Run FreeRTOS demo forever

To run the simulation without a timeout, and without generating waveform data, use the make command:

make -f makefile.verilator USRSIMFLAGS="-GTIMEOUTCOUNT=0 -GRISCVTEST=1" run

Run FreeRTOS demo for 20ms in GUI mode

To run the demo for a given time (20ms in example), generating waveform data to be displayed in gtkwave, use the make command:

make -f makefile.verilator USRSIMFLAGS="-GVCD_DUMP=1 -GTIMEOUTCOUNT=2000000 -GRISCVTEST=1" gui