RTL Studio Open IDE

Control & Timers

16-bit Programmable Timer with Interrupt — L2 Upgrade

A 16-bit down-counter timer with interrupt generation and immediate invalidation support.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

16-bit Programmable Timer with Interrupt — L2 Upgrade is a Verilog reference block in the Control & Timers catalog. FSMs, timers, watchdogs, and control/state sequencing blocks. Marked Medium: more state or a wider datapath, still one workspace in the IDE.

This IP implements a 16-bit down-counter timer with interrupt generation, designed for L2 upgrade scenarios requiring precise timing.

It supports loading a preset value, counting down to zero, and asserting an interrupt request when the count reaches one.

The timer includes an invalidate signal to clear state immediately, ensuring robust control in dynamic systems.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for 16-bit Programmable Timer with Interrupt — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: A 16-bit down-counter timer with interrupt generation and immediate invalidation support.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.

RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.

Features

  • 16-bit programmable countdown capability.
  • Asynchronous active-low reset for safe initialization.
  • Load enable input to update the counter preset value.
  • Interrupt request output asserted at count value one.
  • Timer done output synchronized with the interrupt signal.
  • Invalidate input to clear counter and interrupt flags instantly.
  • Synchronous logic for predictable timing behavior.
  • Verified with Icarus Verilog simulation engine.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input for synchronous logic.
rst_nInput1Active-low asynchronous reset.
load_enInput1Load enable to update counter with load_val.
load_valInput16Preset value for the timer counter.
invalidateInput1Active-high signal to clear counter and interrupts.
timer_doneOutput1High when the timer has reached zero.
interrupt_reqOutput1High when the counter reaches one.

Verification

The testbench verifies five key scenarios for correctness:

  1. TC1: Basic countdown and interrupt assertion. The counter loads five and counts down to zero correctly.
  2. TC2: Reloading the counter and counting again. The counter loads three and generates an interrupt upon completion.
  3. TC3: Invalidating pending interrupts. The interrupt and timer done signals are reset immediately.
  4. TC4: Interrupt generation after a second reload. The counter loads two and asserts the interrupt request.
  5. TC5: Invalidating before the count completes. The pending interrupt is cleared by the invalidate signal.

All test cases passed with zero errors in simulation.

More in Control & Timers

All Control & Timers blocks