One more shape of signal doesn't survive the two-flop synchronizer untouched: a single-cycle pulse. It's not about metastability this time โ it's simpler and sneakier than that. A pulse can be completely, cleanly, silently missed, with no violation, no X, no warning. Here's why, and the neat trick that fixes it.
A two-flop synchronizer only ever reports whatever data_a happens to be at the instant
of a clk_b rising edge. That's fine for a level that stays put. But a pulse, by definition, comes
and goes โ and if it comes and goes entirely between two clk_b edges, no edge ever sees it. FF1's
D input was 1 for a while and 0 again, and FF1 never sampled anything but 0.
clk_b period and its timing is unrelated to clk_b, which is exactly the situation CDC exists to handle.Making the pulse wider doesn't fully solve it either. Even a pulse as wide as one full clk_b period can still land with unlucky phase and get missed by one sample, and if clk_b is much slower than clk_a โ or their ratio isn't known at design time โ there's no width you can pick that's always safe. You need a technique that works regardless of the frequency relationship.
A level can't be squeezed out of existence โ it just sits there until something changes it, and the two-flop synchronizer is built exactly for levels. So: don't synchronize the pulse. Toggle a flip-flop in domain A every time the pulse fires, synchronize that (a level, immune to width), and then rebuild a clean one-cycle pulse on the other side.
Flicking a light switch is a brief action, easy to miss if you glance away at the wrong moment. But whether the light is currently ON or OFF is a state you can check any time and always get the right answer. Toggling turns a "did something just happen?" question (easy to miss) into an "is it currently different than before?" question (impossible to miss).
One straight chain, three stages, nothing crossing back on itself:
clk_b-wide pulse comes out.toggle_a changes level and, critically, stays at the new level indefinitely, however narrow the original pulse was.clk_b cycle. For exactly one cycle after the toggle changes, the two disagree โ and that disagreement is pulse_out: a clean, single-clk_b-cycle pulse.The only thing that has to survive is a level change reaching the toggle flop โ and levels don't have a "width" to be too narrow. It doesn't matter if clk_b is faster, slower, or completely unrelated to clk_a.
Immunity to width is not immunity to rate. If a second source pulse fires before the first toggle has finished making its way through SYNC_2FF and the edge detector, the two toggles can blur together โ the receiver sees one level change instead of two, and a pulse is lost anyway, this time for a completely different reason: it never even reached the point of being "too narrow."
Rule of thumb: keep source pulses spaced at least 3 receiving-clock periods apart. That gives the two-flop synchronizer its full settling time and the edge detector a clean, separate cycle to register each toggle. If your source needs to fire faster than that, a pulse synchronizer is the wrong tool โ reach for the handshake synchronizer (Lesson 3.2) or a FIFO (Module 4) instead, both of which have built-in back-pressure.
Race the two methods head-to-head โ same pulse train, same clock, two different synchronizers. ๐
The same pulse_a train feeds two synchronizers at once: the toggle-and-detect circuit from this
lesson, and a naive direct two-flop synchronizer applied straight to the pulse. Drag the sliders and watch
which one actually gets every pulse through.
Try it yourself โ copy this into our Verilog simulator and check the waveform. ๐
module pulse_sync (
input wire clk_a,
input wire rst_a_n,
input wire pulse_a, // single-cycle pulse, domain A
input wire clk_b,
input wire rst_b_n,
output wire pulse_b // single-cycle pulse, domain B
);
// ---- Domain A: pulse -> toggle ----
reg toggle_a;
always @(posedge clk_a or negedge rst_a_n) begin
if (!rst_a_n) toggle_a <= 1'b0;
else if (pulse_a) toggle_a <= ~toggle_a;
end
// ---- Domain B: 2-flop synchronizer for the toggle ----
(* ASYNC_REG = "TRUE" *) reg sync_stage1;
(* ASYNC_REG = "TRUE" *) reg toggle_sync_b;
always @(posedge clk_b or negedge rst_b_n) begin
if (!rst_b_n) begin
sync_stage1 <= 1'b0;
toggle_sync_b <= 1'b0;
end else begin
sync_stage1 <= toggle_a;
toggle_sync_b <= sync_stage1;
end
end
// ---- Domain B: edge detector (delay + XOR) ----
reg toggle_sync_b_d1;
always @(posedge clk_b or negedge rst_b_n) begin
if (!rst_b_n) toggle_sync_b_d1 <= 1'b0;
else toggle_sync_b_d1 <= toggle_sync_b;
end
assign pulse_b = toggle_sync_b ^ toggle_sync_b_d1;
endmodule
`timescale 1ns/1ps
module tb_pulse_sync;
reg clk_a = 0, clk_b = 0;
reg rst_a_n = 0, rst_b_n = 0;
reg pulse_a = 0;
wire pulse_b;
// Two unrelated clocks
always #5 clk_a = ~clk_a; // 100 MHz
always #3.5 clk_b = ~clk_b; // ~143 MHz
pulse_sync dut (
.clk_a(clk_a), .rst_a_n(rst_a_n), .pulse_a(pulse_a),
.clk_b(clk_b), .rst_b_n(rst_b_n), .pulse_b(pulse_b)
);
initial begin
$dumpfile("pulse_sync.vcd");
$dumpvars(0, tb_pulse_sync);
#20 rst_a_n = 1; rst_b_n = 1;
// Fire a single-cycle pulse a few times, spaced safely apart
repeat (4) begin
#23 pulse_a = 1;
#5 pulse_a = 0; // exactly 1 clk_a cycle wide
end
#60 $finish;
end
endmodule