CDC Course / Module 3: Synchronization Techniques
Lesson 3.1

The Two-Flop Synchronizer

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.

1

The complete circuit

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.

DOMAIN A (async) DOMAIN B (clk_b) data_a FF1 D Q (may go metastable) FF2 D Q (always clean) sync_out clk_b (same clock drives both) โ†‘ placed physically adjacent, zero logic in between
FF1 absorbs whatever metastability the crossing causes. FF2 only ever samples FF1 after it's had a full clock period to settle โ€” so by the time anything downstream reads sync_out, the value is clean.
Rule zero

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.

2

Walking through what actually happens

Say data_a flips at some random instant, completely unrelated to clk_b's edges:

  1. Common case (no timing violation): the change lands safely outside FF1's setup/hold window. FF1 samples it cleanly on the next edge, in one cycle. FF2 samples FF1 a cycle later. Two clean cycles, no drama.
  2. Rare case (violation on FF1): the change lands right in FF1's setup/hold window. FF1 goes metastable โ€” exactly the physics from Lesson 2.1. It has one entire clock period to resolve before FF2 samples it.
  3. Per Lesson 2.2's math, one clock period of resolution time is normally enough to push MTBF from "fails constantly" into "won't fail before the sun burns out." FF2 samples a resolved, clean value almost always.

"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.

3

What it costs you, and what it can't do

This circuit is not free, and it is not universal. Both limits matter as much as the fix itself:

โฑ๏ธ
Latency: 2 clock periods
The signal takes two clk_b edges to appear at sync_out, even in the best case. Any logic depending on this signal must budget for that delay.
๐Ÿšซ
Single bit only
Put a multi-bit bus through independent two-flop synchronizers and different bits can resolve on different cycles โ€” the receiver can briefly see a value that was never actually driven. That's a real bug class, and it's why buses need Gray coding or handshaking (coming up in Modules 3โ€“4).
๐Ÿ“ถ
Only works for level signals
If 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.
4

The physical rules real teams enforce

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.

  • No combinational logic between FF1 and FF2. Even one gate adds delay that eats into FF2's setup time, shrinking the resolution window you were counting on.
  • Place FF1 and FF2 physically close together. If place-and-route spreads them across the die, wire delay between them can approach a clock period โ€” again eating your resolution margin. Chip teams add explicit placement constraints for synchronizer pairs.
  • Mark them so synthesis and P&R leave them alone. Tools that don't understand CDC intent might "optimize" by merging, retiming, or resizing these flops โ€” silently destroying the synchronizer. RTL uses attributes like (* ASYNC_REG = "TRUE" *) (Xilinx) or dont_touch / preserve pragmas to say "leave this exactly as written."
  • Use the highest-metastability-immunity flop your library offers for FF1 specifically โ€” many standard-cell libraries include a dedicated synchronizer flop cell for exactly this reason.

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. ๐Ÿ‘‡

๐Ÿงช

Interactive Lab: Watch a Signal Cross Safely

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.

data_a FF1 FF2
data_a = 0 FF1_Q = 0 FF2_Q = 0
red dot = data changed inside FF1's risk window on that edge

Try it yourself โ€” copy this into our Verilog simulator and check the waveform. ๐Ÿ‘‡

sync_2ff.v
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
tb_sync_2ff.v
`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

๐ŸŽฏ What to remember

  • Two flip-flops, both clocked by the receiving domain's clock, chained Dโ†’Qโ†’Dโ†’Q. Nothing else touches the signal in between.
  • FF1 absorbs the metastability risk; FF2 only ever samples a value that's had a full clock period to settle.
  • Costs one extra clock period of latency, and only works for single-bit level signals โ€” buses and pulses need different techniques (coming up next).
  • The RTL is trivial. Keeping it safe through synthesis and place-and-route โ€” no logic between the flops, physically adjacent placement, ASYNC_REG/dont_touch attributes โ€” is where real designs actually go wrong.
Advertisement