Every lesson so far has been building toward one circuit. Lesson 1.2 showed why a single flop isn't enough. Lesson 2.1 showed what's actually happening inside a flop when it goes metastable. Lesson 2.2 gave you the formula for how often that failure happens. Now: the actual fix โ the circuit every real chip uses to cross a single-bit signal safely โ built, wired, placed, and simulated properly.
It's exactly what the name says: two flip-flops, both clocked by the receiving clock domain, chained back to back. The asynchronous signal feeds the first flop's input. The first flop's output feeds the second flop's input. The second flop's output is the only thing the rest of the receiving domain is ever allowed to look at.
sync_out, the value is clean.Both flops are clocked by the same clock โ the receiving domain's clock. Not one flop per domain. FF1 and FF2 both live inside domain B.
Say data_a flips at some random instant, completely unrelated to clk_b's edges:
"Almost always" is not "always." A two-flop synchronizer doesn't eliminate the possibility of failure โ it makes the MTBF astronomically large. If your design needs even more margin (very high clock frequencies, very high toggle rates, safety-critical systems), teams add a third flop for extra resolution time. That trades one more cycle of latency for another multiplicative jump in MTBF.
This circuit is not free, and it is not universal. Both limits matter as much as the fix itself:
clk_b edges to appear at sync_out, even in the best case. Any logic depending on this signal must budget for that delay.data_a toggles faster than clk_b can sample it, edges get silently swallowed. The synchronizer only guarantees the receiver eventually sees the correct level โ not every transition.On paper, "two flip-flops in a row" sounds trivial. In an actual chip, getting this wrong is one of the most common real CDC bugs โ because the RTL can look perfect while the implementation silently breaks the theory.
(* ASYNC_REG = "TRUE" *) (Xilinx) or dont_touch / preserve pragmas to say "leave this exactly as written."This is the gap between "I understand synchronizers" and "I can implement one that survives silicon." The circuit is two flip-flops. Making sure it stays two flip-flops, physically adjacent, with nothing sneaking in between, is the actual engineering work.
Watch it happen below โ an async signal crossing into a clean domain, live. ๐
Adjust the receiving clock's speed and how often the async signal toggles, then hit play. The red dot marks
an edge where the data changed dangerously close to clk_b's rising edge โ FF1's risk zone. Notice
FF2_Q is always a clean square wave, one cycle behind FF1_Q.
Try it yourself โ copy this into our Verilog simulator and check the waveform. ๐
module sync_2ff (
input wire clk_b,
input wire rst_b,
input wire data_a, // async input, driven by domain A
(* ASYNC_REG = "TRUE" *) output reg sync_out // clean output, safe to use in domain B
);
(* ASYNC_REG = "TRUE" *) reg ff1_q;
always @(posedge clk_b or negedge rst_b) begin
if (!rst_b) begin
ff1_q <= 1'b0;
sync_out <= 1'b0;
end else begin
ff1_q <= data_a; // stage 1: may go metastable
sync_out <= ff1_q; // stage 2: always samples a settled value
end
end
endmodule
`timescale 1ns/1ps
module tb_sync_2ff;
reg clk_b = 0;
reg rst_b = 0;
reg data_a = 0;
wire sync_out;
// clk_b: 100 MHz (10 ns period)
always #5 clk_b = ~clk_b;
sync_2ff dut (
.clk_b(clk_b),
.rst_b(rst_b),
.data_a(data_a),
.sync_out(sync_out)
);
initial begin
$dumpfile("sync_2ff.vcd");
$dumpvars(0, tb_sync_2ff);
rst_b = 0;
#12 rst_b = 1;
// data_a toggles at an offset unrelated to clk_b's edges,
// deliberately landing close to an edge at least once
#7 data_a = 1;
#23 data_a = 0;
#9 data_a = 1; // near-edge case
#31 data_a = 0;
#17 data_a = 1;
#80 $finish;
end
endmodule
ASYNC_REG/dont_touch attributes โ is where real designs actually go wrong.