RTL Studio Open IDE

Edge, Debounce & Pulse

Level-Change Sticky Flag — L1 Upgrade — L2 Upgrade

Module that detects level changes on a single bit, sets a persistent sticky flag, and activates a programmable window timer on each change.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

Level-Change Sticky Flag — 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 level-change sticky flag with a programmable clear window. It detects rising or falling edges on a single-bit input signal. The sticky flag remains set until explicitly cleared by the clear_sticky signal. A programmable window timer activates on each detected change. The window duration is defined by the window_width input. The window timer is controlled by the window_en enable signal.

This IP provides a robust mechanism for tracking level changes with a configurable observation window. It is suitable for event logging, glitch filtering, or state synchronization interfaces. The design is fully synchronous except for the asynchronous clear and reset. Simulation results confirm correct behavior across all specified scenarios.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Level-Change Sticky Flag — L1 Upgrade — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: Module that detects level changes on a single bit, sets a persistent sticky flag, and activates a programmable window timer on each change.
  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.

Architecture

The module uses a latch-free design for level change detection. It compares the current input level with the previous clock cycle value. A dedicated register holds the sticky state until reset or clear. The window timer counts down from the configured width. The timer resets automatically when clear_sticky is asserted. The window_active output indicates when the timer is running.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low asynchronous reset
level_inInput1Signal to monitor for level changes
clear_stickyInput1Asynchronous clear for sticky flag and window
window_widthInput8Number of cycles for the active window
window_enInput1Enable signal for the window timer
sticky_flagOutput1Persistent flag set on level change
window_activeOutput1High while window timer is counting

Verification

The testbench validates reset behavior, edge detection, and window timing. All seven test cases pass successfully in the Icarus Verilog simulation.

  • Reset initializes both outputs to zero.
  • Level changes set the sticky flag immediately.
  • The window timer activates for the specified number of cycles.
  • The sticky flag persists after the window expires.
  • Clearing the sticky flag resets both the flag and the window.
  • Disabling window_en prevents the timer from starting.
  • Falling edges are detected with the same logic as rising edges.
  • Changing window_width correctly adjusts the timer duration.
Test CaseDescriptionResult
TC1Reset state checkPASS
TC2Rising edge detectionPASS
TC3Window active and expiryPASS
TC4Clear sticky flagPASS
TC5Window disabledPASS
TC6Falling edge detectionPASS
TC7Window width parameterizationPASS

More in Edge, Debounce & Pulse

All Edge, Debounce & Pulse blocks