Draft preview. Lessons are being written and reviewed.

Digital Design / Module 10: Clock domain crossing

53. Metastability and MTBF

Understand why synchronizers exist.

Lecture coming soon

See it move

The idea

A flop is built around a feedback loop with two stable states. If data changes right at the clock edge, breaking setup or hold, the loop can land near its balance point, like a ball on the top of a hill. It will roll to one side eventually, but nobody can say how long this takes. This state is called metastability.

Why you can't avoid it

When clocks are unrelated, the data will sometimes change near the edge. No design can prevent that. What you can do is give the flop time to settle before anyone uses its output, and make failure extremely unlikely.

The odds

The chance of still being unresolved falls exponentially with waiting time:

MTBF = e^(t / τ) / (T0 · fclk · fdata)

  • t is the settling time available.
  • τ is a flop characteristic: smaller means faster resolution.
  • T0 relates to how wide the vulnerable window is.
  • fclk and fdata set how often an edge may catch a change.

The exponential is what matters. A little more settling time gives an enormous improvement. A flop adds almost a whole clock period of settling time, which can raise MTBF by many orders of magnitude.

The synchronizer

Two flops in series give the first one a full cycle to settle before the second one samples it. Even if the first flop is unresolved, it has almost always settled by the next edge. The second output is then a clean 0 or 1, either the old value or the new.

Common mistake

Saying that a synchronizer eliminates metastability. It makes failure very rare but not impossible, so you design for an acceptable MTBF. Remember the whole product: 10 years of MTBF for one synchronizer means something different in a chip with a million units, each with hundreds of synchronizers. High-frequency or safety-critical designs use three stages. Drag the sliders above, and watch how strongly MTBF depends on the settling time.

Key ideas

  • An async change near the edge can leave a flop between 0 and 1.
  • It settles eventually; the odds fall exponentially with time.
  • MTBF rises dramatically with each added synchronizer stage's settling time.

Lab: Clock crossing lab

Your exercise

Compare relative MTBF for one and two stages of settling time.

Interview questions

coreDoes a 2-flop synchronizer remove metastability?

basicWhat is metastability, and why can no design prevent it when two clocks are unrelated?

basicIn MTBF = e^(t / tau) / (T0 x fclk x fdata), which term gives a designer the most control, and why?

coreA flop has tau = 0.05 ns. How much extra settling time makes MTBF ten times larger? How much for a thousand times?

coreWith tau = 0.05 ns, T0 = 0.1 ns, fclk = 500 MHz, fdata = 10 MHz and 1.8 ns of settling time, MTBF is about 273 years. What is it if the data only changes at 1 MHz?

coreOne synchronizer has an MTBF of 1 million years. A product ships 10,000 units, each with 50 such synchronizers. What is the expected time between failures across the whole fleet?

coreYour RTL and gate-level simulations of a clock crossing never show an X at the synchronizer. Does that show the design is safe from metastability?

advancedUsing the same constants (tau 0.05 ns, T0 0.1 ns, fdata 10 MHz, 0.2 ns of each period used by the flops), a two-flop synchronizer at 500 MHz has an MTBF of about 273 years. What happens at 1 GHz, and why is the drop so large?

advancedWhen would you choose a three-flop synchronizer over two, and what does it cost?

Practise these 9 questions with animations