Vproc_n1/examples/riscv
David Rodriguez c2f821f6da Merge remote-tracking branch 'Documents/master'
I am includding a document folder to send the repo to Forgejo
2026-04-06 19:31:14 +01:00
..
include Merge remote-tracking branch 'Documents/master' 2026-04-06 19:31:14 +01:00
interrupt Added RISC-V test example executable and source 2024-04-10 11:31:19 +01:00
lib Upgraded rv32 RISC-V version to 1.2.11 in examples/riscv 2025-09-30 08:21:31 +01:00
src Fix to rv32 RISC-V ISS example 2025-09-30 09:24:48 +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 Dropped support for Verilog PLI to use VPI only for those simulators that use it. 2024-10-14 13:41:02 +01:00
makefile.verilator Dropped support for Verilog PLI to use VPI only for those simulators that use it. 2024-10-14 13:41:02 +01:00
mtimer.v Added FreeRTOS to RISC-V demonstration example code 2024-06-21 11:51:38 +01:00
README.md Updated README.md of examples/riscv 2025-09-30 09:44:24 +01:00
riscVsim.v Added FreeRTOS to RISC-V demonstration example code 2024-06-21 11:51:38 +01:00
test.v Fix to rv32 RISC-V ISS example 2025-09-30 09:24:48 +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 Fix to rv32 RISC-V ISS example 2025-09-30 09:24:48 +01:00

RISC-V ISS model demonstration example

This directory contains an example of co-simulating a RISC-V instruction set simulator C++ model. rv32, 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 execution 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 on Questa (or Verilator with the optional argument), use the make command:

make [-f makefile.verilator] run

FreeRTOS test (Verilator only)

This example uses the demo code from the rv32 RISC-V ISS repository found on github. 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