D108 of 13
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

D10 · Lesson 8 · Timing and clock domains

Why almost all digital design is synchronous, the setup and hold checks every register-to-register path must pass, slack and the maximum clock rate, metastability when a signal arrives from another clock domain, the two-flip-flop synchronizer and its mean time between failures, and safe ways to pass whole buses across

A synchronous design makes one promise: every flip-flop changes only at a clock edge, and every signal has a full clock period to settle before the next edge samples it. Keep that promise and a design with millions of gates behaves predictably, which is why static timing analysis can check it path by path. Break it, by letting a signal arrive from a different clock or from a button, and a flip-flop can be caught mid-change and hover between 0 and 1 for an unpredictable time. That state, metastability, can't be prevented, only made vanishingly rare.

  • An asynchronous input A, changing with no relation to the clock, passes through two flip-flops: S1 samples it, S2 samples S1.
  • In real hardware S1 may go metastable when A changes right at a clock edge; S2 gives it a whole clock period to resolve before anything uses it. The logic simulator here shows the ideal behavior: the two-cycle delay through the synchronizer.
  • Everything downstream reads only S2, which is synchronous to the clock.

Predict

A synchronizer flip-flop has a resolution time constant τ = 50 ps. Compared with allowing 0.5 ns to resolve, how much does allowing 3 ns improve the mean time between failures?

Name it

Setup and hold

For every path from one flip-flop to the next:

  • setup: the data must arrive a setup time tsu before the next edge: T≥tcq+tlogic,max+tsu, giving the maximum clock rate. Slack is the period minus the required time; negative slack fails.
  • hold: the data must not change until a hold time th after the edge: tcq+tlogic,min≥th, independent of the clock rate, and fixed by adding delay to short paths.

Clock skew, the difference in when the edge reaches the two flip-flops, eats into one check or the other. Static timing analysis checks every path against both.

Metastability

A flip-flop whose input changes inside its setup-and-hold window may hang between 0 and 1 before resolving. The mean time between failures of a synchronizer allowing a time tr to resolve is

MTBF=etr/τT0fclkfdata

with device constants τ and T0 (around 50 ps and 1 ns in modern processes).

Crossing clock domains

  • A single bit crosses through a two-flip-flop synchronizer, which gives the first flip-flop a whole period to resolve.
  • A multi-bit value can't be synchronized bit by bit, since its bits could be caught in different cycles. Use a Gray-coded counter (only one bit changes at a time), a handshake that holds the data steady while a synchronized flag crosses, or an asynchronous FIFO (S3).

Worked example

A path has 0.3 ns clock-to-output, 3.2 ns of logic and 0.2 ns setup. What's its maximum clock, and its slack at 250 MHz?

Show the solution
  1. Path delay. t=0.3+3.2+0.2=3.7ns
  2. Maximum clock. 13.7ns=270MHz
  3. Slack at 250 MHz. The period is 4.0 ns: 4.0−3.7=0.3ns

Answer a maximum clock of 270 MHz, and 0.3 ns of slack at 250 MHz.

Worked example

A flip-flop with 0.1 ns clock-to-output feeds another through a 0.05 ns wire. The receiving flip-flop needs 0.2 ns of hold. Does it pass?

Show the solution
  1. When the data changes. t=0.1+0.05=0.15ns after the edge.
  2. Compare with the hold window. The data changes before the 0.2 ns hold window closes: 0.2−0.15=0.05ns a hold violation of 0.05 ns.
  3. The fix. Add delay to the path, since slowing the clock doesn't help hold.

Answer it fails, with a hold violation of 0.05 ns.

Worked example

A single flip-flop synchronizes a 1 MHz signal into a 100 MHz domain with only 0.5 ns to settle. With τ = 50 ps and T0 = 0.1 ns, what is its MTBF?

Show the solution
  1. Settling time in time constants. tτ=0.5ns50ps=10
  2. MTBF. MTBF=et/τT0fclkfdata=e1010−10×108×106s=2.2s It fails every couple of seconds.
  3. A second flip-flop. It adds a whole 10 ns period of settling, multiplying the MTBF by e10ns/50ps=e200 effectively never.

Answer an MTBF of 2.2 s, a failure every couple of seconds; a second flip-flop multiplies it by e200.

Check

A path has 0.1 ns clock-to-output, 1.5 ns of logic and 0.2 ns of setup time. What's the fastest clock it allows?

Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.

Check

A 200 MHz design has a path with 0.2 ns clock-to-output, 3.5 ns of logic and 0.15 ns setup. What's its setup slack?

Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.

Check

A synchronizer with τ = 50 ps and T0 = 1 ns allows 2 ns to resolve, on a 100 MHz clock with data changing 10 million times a second. What's its MTBF?

Write units the way you normally would: 1.5 s and 1500 ms are the same answer.

Check

A flip-flop with 0.1 ns clock-to-output feeds another through 0.03 ns of logic, and the second needs 0.25 ns of hold. What's the hold slack?

Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.

Check

A path has 0.2 ns clock-to-output, 2 ns of logic and 0.3 ns of setup, clocked at 200 MHz.

(a)

What is its maximum clock?

Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.

(b)

What is its slack at 200 MHz?

Check

A synchronizer has τ = 50 ps and T0 = 0.1 ns, with 0.5 ns to settle, on a 100 MHz clock sampling data that changes 10 million times a second.

(a)

What is its MTBF?

Write units the way you normally would: 1.5 s and 1500 ms are the same answer.

(b)

By how many powers of ten does a second flip-flop, adding 10 ns of settling, raise it?

Explain why

Why can't a multi-bit counter value be passed between clock domains through a synchronizer on each bit?

Practice

Keep practicing

8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.