Control & Timers
Pulse Width Window Checker 8-bit
Measures high-pulse width on din and validates it against min/max thresholds with sticky fail flag.
About this block
Simulate it in the Verilog IDE
Pulse Width Window Checker 8-bit 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 core validates that the duration of a digital pulse on the din signal falls within a user-defined range (min_pw to max_pw). It is designed for timing-critical control systems where pulse width integrity is essential.
Key Features:
- Window Validation: Checks if the pulse width (in clock cycles) is between
min_pwandmax_pw. - Sticky Failure Flag: The
failoutput latches high if any measurement falls outside the window, persisting until reset. - Immediate Status: The
okoutput reflects the validity of the most recent measurement. - Configurable Range: Supports 8-bit thresholds for flexible timing windows.
The module measures the number of clock cycles the din signal remains high. The measurement is triggered by the start signal. Once triggered, the module counts cycles while din is high. When din goes low, the counter value is compared against the configured thresholds.
- Measurement: Counts clock cycles during the high phase of
din. - Validation: Compares the count against
min_pwandmax_pw. - Status:
- Choose Open in IDE. RTL Studio loads the packaged workspace for Pulse Width Window Checker 8-bit.
- Read the Verilog module in the editor. The catalog line for this block: Measures high-pulse width on din and validates it against min/max thresholds with sticky fail flag.
- 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 | Direction | Width | Description |
|---|---|---|---|
| clk | input | 1 | System clock |
| rst_n | input | 1 | Active-low asynchronous reset |
| start | input | 1 | Trigger to begin measurement (pulse width >= 1 cycle) |
| din | input | 1 | Signal to measure pulse width |
| min_pw | input | 8 | Minimum acceptable pulse width (cycles) |
| max_pw | input | 8 | Maximum acceptable pulse width (cycles) |
| ok | output | 1 | High if last pulse was in window |
| fail | output | 1 | Sticky flag if any pulse was out of window |
Architecture
The module implements a synchronous Finite State Machine (FSM) with three primary states:
- Idle: Waiting for the
starttrigger. - Measuring: Counting cycles while
dinis high. - Evaluating: Comparing the counter value against thresholds upon the falling edge of
din.
### State Diagram
Verification
The provided testbench (tb_pulse_width_window_check_8.v) covers the following scenarios:
- Reset Behavior: Verifies all outputs are zeroed upon reset.
- In-Window Pulse: Validates a pulse width within the specified range.
- Out-of-Window (Short): Validates a pulse width shorter than
min_pw. - Out-of-Window (Long): Validates a pulse width longer than
max_pw. - Boundary Conditions: Tests exact equality with
min_pwandmax_pw.
All test cases are designed to pass, confirming the correctness of the window checking logic.
To run the simulation:
- Open your preferred HDL simulator.
- Load
tb_pulse_width_window_check_8.v. - Run the simulation and check the log for
INFO: PASS.
More in Control & Timers
- 1 MHz Tick Generator — L1 Upgrade — L2 Upgrade
- 16-Bit Down Timer (Match on Load-Zero Too) — L2 Upgrade
- 16-Bit Programmable Prescaler — L1 Upgrade — L2 Upgrade
- 16-bit Programmable Timer with Interrupt — L2 Upgrade
- 16-Bit Pulse Width Modulator (PWM) Controller
- 32-Bit Interval Timer with IRQ
- 32-Bit Kick Watchdog with Configurable Timeout and Reset Pulse
- 8-Bit Down Timer (Pulse Match on Zero) — L2 Upgrade
- 8-Bit Programmable Digital Deglitch Filter — L1 Upgrade — L2 Upgrade
- 8-Bit Window Comparator — L1 Upgrade — L2 Upgrade
- 8-Channel 16-Bit PWM Controller
- Activity Timeout Flag 8-bit — L2 Upgrade
- Bang-Bang Thermostat 8-bit
- Complementary PWM Dead-Time Inserter — L2 Upgrade
- Duty-Cycle Measurement 8-Bit — L2 Upgrade
- Edge Rate Limiter 8-bit — L2 Upgrade