RTL Studio Open IDE

2.2 · SOC CLASS

Timer / tick generator

Build a timer peripheral with prescaler, counter, and compare match logic to generate periodic interrupt ticks.

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

What you practice

Timer / tick generator (2.2). Build a timer peripheral with prescaler, counter, and compare match logic to generate periodic interrupt ticks. It is in Timer Tick — Part 2 · Peripheral Islands of the SoC Masterclass. Build GPIO, timer, UART, and IRQ islands, then wrap them as a peripheral subsystem.

SoC lessons simulate the fabric and the peripheral together in the IDE. Verilator is the simulator; the waveform is where address and response show up.

What you will learn

You will implement a timer peripheral that generates periodic interrupt pulses. This module combines a prescaler, a counter, and a compare match logic to create a reliable tick signal.

Learning objectives

  • Implement a 16-bit prescaler to divide the clock frequency.
  • Build a 32-bit counter that increments based on the prescaled clock.
  • Create a compare match mechanism to generate a single-cycle tick pulse.
  • Verify the timer behavior using an AXI-Lite interface and a testbench.

Theory

A timer peripheral typically divides a fast system clock into a slower tick rate. The prescaler counts up to a specific value before allowing the main counter to increment. The main counter counts up to a compare value to trigger an event. When the counter reaches the compare value, it resets and asserts a tick signal. This tick signal can be used to trigger interrupts or update system time. The AXI-Lite interface allows software to configure the prescaler and compare values at runtime.

ComponentWidthFunction
Prescaler16-bitDivides the input clock frequency.
Counter32-bitCounts prescaler cycles to reach the compare value.
Compare32-bitThreshold value for the counter to trigger a tick.
Tick1-bitSingle-cycle pulse when counter matches compare value.

Practice

  1. Open RtlStudio and select the 2.2 Timer / tick generator chapter.
  2. In the Explore panel, open student/rtl/ip/soc/timer_csr.sv.
  3. Locate the always_ff block that handles the timer logic.
  4. Replace the __TODO__ placeholders with the correct initialization values for prescaler, compare, counter, presc_cnt, and tick.
  5. Ensure the logic inside the if (enable) block correctly implements the prescaler and counter behavior.
  6. Open student/tb/tb_top.sv to verify the testbench structure.
  7. Run Simulation from the sidebar and check the Log panel for results.

Summary

You implemented a timer peripheral featuring a prescaler, compare match logic, and an interrupt request pulse generator. This exercise demonstrated how to construct reusable peripheral blocks within a SystemVerilog design hierarchy. The successful simulation confirms that the generated tick signals and interrupts function as intended.

© 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 lesson workspace in the IDE. The fabric and the peripheral are one simulation.
  2. Run Verilator and follow the address, write data, and read response on the waveform.
  3. A passing log is not enough when decode or an IRQ line is the point of the lesson — those show up on the VCD.
  4. Run Yosys on the RTL island you just integrated when you want the mapped cells.

The lesson is done when the simulation matches Timer / tick generator. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.