An asynchronous input will sometimes change inside a flip-flop's setup-and-hold window, so the first flip-flop to sample it may go metastable. A two-flip-flop synchronizer contains the damage:
- The raw input goes into flip-flop S1, clocked by the receiving clock.
- S1's output goes straight into flip-flop S2, on the same clock. No logic in between.
- The rest of the circuit reads only S2.
If S1 goes metastable, it has almost a whole clock period to settle before S2 samples it. Because the chance of still being unsettled shrinks exponentially with time, S2 almost always sees a clean 0 or 1.
What it costs and what it doesn't promise:
- Latency: the circuit sees the input one or two cycles later than it arrived.
- Not perfect: failure becomes extremely rare, not impossible. More stages or a slower clock make it rarer still.
- One bit only: synchronizing each bit of a multi-bit value separately can produce a value that never existed, because bits may settle on different cycles.
Synchronize an input once, then fan the synchronized signal out. Never send the raw input to several flip-flops.