Clock Domain Crossing and Metastability: When Is a Two-Flop Synchronizer Enough?

When a signal from one clock domain is sampled by a flip-flop on an unrelated clock, it will sometimes change inside that flop's setup and hold window, and the flop can go metastable: its output sits between 0 and 1 for an unpredictable time before settling. A two-flop synchronizer handles this by giving the first flop a whole clock cycle to settle before the second flop samples it, which makes failures vanishingly rare for a single-bit level that changes slowly. It is not enough for short pulses from a faster clock, for multi-bit values, or for one signal synchronized in two places; those need a toggle or handshake synchronizer, Gray code or an asynchronous FIFO.

What you'll learn

  • What metastability is and why no flip-flop can avoid it
  • The two-flop synchronizer in Verilog, its latency, and why there must be no logic between the flops
  • A worked MTBF calculation that shows why the second flop matters so much
  • Four cases where two flops are not enough, with a simulated toggle synchronizer for short pulses
  • What to tell the synthesis and timing tools about a synchronizer

Conventions and assumptions

Two clocks with no fixed phase relationship, clk_a (source) and clk_b (destination). Verilog-2001 syntax, valid in SystemVerilog, simulated in Icarus Verilog 12 and linted with Verilator 5.036 with -Wall (no warnings for either design module). A digital simulator cannot show metastability: its flip-flops always resolve cleanly, so the simulation below checks latency and pulse capture, and the metastability figure is an illustration.

What is metastability?

A flip-flop's datasheet setup and hold times describe a window around the clock edge where the input must not change. If it does change inside that window, the flop's internal latch is left close to its balance point, and it takes extra time to fall to 0 or to 1. That extra time has no fixed upper bound; the probability that the flop is still unresolved falls exponentially with the time you wait. Between two unrelated clocks, the data will eventually change inside the window, so the question is never whether a flop goes metastable but how often it is still unresolved when something reads it.

The first synchronizer flop going metastable and the second flop changing cleanly one cycle later
d_async changes just before edge 1. The first flop, meta, is left between 0 and 1 and settles some time later; the second flop, sync, samples it at edge 2, a full clk_b cycle after the first, by which time it has almost certainly settled.

The two-flop synchronizer

The fix is to wait. The first flop samples the asynchronous signal and may go metastable; the second flop samples the first one clock later, so the first gets almost a whole clock period to settle. Only the second flop's output is used by the rest of the design.

Two-flop synchronizer: a clk_a flip-flop feeding two flip-flops in series clocked by clk_b
The signal leaves a clk_a flip-flop and passes through two clk_b flip-flops in a row. Only sync is used in the clk_b domain.
sync2: a two-flop synchronizer for a single-bit level
module sync2 (input wire clk_dst, input wire rst_dst, input wire d_async, output wire q_sync);
  reg meta, sync;                    // meta may go metastable in hardware; sync gets a full cycle to settle
  always @(posedge clk_dst) begin
    if (rst_dst) begin
      meta <= 1'b0;
      sync <= 1'b0;
    end else begin
      meta <= d_async;
      sync <= meta;
    end
  end
  assign q_sync = sync;
endmodule
  • Drive the input straight from a flip-flop in the source domain. A combinational output can glitch, and the synchronizer may catch the glitch as a real pulse.
  • Put no logic between meta and sync. Every gate between them eats into the settling time.
  • Expect one to two destination cycles of latency. In simulation a level that changed at 301 ns, just after the clk_b edge at 300 ns, reached meta at the 324 ns edge and sync at 348 ns: 47 ns, just under two 24 ns cycles.

Worked example: why the second flop matters

A widely used model for one synchronizer stage gives the mean time between failures as MTBF = e^(tr/τ) ÷ (T0 · fclk · fdata), where tr is the time the flop has to resolve before its output is used, τ and T0 are constants of the flip-flop, fclk is the sampling clock and fdata the rate at which the input changes. FPGA vendors characterize τ and T0 for their devices, and their timing tools report MTBF from them. To see the shape of the numbers, take round illustrative values, not from any datasheet: τ = 100 ps, T0 = 1 ns, fclk = 200 MHz and fdata = 20 MHz, so T0 · fclk · fdata = 4 × 10⁶ per second.

  • One flop, its output used by logic that leaves 0.5 ns of slack: tr = 0.5 ns, e^(0.5/0.1) = e^5 = 148.4, so MTBF = 148.4 ÷ (4 × 10⁶) = 37.1 µs. The design fails tens of thousands of times a second.
  • Two flops: the second flop gets a whole 5 ns period minus the first flop's clock-to-Q (0.3 ns) and the second flop's setup time (0.2 ns), so tr = 4.5 ns. e^45 = 3.49 × 10¹⁹, and MTBF = 8.73 × 10¹² s, about 277,000 years.
  • The exponent is what matters: each extra nanosecond of resolution time multiplies the MTBF by e^10, about 22,000, with these constants. That is why a third flop is added for very fast clocks, and why logic between the flops is so costly.

When is a two-flop synchronizer not enough?

A synchronizer only promises that its output is a clean 0 or 1 at some clock edge near the change. It does not promise which edge, and it can miss a change entirely if the input goes back before it is sampled. Four cases break it.

1. Short pulses from a faster clock

A pulse that is shorter than one destination clock period can fall between two destination edges and never be sampled. The testbench below sends five one-cycle pulses, 10 ns wide, from a 100 MHz clk_a into a clk_b with a 24 ns period, at five different phases. A two-flop synchronizer on the pulse saw 2 of the 5. The fix is a toggle synchronizer: the source flips a level on every pulse, the level crosses through sync2, and an XOR of the synchronized level with its delayed copy rebuilds a one-cycle pulse in clk_b. It caught all 5.

pulse_sync: a toggle synchronizer for single-cycle pulses
module pulse_sync (
  input  wire clk_src, input wire rst_src, input wire pulse_src,
  input  wire clk_dst, input wire rst_dst, output wire pulse_dst
);
  reg toggle_src;
  always @(posedge clk_src) begin
    if (rst_src)        toggle_src <= 1'b0;
    else if (pulse_src) toggle_src <= ~toggle_src;
  end

  wire toggle_dst;
  sync2 s (.clk_dst(clk_dst), .rst_dst(rst_dst), .d_async(toggle_src), .q_sync(toggle_dst));

  reg toggle_dst_d;
  always @(posedge clk_dst) begin
    if (rst_dst) toggle_dst_d <= 1'b0;
    else         toggle_dst_d <= toggle_dst;
  end
  assign pulse_dst = toggle_dst ^ toggle_dst_d;
endmodule
A 10 ns pulse missed between two clk_b edges, and a toggle synchronizer turning it into a clk_b pulse
The second of the five pulses, from the simulation. It is high from 186 to 196 ns, between the clk_b edges at 180 and 204 ns, so the plain synchronizer misses it. The toggle level changes at 195 ns, reaches meta at 204 ns and sync at 228 ns, and pulse_b is high for one clk_b cycle from 228 to 252 ns.

The toggle synchronizer has its own limit: the source must not send a second pulse before the first has crossed, or two toggles cancel out. Here the pulses are 130 ns apart, more than five clk_b cycles. When pulses can come faster, use a request and acknowledge handshake, or an asynchronous FIFO.

2. Multi-bit values

Synchronizing each bit of a bus with its own two flops does not work. If a 4-bit counter goes from 0111 to 1000, all four bits change, each synchronizer resolves independently, and for one cycle the destination can see any mix, such as 1111 or 0000. Either make sure only one bit changes at a time (Gray code, which is how an asynchronous FIFO passes its read and write pointers), or hold the bus stable and send a single synchronized valid or request signal to say when to sample it.

3. One signal synchronized in two places

If the same asynchronous signal goes through two separate synchronizers, they can resolve on different edges, and for a cycle two parts of the destination logic disagree about its value. Synchronize once and fan out from the synchronized output.

4. Very fast clocks or long chains of risk

At high clock rates the settling time in one period may not give an acceptable MTBF, especially with many synchronizers in a design, since the failure rates add up. Add a third flop, and use the vendor's MTBF report to check.

Tell the tools what it is

  • Timing: the path from clk_a into the first flop is asynchronous, so timing it against clk_b is meaningless. Declare the clocks asynchronous or put a maximum delay (data path only) on the crossing, as the vendor's constraints guide describes.
  • Placement: on AMD devices, set the ASYNC_REG property on the synchronizer flops so synthesis keeps them, the placer puts them next to each other, and the MTBF report knows about them. Intel's Quartus Timing Analyzer identifies synchronization register chains and reports their MTBF in the same spirit.
  • Checking: run the tool's clock domain crossing report (report_cdc in Vivado) to find crossings with no synchronizer, multi-bit buses synchronized bit by bit, and logic in front of a synchronizer.

Common mistakes

  • Synchronizing a bus bit by bit and trusting the result for the one cycle when several bits change together.
  • Feeding a synchronizer from combinational logic in the source domain, so a glitch crosses as if it were a real change.
  • Sending single-cycle pulses from a fast clock to a slow one through two flops and losing some of them, which no functional simulation at a single phase will show.

Interview questions

  • Q1. Why can't you remove metastability by choosing a faster flip-flop? Answer: any bistable element has a balance point, so an input that changes inside its window can always leave it unresolved. A faster flop has a smaller τ and settles faster on average, which raises the MTBF, but the probability of a long settling time is never zero. Synchronizers manage the probability; they do not remove it.
  • Q2. How would you pass an 8-bit counter value from a 50 MHz domain to a 30 MHz domain? Answer: if the value only ever counts up or down by one, convert it to Gray code, synchronize each bit and convert back, since only one bit changes per step. If it can jump, hold the value in a source register, send a request through a synchronizer, sample the stable value in the destination and send an acknowledge back; or use an asynchronous FIFO.
  • Q3. A design passes every simulation, but a two-flop synchronizer occasionally misses an event in the lab. What is the likely cause? Answer: the event is a pulse shorter than a destination clock period, or two events closer together than the synchronizer can handle. Simulation runs at one fixed phase between the clocks, so it can catch every pulse by luck. Widen the pulse, use a toggle or handshake synchronizer, and test at several clock phases.

Related

Sources

Last verified

sync2 and pulse_sync were simulated in Icarus Verilog 12 and linted with Verilator 5.036 on 25 November 2026; the latency (301 to 348 ns) and the pulse counts (2 of 5 and 5 of 5) are copied from that run, and lib/digitalDesign.test.js reruns it when Icarus Verilog is installed. The MTBF figures were computed in code from the stated illustrative constants.

Keep going

Practice this