RTL Studio Open IDE

Control & Timers

8-Bit Down Timer (Pulse Match on Zero) — L2 Upgrade

An 8-bit down counter with synchronous load, match-zero pulse detection, and a sticky interrupt request flag.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

8-Bit Down Timer (Pulse Match on Zero) — 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 an 8-bit down counter with synchronous load capability.

It generates a pulse signal (match_zero) when the counter matches zero and asserts a sticky interrupt request (irq_sticky) flag.

The sticky flag can be cleared via an asynchronous reset or a dedicated clear signal.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for 8-Bit Down Timer (Pulse Match on Zero) — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: An 8-bit down counter with synchronous load, match-zero pulse detection, and a sticky interrupt request flag.
  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

  • 8-bit Down Counting: Counts down from a loaded value to zero.
  • Synchronous Load: Supports loading an initial value via load_en.
  • Match-Zero Detection: Asserts match_zero pulse when the counter reaches zero.
  • Sticky IRQ: Captures interrupt events with a sticky flag (irq_sticky) to ensure no events are missed.
  • Asynchronous Reset: Active-low reset (rst_n) for system initialization.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input for synchronous logic.
rst_nInput1Active-low asynchronous reset.
load_valInput8Data value to load into the counter.
load_enInput1Enable signal to load load_val into the counter.
irq_clearInput1Active-high signal to clear the sticky IRQ flag.
match_zeroOutput1High when the counter value is zero.
irq_stickyOutput1Sticky flag set on match_zero, cleared by irq_clear.

Integration

### Instantiation

To integrate this module into your design, use the following Verilog instantiation template:

### Operation Sequence

  1. Initialization: Assert rst_n low to reset the counter to 0. match_zero will be high during reset.
  2. Loading Value: Deassert rst_n. Assert load_en high with load_val set to the desired initial count.
  3. Counting: The counter will decrement on each clock cycle.
  4. Interrupt Handling: When the counter reaches 0, match_zero goes high and irq_sticky is set. Clear irq_sticky by asserting irq_clear high.

Verification

The testbench validates the following scenarios:

Test CaseDescriptionResult
TC1Verify match_zero is high after reset.PASS
TC2Verify match_zero is low after loading non-zero value.PASS
TC3Verify match_zero goes high after counting down to zero.PASS
TC4Verify irq_sticky is set after match event.PASS
TC5Verify irq_sticky is cleared by irq_clear signal.PASS
TC6Verify match_zero is high when loading zero value.PASS
TC7Verify irq_sticky is re-set after loading zero and matching.PASS

All 7 test cases passed successfully.

More in Control & Timers

All Control & Timers blocks