Metastability
Metastability is an unavoidable physical phenomenon in sequential digital circuits.
Every bistable storage element can enter an intermediate state where its output voltage balances between logic 0 and logic 1. In this state, the output requires an unpredictable duration to resolve to a valid logic level.
When an asynchronous signal connects to a clocked flip-flop, metastability can occur. Engineering designs cannot eliminate metastability completely. Instead, designers structure synchronizers to make the probability of failure negligible during the operational lifespan of the product.
Physical Mechanism of Metastability
A flip-flop storage element contains two cross-coupled inverters. This circuit has two stable digital operating points and one unstable equilibrium point near half of the power supply voltage ($V_{DD}/2$).
Under normal operation, data input $D$ remains stable throughout the setup and hold window. The internal storage nodes settle far from the unstable equilibrium point. Positive feedback drives the nodes to $V_{DD}$ or ground within the specified clock-to-Q delay ($t_{\text{cq}}$).
If input $D$ transitions during the setup or hold window, the internal nodes capture an intermediate voltage near the unstable midpoint. The cross-coupled inverters amplify the small initial voltage difference $V_\epsilon$ exponentially:
$$V(t) = \frac{V_{DD}}{2} + V_\epsilon e^{t/\tau}$$
The parameter $\tau$ is the metastability resolution time constant of the semiconductor process. Advanced semiconductor processes feature smaller time constants ($\tau \approx 10\text{ ps}$ to $20\text{ ps}$ at 7 nm) because smaller transistors provide higher transconductance and lower parasitic capacitances.
The probability $P(t)$ that the node remains unresolved after duration $t$ decreases exponentially:
$$P(t) = e^{-t/\tau}$$
Although the probability decays rapidly, the mathematical probability never equals zero.
The Metastability Window
The metastability window $t_w$ represents the temporal duration around the clock edge where an input transition triggers metastability.
For modern standard cell libraries, $t_w$ is approximately equal to the sum of setup time and hold time ($t_{\text{su}} + t_h$), typically ranging between $50\text{ ps}$ and $100\text{ ps}$.
Mean Time Between Failures (MTBF)
The Mean Time Between Failures (MTBF) measures the statistical reliability of a synchronizer circuit:
$$\text{MTBF} = \frac{e^{t_r/\tau}}{f_{\text{clk}} , f_{\text{data}} , t_w}$$
The parameters are:
- $t_r$: Available resolution time before the destination flip-flop samples the signal.
- $\tau$: Metastability time constant of the flip-flop.
- $f_{\text{clk}}$: Clock frequency of the receiving clock domain.
- $f_{\text{data}}$: Transition rate of the asynchronous input signal.
- $t_w$: Metastability aperture window.
Consider a 1 GHz clock domain ($T_{\text{clk}} = 1000\text{ ps}$), an asynchronous input frequency $f_{\text{data}} = 10\text{ MHz}$, a 7 nm process with $\tau = 15\text{ ps}$, $t_w = 80\text{ ps}$, and setup time $t_{\text{su}} = 80\text{ ps}$.
With a single flip-flop stage, the available resolution time is $t_r = 1000\text{ ps} - 80\text{ ps} = 920\text{ ps}$:
$$\text{MTBF} = \frac{e^{920/15}}{10^9 \times 10^7 \times 80 \times 10^{-12}} = \frac{e^{61.33}}{8 \times 10^5} \approx 5.5 \times 10^{20}\text{ seconds}$$
This value exceeds $10^{13}$ years. At 1 GHz, a single stage provides high statistical reliability.
However, increasing clock frequency reduces available resolution time $t_r$ directly. At 4 GHz ($T_{\text{clk}} = 250\text{ ps}$), resolution time drops to $t_r = 250\text{ ps} - 80\text{ ps} = 170\text{ ps}$:
$$\text{MTBF} = \frac{e^{170/15}}{4 \times 10^9 \times 10^7 \times 80 \times 10^{-12}} = \frac{8.3 \times 10^4}{3.2 \times 10^6} \approx 0.026\text{ seconds}$$
At 4 GHz, a single-stage synchronizer fails approximately 38 times per second.
Adding a second flip-flop stage increases available resolution time to:
$$t_r = (2 \times 250\text{ ps}) - 80\text{ ps} = 420\text{ ps}$$
$$\text{MTBF} = \frac{e^{420/15}}{3.2 \times 10^6} = \frac{1.44 \times 10^{12}}{3.2 \times 10^6} \approx 4.5 \times 10^5\text{ seconds} \approx 5.2\text{ days}$$
A failure every 5 days is unacceptable for commercial hardware.
Adding a third flip-flop stage provides $t_r = 670\text{ ps}$, yielding $\text{MTBF} \approx 8 \times 10^{12}\text{ seconds}$ (approximately 250,000 years). High-speed designs use three-stage synchronizers to ensure reliable operation.
The Two-Flip-Flop Synchronizer
The standard circuit for synchronizing a single-bit asynchronous signal is the two-flip-flop synchronizer (Figure 1).
The first flip-flop (FF1) samples the asynchronous input. If an input transition violates setup timing, FF1 can enter metastability.
FF1 has a full clock period minus setup time to resolve its voltage before the second flip-flop (FF2) samples the output (Figure 2). FF2 captures a stable, valid logic level and drives downstream logic.
The Synchronizer Fan-Out Rule
The output of the first synchronizer flip-flop must connect exclusively to the data input of the second synchronizer flip-flop.
Never branch the output of the first synchronizer stage to multiple destination gates.
While the first stage is resolving a metastable event, its output voltage hovers near the switching threshold. Different receiving logic gates have slightly different switching thresholds due to physical process variations.
One receiving gate may interpret the intermediate voltage as logic 1, while an adjacent gate interprets the same voltage as logic 0. This divergence creates inconsistent internal states.
Always sample the output of the second, fully resolved flip-flop stage.
Multi-Bit Clock Domain Crossings
Do not pass multi-bit buses through parallel individual flip-flop synchronizers.
Because path delays and resolution times vary across bits, individual bit synchronizers can resolve across different clock cycles.
For example, when an 8-bit counter increments from 0111_1111 to 1000_0000, all eight bits transition. If bit 7 synchronizes one cycle before the lower bits, the receiving domain temporarily captures 1111_1111, corrupting the data stream.
Digital systems use three robust techniques for multi-bit clock domain crossings:
- Gray Code Encoding: Used for counters and FIFO read/write pointers. Gray codes change only one bit per transition, ensuring that parallel synchronizers never encounter multi-bit transitions.
- Synchronized Handshaking Flags: The transmitting domain places multi-bit data onto a bus and asserts a single-bit
validcontrol flag. The receiving domain synchronizes only thevalidflag. The receiver reads the data bus only after the synchronizedvalidflag arrives, ensuring data stability. - Asynchronous Dual-Clock FIFOs: Dual-clock FIFOs store data in a dual-port memory and pass Gray-coded read and write pointers across domains. This architecture provides high throughput between unrelated clock domains.
Practice Exercises
Problem 1
A synchronizer in a 500 MHz clock domain ($T_{\text{clk}} = 2000\text{ ps}$) uses 7 nm flip-flops with parameters:
- $\tau = 12\text{ ps}$
- $t_w = 60\text{ ps}$
- $t_{\text{su}} = 60\text{ ps}$
- $f_{\text{data}} = 50\text{ MHz}$
Calculate the MTBF for a single-stage synchronizer and for a two-stage synchronizer.
Solution
Calculate the denominator:
$$\text{Den} = f_{\text{clk}} \times f_{\text{data}} \times t_w = (5 \times 10^8) \times (5 \times 10^7) \times (60 \times 10^{-12}) = 1.5 \times 10^6\text{ s}^{-1}$$
Single-stage synchronizer:
$$t_r = T_{\text{clk}} - t_{\text{su}} = 2000\text{ ps} - 60\text{ ps} = 1940\text{ ps}$$
$$\text{MTBF}_1 = \frac{e^{1940/12}}{1.5 \times 10^6} = \frac{e^{161.67}}{1.5 \times 10^6} \approx 10^{64}\text{ seconds}$$
Two-stage synchronizer:
$$t_r = (2 \times T_{\text{clk}}) - t_{\text{su}} = 4000\text{ ps} - 60\text{ ps} = 3940\text{ ps}$$
$$\text{MTBF}_2 = \frac{e^{3940/12}}{1.5 \times 10^6} = \frac{e^{328.33}}{1.5 \times 10^6} \approx 10^{136}\text{ seconds}$$
At 500 MHz, the two-stage synchronizer provides complete statistical reliability.
Problem 2
A 16-bit binary counter must cross from a 125 MHz clock domain to a 1 GHz clock domain. Explain why individual synchronizers fail, and provide the correct SystemVerilog implementation.
Solution
When a binary counter rolls over, multiple bits transition simultaneously. Individual synchronizers resolve independently across different clock cycles, producing corrupted intermediate values in the destination domain.
To correct this failure, convert the counter to Gray code before synchronization:
// Transmitter clock domain: Binary to Gray conversion
always_ff @(posedge clk_src or negedge rst_n) begin
if (!rst_n) begin
count_bin <= '0;
count_gray <= '0;
end else begin
count_bin <= count_bin + 1'b1;
count_gray <= (count_bin + 1'b1) ^ ((count_bin + 1'b1) >> 1);
end
end
// Receiver clock domain: 2-stage synchronization and Gray-to-Binary decoding
logic [15:0] sync1, sync2, count_rx;
always_ff @(posedge clk_dst or negedge rst_n) begin
if (!rst_n) begin
sync1 <= '0;
sync2 <= '0;
end else begin
sync1 <= count_gray;
sync2 <= sync1;
end
end
always_comb begin
count_rx[15] = sync2[15];
for (int i = 14; i >= 0; i--) begin
count_rx[i] = count_rx[i+1] ^ sync2[i];
end
end
Because only one bit transitions at a time in Gray code, the decoded value in the receiving domain is always either the previous count or the new count.
Problem 3
A designer inserts a multiplexer between the two stages of a synchronizer to support a local test bypass mode:
always_ff @(posedge clk) ff1_q <= async_in;
always_ff @(posedge clk) ff2_q <= bypass_mode ? local_in : ff1_q;
assign sync_out = ff2_q;
Identify the circuit flaw and provide the corrected code.
Solution
Placing combinational logic between synchronizer flip-flops violates the synchronizer discipline:
- The multiplexer propagation delay reduces the available resolution time $t_r$, decreasing MTBF exponentially.
- If
ff1_qis metastable, the multiplexer transmits an indeterminate voltage toff2_q.
Correct the circuit by placing the multiplexer after the second synchronizer stage:
always_ff @(posedge clk) ff1_q <= async_in;
always_ff @(posedge clk) ff2_q <= ff1_q;
assign sync_out = bypass_mode ? local_in : ff2_q;
Section 3.3 examines Finite State Machines (FSMs), comparing Moore and Mealy architectures and implementing state machines in SystemVerilog.