RTL Studio Open IDE

Edge, Debounce & Pulse

2-Bit Edge Detector with Edge Type Selection — L1 Upgrade — L2 Upgrade

A 2-bit edge detector with configurable rising/falling edge selection, programmable window timer, hold mode, and sticky flag for event latching.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

2-Bit Edge Detector with Edge Type Selection — 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 a robust 2-bit edge detector with configurable edge type selection, window gating, hold mode, and a sticky status flag. It is designed for low-latency edge detection in synchronous systems, particularly suitable for L1/L2 upgrade scenarios where precise pulse timing and event logging are critical.

This IP provides a flexible and reliable 2-bit edge detection solution capable of detecting rising or falling edges on a 2-bit data bus. Key capabilities include:

  • Configurable Edge Detection: Supports both rising and falling edge detection via the type_sel control signal.
  • Window Gating: A programmable window timer allows pulses to be gated within a specific time window, enhancing noise immunity.
  • Hold Mode: Ensures reliable pulse capture by extending the output pulse to the next clock cycle upon detection.
  • Sticky Flag: Latches edge events for later processing, with an explicit clear mechanism (sticky_clr).
  • Synchronous Reset: Asynchronous active-low reset for quick initialization.
  1. Choose Open in IDE. RTL Studio loads the packaged workspace for 2-Bit Edge Detector with Edge Type Selection — L1 Upgrade — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: A 2-bit edge detector with configurable rising/falling edge selection, programmable window timer, hold mode, and sticky flag for event latching.
  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

  • Detects rising or falling edges on a 2-bit data input.
  • Configurable edge type via the type_sel control signal (0: Falling, 1: Rising).
  • Programmable window timer limits the duration of the output pulse.
  • Hold mode extends the pulse to the next clock cycle upon detection.
  • Sticky flag remains set until explicitly cleared by sticky_clr.
  • Asynchronous active-low reset initializes all internal states.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low reset
data_inInput2Input data bus
enInput1Enable signal for detection
type_selInput10 for falling, 1 for rising edge
hold_modeInput11 to hold pulse for one cycle
window_enInput1Enable window timer
window_cntInput4Window timer count value
sticky_clrInput1Clear sticky flag
edge_pulseOutput1Detected edge pulse
sticky_flagOutput1Latched edge event flag

Architecture

The module uses a delay register to store the previous state of data_in. Edge detection logic compares current and delayed data bits. The type_sel signal selects between rising and falling edge conditions.

A window timer counts cycles when window_en is asserted. The timer resets when it reaches window_cnt or when window_en is deasserted. The edge_pulse output is gated by the window_active status.

Hold mode overrides the window logic to pulse for one cycle. The sticky_flag is set on any enabled edge detection event and remains set until cleared.

Verification

The testbench performs self-checking verification of all modes. It tests:

  • Rising edge detection with window active.
  • Falling edge detection with window active.
  • Pulse suppression when the window is inactive.
  • Setting and clearing of the sticky flag.
  • Hold mode pulse generation and clearance.
  • Enable gating suppression.
  • Asynchronous reset behavior.

All test cases passed successfully.

More in Edge, Debounce & Pulse

All Edge, Debounce & Pulse blocks