What you practice
GPIO input poll (2.2). Complete the GPIO input poll by connecting testbench signals and loading the program hex file. It is in GPIO input poll loop — 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 learn how to configure GPIO pins as inputs and outputs. You will also learn to read the input register and echo the value back to the output pins. This is a fundamental technique for peripheral programming.
Learning objectives
- Connect the testbench signals to the DUT ports correctly.
- Load the assembly program from a hex file into the instruction memory.
- Verify that the GPIO output matches the GPIO input after execution.
Theory
The GPIO peripheral exposes data registers for input and output. The output enable register controls whether a pin drives a value or floats. The CPU reads the input register and writes to the output register to control pins.
| Register | Direction | Description |
|---|---|---|
gpio_in | Input | Current state of GPIO pins |
gpio_out | Output | Value driven by CPU |
gpio_oe | Output | Output Enable (1=drive, 0=float) |
This lesson uses a simple poll loop to verify the connection.
Practice
Open this chapter in RtlStudio to load the workspace. Files appear immediately in the Explore tree.
- Open
student/tb/tb_top.svto edit the testbench. - Open
student/rtl/design.svto review the design structure. - In
student/tb/tb_top.sv, connect thegpio_in,gpio_out, andgpio_oesignals in the DUT instance. - In
student/tb/tb_top.sv, load the program hex filetb/programs/02_02_gpio_input_poll.hex. - Run Simulation from the sidebar.
- Check the Log panel for results.
Summary
You practiced connecting GPIO ports in the testbench to verify the SoC's ability to route input data to output pins. The key takeaway is understanding how to echo a fixed input value through the peripheral logic using a simple polling program. This exercise reinforces fundamental skills in peripheral programming and testbench verification.
© 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 input poll. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.