RTL Studio Open IDE

1.5 · RV SYS CLASS

Link script hex

Load a program image from tb/programs into the instruction ROM and connect peripheral signals in the testbench.

Video coming soon. This lesson page stays at the same URL when the lecture publishes.

What you practice

Link script hex (1.5). Load a program image from tb/programs into the instruction ROM and connect peripheral signals in the testbench. It is in Link script to .hex layout — Part 1 · Core on Bus (MMIO) of the RISC-V on SoC & System Masterclass.

The core and the mini-SoC simulate as one workspace in the IDE. Follow MMIO, interrupts, and the program on the Verilator waveform, not only a pass line.

What you will learn

You will learn how to load a compiled program image into the instruction memory of an RV32I core. This step is critical for verifying that the core fetches and executes the correct instructions from a specific memory layout. You will practice connecting peripheral signals and initializing the instruction ROM with a hex file.

Learning objectives

  • Connect the GPIO and interrupt signals in the testbench top module.
  • Load a program image from the tb/programs directory into the testbench memory array.
  • Preload the instruction ROM (u_imem.mem) with the loaded program data.
  • Verify core execution by checking the halted status and GPIO output values.

Theory

The testbench acts as the environment that drives the Design Under Test (DUT). It must provide clock, reset, and peripheral I/O signals. The DUT wraps the RV32I core and the system peripherals. The core fetches instructions from its internal Instruction Memory (IMEM). To test a specific program, the testbench must load the compiled machine code into this memory before releasing reset. The $readmemh system task reads a hexadecimal file into a SystemVerilog array. This array is then copied into the DUT's internal memory structure. Correct signal connection ensures the core can communicate with GPIO and interrupt lines during execution.

Practice

  1. Open RtlStudio and select Lesson 1.5: Link script hex.
  2. Open student/tb/tb_top.sv in the Explore panel.
  3. Locate the dut_i instance inside the module.

Replace the placeholder port connections for gpio_in, gpio_out, and gpio_oe with the correct signal names defined in the testbench (e.g., gpio_in, gpio_out, gpio_oe).

  1. Locate the $readmemh system task call.

Replace the placeholder string with the exact path: tb/programs/01_05_link_script_hex_layout.hex.

  1. Open Simulation from the sidebar and click Run.
  2. Check the Log panel for the INFO: messages and the final INFO: PASS line.

Summary

You successfully loaded a compiled program image into the instruction memory using the $readmemh task. You practiced mapping the testbench array to the core's instruction ROM and connecting the GPIO ports in the design instance. This exercise demonstrated how software binaries are integrated into hardware simulation for correct execution.

© 2026 RtlStudio. Licensed under CC BY-NC-ND 4.0. Commercial use and modifications by third parties are not permitted.

Run it in the Verilog IDE

  1. Open the system lesson in the IDE. The RV32I core and the mini-SoC fabric simulate together.
  2. Run Verilator and trace the program through MMIO: address, load/store data, and the peripheral response.
  3. Interrupts and DMA belong on the waveform next to the instruction stream, not only in a pass/fail line.
  4. Edit the integration RTL, resimulate, and run Yosys on the structural block when you want a netlist.

The lesson is done when the simulation matches Link script hex. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.