Edge, Debounce & Pulse
Configurable Minimum Pulse Stretcher
Ensures output pulse width is at least min_width cycles using synchronous reset and single clock domain.
About this block
Simulate it in the Verilog IDE
Configurable Minimum Pulse Stretcher 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 core ensures that output pulses are at least a configurable minimum width (min_width) cycles.
It is designed for synchronous reset and single clock domain operation.
The module is ideal for debouncing applications or enforcing minimum signal width requirements in digital systems.
- Configurable Minimum Width: Set via an 8-bit input port.
- Synchronous Reset: Clean reset behavior on
rst_n. - Dynamic Reconfiguration:
min_widthcan be changed while the module is active. - Verified: Comprehensive testbench covering edge cases including short, long, exact, and dynamic width pulses.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Configurable Minimum Pulse Stretcher.
- Read the Verilog module in the editor. The catalog line for this block: Ensures output pulse width is at least min_width cycles using synchronous reset and single clock domain.
- Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
- 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.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input |
rst_n | Input | 1 | Active-low synchronous reset |
pulse_in | Input | 1 | Input pulse signal |
min_width | Input | 8 | Minimum output pulse width in cycles (0-255) |
pulse_out | Output | 1 | Stretched output pulse |
Architecture
The design uses a counter and a detection flag to manage pulse stretching logic.
### Logic Flow
- Idle State: Output is low. Counter is zero.
- Pulse Detected: When
pulse_ingoes high,pulse_detectedis set, and the counter starts incrementing. Output is driven high. - Pulse Ends: When
pulse_ingoes low, the module checks if the counter value is less thanmin_width.
- If cnt < min_width: The output remains high, and the counter continues to increment until cnt == min_width. - If cnt >= min_width: The output goes low immediately, and the state returns to idle.
Verification
The provided testbench (tb_pulse_stretcher_min_width.v) validates the following scenarios:
| Test Case | Description | Expected Result |
|---|---|---|
| TC1 | Short pulse (1 cycle) with min_width 4 | Output stretched to 4 cycles |
| TC2 | Long pulse (10 cycles) with min_width 4 | Output follows input |
| TC3 | Exact width pulse (4 cycles) with min_width 4 | Output matches input |
| TC4 | Dynamic min_width change | Output adapts to new width |
### Running Simulation
After running the simulation, the Log panel should display:
TC1 PASS - Short pulse stretched correctlyTC2 PASS - Long pulse followed correctlyTC3 PASS - Exact width pulse handled correctlyTC4 PASS - Dynamic min width handled correctlyINFO: PASS
More in Edge, Debounce & Pulse
- 2-Bit Edge Detector with Edge Type Selection — L1 Upgrade — L2 Upgrade
- 8-Bit Sticky OR Accumulator — L1 Upgrade — L2 Upgrade
- Both-Edge Detector — L1 Upgrade
- Double-Pulse Rejector
- Edge Count Window 8-bit — L1 Upgrade — L2 Upgrade
- Edge-Triggered Single-Cycle Pulse Generator — L1 Upgrade — L2 Upgrade
- Falling-Edge Hold for N Cycles — L1 Upgrade
- Level-Change Sticky Flag — L1 Upgrade — L2 Upgrade
- Level-to-Pulse Enable — L1 Upgrade — L2 Upgrade
- Min-Width Pulse Filter N
- Pulse Gap Detector 8-bit
- Pulse Width Monitor
- Quadrature Decoder x4 — L2 Upgrade
- Rising-Edge Event Counter 8-Bit — L1 Upgrade — L2 Upgrade
- Rising-Edge Hold for N Cycles — L1 Upgrade — L2 Upgrade
- Single-Cycle Pulse Generator with Enable Gating — L1 Upgrade — L2 Upgrade