What you practice
Timer delay loop (2.3). Enable the timer from software and read its control register back to verify peripheral configuration. It is in Timer delay 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 enable the timer peripheral from software and verify its control register state. This exercise demonstrates how to interact with hardware registers using a simple delay loop. Understanding this pattern is essential for low-level system initialization. You will also learn how to verify peripheral behavior using a testbench. This lesson builds on the previous timer configuration steps.
Learning objectives
- Enable the timer peripheral via software register writes.
- Read back the timer control register to verify the configuration.
- Inspect the simulation log for correct peripheral state changes.
- Understand the relationship between software execution and hardware signals.
Theory
The timer peripheral is a hardware block that counts clock cycles or provides time-based interrupts. Software controls the timer by writing to its control registers. The control register typically contains bits to enable or disable the timer. Reading the control register back confirms that the write operation was successful. This read-back mechanism is a standard debugging technique in embedded systems. The testbench monitors these register accesses to verify correct behavior. The timer delay loop is a simple software construct that waits for a specific condition. In this lesson, the loop enables the timer and checks its status. The DUT wraps the RISC-V core and the peripheral subsystem. The testbench loads a program that performs these register operations. The simulation verifies that the timer is enabled and the GPIO reflects the expected state.
Practice
Open this chapter in RtlStudio and confirm the files appear in the Explore tree. Open student/tb/tb_top.sv in the editor. Locate the dut_i instance block. Replace the __TODO__[0] placeholder in the .gpio_in connection with gpio_in. Replace the __TODO__[0] placeholder in the .gpio_out connection with gpio_out. Replace the __TODO__[0] placeholder in the .gpio_oe connection with gpio_oe. Locate the $readmemh call in the initial block. Replace the __TODO__ placeholder with the string "tb/programs/02_03_timer_delay_loop.hex". Save the file. Run Simulation from the left sidebar. Read the Log panel to check for INFO: lines. Verify that the simulation ends with INFO: PASS.
Summary
You practiced instantiating the timer peripheral and connecting its GPIO ports within the SoC design. By providing the correct memory image, you enabled the CPU to execute a software-controlled timer delay loop. Reading back the control register confirmed that the timer was properly enabled and functioning as expected. This exercise demonstrated the essential interaction between the RISC-V core and peripheral IP blocks for timing operations.
© 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 Timer delay loop. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.