Clock Generators
Lost-Clock Detector — L2 Upgrade
Dual-phase lost-clock detector with configurable threshold and count enable.
About this block
Simulate it in the Verilog IDE
Lost-Clock Detector — L2 Upgrade is a Verilog reference block in the Clock Generators catalog. Clock dividers, gating, and clock distribution helpers. Marked Medium: more state or a wider datapath, still one workspace in the IDE.
This IP implements a robust, dual-phase lost-clock detector for Verilog designs. It monitors a target clock (clk_mon) against a reference clock domain (clk_ref) and asserts an alarm signal when the monitored clock stops toggling.
The design ensures glitch-free edge detection through dual-phase synchronization and provides configurable latency thresholds. It is synthesis-ready, verified with Icarus Verilog, and includes features such as synchronous count enable and active-low reset for deterministic behavior.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Lost-Clock Detector — L2 Upgrade.
- Read the Verilog module in the editor. The catalog line for this block: Dual-phase lost-clock detector with configurable threshold and count enable.
- 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.
Features
- Dual-Phase Synchronization: Ensures glitch-free edge detection and prevents metastability issues when crossing from
clk_montoclk_ref. - Configurable Threshold: Supports various latency requirements via an 8-bit threshold counter (default 8-bit width, extensible).
- Count Enable (CE): Allows dynamic pausing of the monitoring process without resetting the state.
- Active-Low Reset: Ensures deterministic startup behavior by clearing the counter and alarm state immediately.
- Glitch-Free Output: Registered alarm output prevents metastability propagation to downstream logic.
Ports
| Port | Direction | Width | Description |
|---|---|---|---|
clk_ref | Input | 1 | Reference clock (always running, synchronous domain) |
clk_mon | Input | 1 | Monitored clock (may stop, glitch, or be asynchronous) |
rst_n | Input | 1 | Active-low reset (synchronous to clk_ref) |
thresh | Input | [7:0] | Threshold count (cycles of clk_ref) before alarm |
ce | Input | 1 | Count enable (synchronous to clk_ref; 1=enable, 0=freeze) |
alarm | Output | 1 | Asserted high when clk_mon is lost for > thresh cycles |
Verification
The provided testbench (tb_lost_clock_detector_dual_phase.v) validates five key scenarios:
- Normal Operation: Confirms no false alarms during active clock.
- Lost Clock Detection: Verifies alarm assertion after threshold cycles of inactivity.
- Reset Behavior: Ensures immediate clearing of alarm and counter on reset.
- Count Enable Freeze: Confirms detection pauses when
CE=0. - Custom Threshold: Validates configurable latency settings.
### Running Simulation
- Ensure Icarus Verilog is installed.
- Run the simulation script:
- Check the Log panel for the following expected results:
- TC1 PASS - Alarm low as expected - TC2 PASS - Alarm asserted after clock loss - TC3 PASS - Alarm cleared on reset - TC4 PASS - Alarm not asserted when CE=0 - TC5 PASS - Alarm asserted with custom threshold - INFO: PASS
More in Clock Generators
- 1-Cycle Data Delay
- 16-Bit DDS Phase Accumulator — L2 Upgrade
- 2:1 Clock Divider (Toggle Flip-Flop)
- 4-Phase Clock-Enable Sequencer — L1 Upgrade — L2 Upgrade
- Burst Enable for N Cycles — L1 Upgrade — L2 Upgrade
- CE Pulse Every N Cycles
- Clock Enable with Soft-Reset Stretch — L2 Upgrade
- Clock-Enable Divider (CE Pulse) — L1 Upgrade — L2 Upgrade
- Clock-Enable Stretcher N — L1 Upgrade — L2 Upgrade
- Divide-by-3 Clock (50% Duty)
- Dual-Edge DDR Sampler — L2 Upgrade
- Duty-Correct Divide-by-2 — L1 Upgrade — L2 Upgrade
- Fractional Clock Divider with Jitter Control
- Fractional Clock Enable M/N — L2 Upgrade
- Glitch-Free Clock Select 2 — L2 Upgrade
- Integer Clock Divider