Fast to Slow Domain Pulse Synchronizer
A one-cycle pulse from a fast clock domain can fall entirely between two edges of a slow clock. A two-flop synchronizer would never see it.
This module reliably transfers a single-cycle pulse from a fast clock domain to a slow clock domain. It operates by converting the incoming fast pulse into a level change by toggling a register. This level signal is wide enough to be safely captured by the slow clock. A standard two-stage synchronizer brings the level signal into the slow domain, and an edge detector recreates the single-cycle pulse in the destination domain.
- Both
clk_fastandclk_sloware positive-edge triggered. - Both
rst_fast_nandrst_slow_nare asynchronous, active-low resets. - When
rst_fast_nis asserted, all fast-domain logic resets to 0. - When
rst_slow_nis asserted, all slow-domain logic andpulse_outreset to 0. pulse_inis exactly oneclk_fastcycle wide.pulse_outmust be exactly oneclk_slowcycle wide for everypulse_inreceived.- The module must safely handle consecutive pulses, provided they are separated by enough time for the slow domain to process the first toggle.
{ "signal": [
{ "name": "clk_fast", "wave": "p..............." },
{ "name": "pulse_in", "wave": "010............." },
{ "name": "toggle_reg", "wave": "0.1............." },
{ "name": "clk_slow", "wave": "p...p...p...p..." },
{ "name": "sync1", "wave": "0...1..........." },
{ "name": "sync2", "wave": "0.......1......." },
{ "name": "sync3", "wave": "0...........1..." },
{ "name": "pulse_out", "wave": "0.......1...0..." }
], "head": { "text": "Transferring a fast pulse across domains using a toggle and detect strategy." } }
| Signal | Direction | Width | Description |
|---|---|---|---|
clk_fast |
input | 1 | Source clock domain; fast positive-edge triggered clock |
rst_fast_n |
input | 1 | Asynchronous active-low reset for the fast clock domain |
pulse_in |
input | 1 | Single-cycle pulse in the clk_fast domain |
clk_slow |
input | 1 | Destination clock domain; slow positive-edge triggered clock |
rst_slow_n |
input | 1 | Asynchronous active-low reset for the slow clock domain |
pulse_out |
output | 1 | Recreated single-cycle pulse in the clk_slow domain |
Constraints
- The fast domain logic must only be clocked by
clk_fastand reset byrst_fast_n. - The slow domain logic must only be clocked by
clk_slowand reset byrst_slow_n. - The design must use a 2-stage flip-flop synchronizer in the slow domain to capture the toggle signal to resolve metastability.
- The output
pulse_outmust be combinational, derived directly from the synchronized signals, so it asserts on the sameclk_slowcycle that the toggle edge is detected.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.
Part of Clock Domain Crossing and Synchronization
Problem 34 of 36 in the Clock Domain Crossing and Synchronization track.
Related problems
Browse all problems · Clock domain crossing (CDC) problems · Verilog practice problems · Learning tracks