C7 · Lesson 27 · Timing of sequential circuits
Setup, hold, clock skew, metastability and pipelining
A synchronous circuit works only if every signal leaving one flip-flop reaches the next in time for the following clock edge, and not so quickly that it disturbs the value being captured on the current one. Those two conditions, setup and hold, decide a chip's top clock speed and whether it works at all. Signals that arrive from outside, unsynchronized to the clock, add a third problem: a flip-flop caught mid-change can hang between 0 and 1. And when the logic between registers is too slow, the cure is to cut it into stages: pipelining.
- One register feeds two paths to two more registers: N1 inverts it after 3 ticks, N2 after 12. The clock period is 8 ticks.
- R1 always captures the new value of N1. N2 hasn't settled when the next edge arrives, so R2 captures a stale value: the slow path violates setup.
- A slow path can be fixed by a slower clock, a faster circuit, or by adding a register in the middle of it.
Predict
A flip-flop's clock-to-Q delay is 50 ps, the logic after it takes 600 ps, and the next flip-flop needs 40 ps of setup. What is the highest clock frequency?
About 1.45 GHz: the period must cover 50 + 600 + 40 = 690 ps. The logic dominates, but the flip-flops' own overhead is part of every cycle, which matters more as logic per stage shrinks.
Name it
Setup
From one clock edge, data leaves a flip-flop after at most (clock-to-Q), passes logic of at most , and must arrive before the next edge:
The slowest such path is the critical path. A setup violation can always be fixed by slowing the clock.
Hold
The new data must not reach the next flip-flop so soon that it corrupts what that flip-flop is capturing on the same edge. With the shortest delays, (contamination clock-to-Q) and (contamination logic delay):
This doesn't involve the clock period, so slowing the clock can't fix it: the fix is adding delay (buffers) to the short path.
Clock skew
If the receiving flip-flop's clock arrives late by up to , the setup constraint gets easier only if skew is known; in the worst case both tighten: and .
Metastability and synchronizers
An input that changes asynchronously can violate setup, leaving a flip-flop between 0 and 1 for an unbounded (but exponentially unlikely) time. The probability that it's still unresolved after time t is about , with τ and properties of the flip-flop. A synchronizer, two flip-flops in series, gives the first nearly a whole period to resolve, so for N asynchronous changes per second
Pipelining
Splitting logic of total delay into k stages with registers between them gives (the of each register): throughput rises almost k-fold, but each result's latency grows to .
Worked example
A synchronizer runs at 100 MHz with = 0.1 ns; its flip-flops have τ = 0.2 ns and = 0.15 ns, and the input changes 10⁶ times a second. Find its MTBF.
Show the solution
- The prefactor.
- The exponential. The flip-flop has the period less the setup time, 9.9 ns, to resolve:
- MTBF. billions of years.
- With half a period. With only half a period to resolve it would be about s, a failure every month: the exponential makes every extra picosecond count.
Answer about s, billions of years.
Worked example
Logic taking 9 ns sits between registers with 1 ns of overhead. Compare 1, 3 and 9 pipeline stages.
Show the solution
- One stage. 100 MHz, with a latency of 10 ns.
- Three stages. 250 MHz, with a latency of 12 ns.
- Nine stages. 500 MHz, with a latency of 18 ns.
- Compare. Throughput rises with depth, but the overhead stops it reaching 900 MHz, and latency grows.
Answer 100 MHz, 250 MHz and 500 MHz, with latencies of 10 ns, 12 ns and 18 ns.
Worked example
Registers with = 0.1 ns, = 0.05 ns, setup 0.05 ns and hold 0.03 ns surround logic with = 0.8 ns and = 0.1 ns. The capture clock arrives 0.2 ns late. Check setup and hold.
Show the solution
- Check setup. Skew that delays the capture clock gives the data extra time: a gain.
- Check hold. Hold gets worse by the same amount, since the new data must not arrive before the late edge's hold window closes: a violation by 0.08 ns.
- The fix. No clock frequency fixes it; delay buffers in the short path do.
- The trade. Skew helps one constraint exactly as much as it hurts the other.
Answer setup passes for any ns, but hold fails by 0.08 ns.
Check
A path has = 30 ps, logic of 200 ps and = 60 ps. What is the highest clock frequency?
Write units the way you normally would: 1.5 GHz, 1500 MHz and 0.0015 THz are the same answer.
Check
With up to 50 ps of clock skew, what is the shortest period for that path ( = 30, = 200, = 60 ps)?
Write units the way you normally would: 1.5 ps and 0.0015 ns are the same answer.
Check
A short path has = 20 ps and = 0 ps; the next flip-flop needs = 50 ps, with up to 20 ps of skew. What is the hold margin (negative means a violation)?
Write units the way you normally would: 1.5 ps and 0.0015 ns are the same answer.
Check
A synchronizer clocked at 50 MHz ( = 0.05 ns, τ = 0.3 ns, = 1 ns) samples an input changing 0.1 million times a second. What is of its MTBF in seconds?
Write units the way you normally would: 1.5 s and 1500 ms are the same answer.
Check
Logic of 12 ns is split into 2 equal pipeline stages, with 1 ns of register overhead each. What clock frequency results?
Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.
Check
What is the latency through that pipeline (12 ns of logic, 2 stages, 1 ns overhead)?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
Check
Static timing analysis reports a hold violation. Which fix works?
Check
Registers ( = 0.05, = 0.03, setup 0.04, hold 0.02 ns) surround logic with = 1.5 ns and = 0.2 ns; the capture clock arrives 0.05 ns late.
(a)
What's the minimum clock period?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
(b)
What's the hold slack (negative means a violation)?
Check
A two-flop synchronizer is clocked with period T; its flip-flops have τ = t and = u, setup w, and the input changes N times a second.
Step 1
What's its mean time between failures?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
By what exponent does the resolution time beat τ?
Explain why
Why can't a hold violation be fixed by slowing the clock?
A setup violation is a race against the next clock edge: data takes too long to arrive, so giving it a longer period fixes it. A hold violation is a race within a single edge: the same edge launches new data from one flip-flop and captures old data in the next, and if the new data arrives too quickly it overwrites the old value before the capture is complete. Both events happen at the same clock edge, whatever the period, so the period never enters the condition. Only lengthening the short path, or reducing skew, can fix it.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.