RTL Studio Open IDE

2.1 · RV SYS CLASS

GPIO output hex

Connect GPIO ports and load program image to drive hex output pattern 0xAA.

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

What you practice

GPIO output hex (2.1). Connect GPIO ports and load program image to drive hex output pattern 0xAA. It is in GPIO output .hex — Part 2 · Peripheral Programs 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 configure a GPIO peripheral to act as an output and drive a specific hexadecimal value. This lesson demonstrates how software running on an RISC-V core controls external hardware pins.

Learning objectives

  • Connect the DUT GPIO ports to the testbench signals.
  • Load the correct program image into the CPU memory.
  • Verify that the GPIO output register matches the expected value.

Theory

The GPIO peripheral exposes data, output enable, and input registers via memory-mapped addresses. Software writes to the output enable register to configure pins as outputs. Software then writes to the data register to drive high or low logic levels on those pins. This lesson uses a pre-compiled program that configures all 8 pins as outputs and drives the pattern 0xAA.

Practice

  1. Open RtlStudio and select this chapter from the Examples list.
  2. Open student/tb/tb_top.sv in the editor.
  3. Locate the dut_i instance block.
  4. Replace __TODO__[0] in the .gpio_in connection with gpio_in.
  5. Replace __TODO__[0] in the .gpio_out connection with gpio_out.
  6. Locate the $readmemh call in the initial block.
  7. Replace __TODO__ with the string "tb/programs/02_01_gpio_output_hex.hex".
  8. Open student/rtl/design.sv to verify the DUT port definitions match your connections.

Summary

You practiced configuring the GPIO direction register to set pins as outputs and driving specific hexadecimal values onto the pins. By connecting the GPIO signals in the testbench and loading the program image, you verified that the peripheral correctly drives the output data register. This exercise demonstrated the fundamental process of controlling external hardware through register manipulation in a SystemVerilog testbench.

© 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 GPIO output hex. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.