What you practice
Watchdog tie-in (3.5). Implement watchdog kick CSR and timeout IRQ logic in the SOC IP module. It is in Watchdog Tie-In — Part 3 · System Control of the SoC Masterclass. Sequence reset, clock enables, boot vector, and watchdog into a sysctrl block.
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 watchdog timer control register and its associated timeout interrupt logic. This ensures the system can detect and recover from software hangs or lockups.
Learning objectives
- Define the register address map for the watchdog kick and control registers.
- Implement a down-counter that triggers an interrupt when it reaches zero.
- Connect the kick register write to reset the counter value.
- Verify the timeout behavior using the testbench stimulus.
Theory
A watchdog timer is a hardware counter that must be periodically reset by software. If the software fails to reset the counter before it underflows, the watchdog asserts an interrupt. This mechanism allows the system to detect when the main control loop has stalled. The watchdog_csr module implements this logic using an AXI-Lite interface.
| Register | Address | Access | Description |
|---|---|---|---|
| KICK | 0x00 | Write | Resets the counter to the timeout value. |
| CTRL | 0x04 | Read/Write | Bit 0 enables or disables the counter. |
The counter decrements on every clock cycle when enabled. When the counter reaches zero, the timeout_irq signal is asserted. Writing to the KICK register reloads the counter with the initial TIMEOUT_CYCLES value. This allows software to keep the watchdog alive during normal operation.
Practice
- Open RtlStudio and select this chapter from the Examples or Lecture list.
- Confirm that
student/rtl/ip/soc/watchdog_csr.svandstudent/tb/tb_top.svappear in the Explore tree. - Open
student/rtl/ip/soc/watchdog_csr.svin the editor. - Implement the
REG_KICKlocalparam to match the address map (0x00). - Implement the reset logic for
counterandtimeout_irqin the firstalways_ffblock. - Implement the
timeout_irqassignment and counter reload logic when the counter underflows. - Implement the write handling for
REG_KICKto reload the counter. - Open Simulation in the sidebar and click Run.
Summary
You implemented the watchdog kick Control and Status Register to allow software interaction with the hardware timer. You also connected the watchdog timeout interrupt signal to the system interrupt controller. This exercise demonstrated how to integrate peripheral control logic with system-level interrupt handling. The successful simulation confirms that the timeout mechanism correctly triggers the expected interrupt response.
© 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 lesson workspace in the IDE. The fabric and the peripheral are one simulation.
- Run Verilator and follow the address, write data, and read response on the waveform.
- A passing log is not enough when decode or an IRQ line is the point of the lesson — those show up on the VCD.
- Run Yosys on the RTL island you just integrated when you want the mapped cells.
The lesson is done when the simulation matches Watchdog tie-in. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.