RTL Studio Open IDE

Edge, Debounce & Pulse

Rising-Edge Event Counter 8-Bit — L1 Upgrade — L2 Upgrade

8-bit rising-edge event counter with load, clear, windowing, and sticky flag support.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

Rising-Edge Event Counter 8-Bit — L1 Upgrade — L2 Upgrade is a Verilog reference block in the Edge, Debounce & Pulse catalog. Edge detectors, debouncers, pulse stretchers, and one-shot generators. Marked Medium: more state or a wider datapath, still one workspace in the IDE.

This IP implements an 8-bit rising-edge event counter designed for Level 1 (L1) and Level 2 (L2) upgrade scenarios in high-speed data acquisition systems. It provides precise event tracking with programmable windowing limits, synchronous load/clear capabilities, and a sticky flag for event detection.

The module is fully verified, synthesizable, and ready for integration into larger FPGA designs.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Rising-Edge Event Counter 8-Bit — L1 Upgrade — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: 8-bit rising-edge event counter with load, clear, windowing, and sticky flag 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

  • 8-bit Counter Width: Accumulates events from 0 to 255.
  • Rising-Edge Detection: Accurately counts pulses on the pulse_in signal by detecting transitions from 0 to 1.
  • Synchronous Load: Preloads the counter with data_in when load is asserted.
  • Synchronous Clear: Resets the counter and sticky flag to zero when clear is asserted.
  • Enable Control: Gates counting operations via the en signal.
  • Windowing Logic: Prevents counting beyond a specified threshold (window_val) when window_en is active. The counter holds its value if the limit is reached.
  • Sticky Flag: Sets to 1 upon the first valid count event and remains high until explicitly cleared by the clear signal.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low asynchronous reset
enInput1Count enable signal
loadInput1Load data input signal
clearInput1Clear counter and sticky flag
data_inInput8Data input for load operation
window_enInput1Window enable signal
window_valInput8Window threshold value
pulse_inInput1Pulse input for counting
count_outOutput8Current counter value
sticky_flagOutput1Sticky flag indicating first count

Architecture

The module utilizes sequential logic for state storage and combinational logic for next-state calculation.

  1. Rising-Edge Detection: Performed by comparing the current pulse_in with the previous cycle's value (prev_pulse).
  2. Priority Logic: The counter updates based on the priority of signals: load > clear > enable.
  3. Windowing: If window_en is active, the counter increments only if count_out < window_val. Otherwise, it holds the current value.
  4. Sticky Flag: Set to one upon the first successful count event and remains high until clear is asserted.

Verification

The testbench verifies reset, basic counting, load, clear, windowing, and sticky flag behavior. All test cases passed successfully in the simulation environment.

Test CaseDescriptionResult
TC1Reset functionalityPASS
TC2Basic counting up to 10PASS
TC3Load value 42PASS
TC4Clear counter and sticky flagPASS
TC5Windowing limit at 5PASS
TC6Sticky flag sensitivityPASS

More in Edge, Debounce & Pulse

All Edge, Debounce & Pulse blocks