The Two-Flop Synchronizer
The standard fix for a single-bit crossing
The two-flop synchronizer is the workhorse of CDC. It is the correct, standard way to bring a single-bit signal safely into a new clock domain.
How it works
Place two flip-flops in series, both clocked by the destination clock. The first flop samples the asynchronous input and may go metastable. By the time the next destination edge arrives, that first flop has almost certainly settled, so the second flop captures a clean, stable value to hand to the rest of the logic.
// Two-flop synchronizer for a single-bit signal
module sync2 (
input wire clk_dst, // destination clock
input wire async_in, // signal from another domain
output reg sync_out
);
reg meta;
always @(posedge clk_dst) begin
meta <= async_in; // may go metastable
sync_out <= meta; // settled, safe to use
end
endmoduleThe rules that make it valid
- Both flops use the destination clock, and only the destination clock.
- Put no combinational logic between the two flops - the first flop needs the full cycle to settle.
- Use it only for a single bit, or for signals where each bit is independent.
What it costs and what it needs
- Latency: the signal appears one to two destination cycles later.
- The input must stay stable long enough to be caught, so it suits slow-changing levels and control signals.
A two-flop synchronizer does not work for a short pulse that is narrower than the destination clock period. The destination clock may step right over it and miss it entirely. Narrow pulses need a pulse synchronizer or a handshake, covered later in this path.
Mark synchronizer flops clearly (a naming convention like _meta and _sync, or a dedicated module) so synthesis, place-and-route, and CDC tools recognize them and keep the two flops close together with no logic between.