clock domain crossing
Clock domain crossing is the transfer of a signal from a circuit block running on one clock to a circuit block running on a different, asynchronous clock, a situation that requires special synchronization circuitry to avoid unpredictable capture errors called metastability.
```flowchart
{
"rows": [
{ "type": "nodes", "items": [
{ "title": "Signal originates in a block running on one clock", "sub": "destination block runs on a different, unrelated clock", "tone": "neutral" }
]},
{ "type": "arrow" },
{ "type": "group", "title": "Synchronizer bridges the two asynchronous clock domains", "items": [
{ "title": "Multi-stage flip-flop chain lets metastability settle safely", "sub": "prevents an unstable value from propagating further", "tone": "blue" }
]},
{ "type": "arrow" },
{ "type": "nodes", "items": [
{ "title": "Signal safely captured in the destination clock domain", "sub": "reliable transfer despite the clocks being unrelated", "tone": "green" }
]}
]
}
```
**Clock domain crossing requires special handling because a signal changing at essentially any moment relative to a receiving flip-flop's clock edge can occasionally arrive so close to that edge that the flip-flop can't resolve a clean logical value in time, entering a temporarily unstable state called metastability.** Since two clock domains running independently, with no fixed timing relationship between their edges, mean a signal crossing between them can violate the receiving flip-flop's setup and hold requirements at essentially any moment, without deliberate synchronization such a metastable capture can propagate an invalid, unpredictable value into the receiving clock domain's logic.
```svg
```
```svg
```
| Aspect | Signal within one clock domain | Signal crossing clock domains |
|---|---|---|
| Timing relationship between source and destination | Fixed and known | Unrelated, asynchronous |
| Risk of metastability | None | Present without synchronization |
| Standard mitigation | Not needed | Multi-stage synchronizer |
| Common use | Ordinary internal signal paths | Interfaces between independent clock regions |
**A common synchronizer for a single-bit signal uses two or more flip-flop stages in series clocked by the destination domain, giving any metastable value time to resolve into a stable logic level before it's used by downstream logic.** Because a metastable flip-flop output generally does eventually settle to a valid logic level, just not necessarily within a single clock cycle, adding extra flip-flop stages between the crossing signal and the logic that uses it gives that settling process more time to complete, dramatically reducing the practical risk that an unresolved metastable value reaches downstream logic.
**Multi-bit signals crossing clock domains need more careful handling than a simple synchronizer chain, since different bits could be captured on different clock cycles, producing a combination of old and new bit values that was never actually a valid signal state.** Because a straightforward per-bit synchronizer applied independently to each bit of a multi-bit value doesn't guarantee all bits get captured together, designers typically use techniques such as gray coding or handshake protocols specifically designed to ensure a multi-bit value crosses the clock domain as a single, internally consistent unit.
**Clock domain crossing verification has become a specialized area of chip design, since metastability-related bugs are often intermittent and timing-dependent, making them notoriously difficult to catch through ordinary functional simulation alone.** Because a clock domain crossing bug might only manifest under specific, rare timing alignments between two independent clocks, rather than showing up reliably in typical simulation runs, chip design teams commonly use dedicated clock domain crossing analysis tools that specifically check every crossing in a design for proper synchronization, catching issues that conventional verification approaches could easily miss.
Read clock domain crossing through a relay-handoff lens: much like a relay race baton handoff requires a careful, deliberate exchange between two runners moving at their own independent paces to avoid a dropped baton, transferring a signal between two independently clocked domains requires a careful, deliberate synchronizer to avoid a corrupted value.