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
- Open RtlStudio and select this chapter from the Examples list.
- Open
student/tb/tb_top.svin the editor. - Locate the
dut_iinstance block. - Replace
__TODO__[0]in the.gpio_inconnection withgpio_in. - Replace
__TODO__[0]in the.gpio_outconnection withgpio_out. - Locate the
$readmemhcall in the initial block. - Replace
__TODO__with the string"tb/programs/02_01_gpio_output_hex.hex". - Open
student/rtl/design.svto 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
- Open the system lesson in the IDE. The RV32I core and the mini-SoC fabric simulate together.
- Run Verilator and trace the program through MMIO: address, load/store data, and the peripheral response.
- Interrupts and DMA belong on the waveform next to the instruction stream, not only in a pass/fail line.
- 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.