How Do You Calculate Setup and Hold Slack for a Flip-Flop Path?
Setup time is how long a flip-flop's input must be stable before the clock edge, and hold time is how long it must stay stable after the edge; a timing check compares when data really arrives with those two windows. Setup slack = (T + skew) − (tcq,max + tcomb,max + tsetup) uses the slowest delays, and hold slack = (tcq,min + tcomb,min) − (thold + skew) uses the fastest delays and no clock period at all. For a 5 ns clock with the capture clock 0.2 ns late, the worked path below has 0.9 ns of setup slack and 0.05 ns of hold slack, so it meets timing and could run up to 243.9 MHz.
What you'll learn
- What setup time, hold time, clock-to-Q delay and skew each mean, with the sign convention for skew
- Where the setup and hold formulas come from, using the clock edges
- A fully worked timing check, drawn as timing diagrams, plus the maximum clock frequency
- Why a faster or slower clock cannot fix a hold violation
- How skew trades setup slack against hold slack, and what happens when either check fails
What goes into the two checks?
Data leaves the launch flip-flop FF1 a clock-to-Q delay tcq after a clock edge, passes through combinational logic, and must be captured by FF2. FF2 needs its input stable for tsetup before its clock edge (setup time) and for thold after it (hold time). Every delay has a slowest value (propagation delay) and a fastest value (contamination delay), because different inputs take different paths through the logic. Setup is a race the data must win, so it uses the slowest values; hold is a race the data must not win too early, so it uses the fastest values.
Conventions used here
One clock of period T feeds both flip-flops. Skew is the clock's arrival time at the capture flip-flop minus its arrival time at the launch flip-flop, so positive skew means the capture clock is late. Positive slack meets the constraint and negative slack is a violation. Some textbooks define skew the other way round; flip the sign of the skew terms if a question does.
Where do the formulas come from?
Setup: data launched by FF1's edge at time 0 arrives at FF2 by tcq,max + tcomb,max at the latest. FF2 captures it on its next edge, which arrives at T + skew, and needs it there tsetup earlier. So the data is in time if tcq,max + tcomb,max ≤ T + skew − tsetup, and setup slack is the difference. Hold: the same launch edge also reaches FF2 at time skew, and FF2 is still holding the previous data until thold after that. The new data, arriving as early as tcq,min + tcomb,min, must not get there before skew + thold. So hold slack is (tcq,min + tcomb,min) − (thold + skew). The clock period never appears, because both events come from the same edge.
Worked example: a 5 ns clock with 0.2 ns of skew
- Setup slack = (5 + 0.2) − (0.4 + 3.6 + 0.3) = 5.2 − 4.3 = 0.9 ns. Positive, so the setup check passes.
- Hold slack = (0.3 + 0.2) − (0.25 + 0.2) = 0.5 − 0.45 = 0.05 ns. Positive, but only just.
- Minimum clock period: set the setup slack to zero, T = 0.4 + 3.6 + 0.3 − 0.2 = 4.1 ns, so fmax = 1 ÷ 4.1 ns = 243.9 MHz.
- For comparison, with zero skew the setup slack would be 0.7 ns, the hold slack 0.25 ns and the minimum period 4.3 ns.
Why can't the clock period fix a hold violation?
Because T is not in the hold formula. Suppose the shortest path through the logic were 0.1 ns instead of 0.2 ns. Hold slack becomes (0.3 + 0.1) − (0.25 + 0.2) = −0.05 ns, a violation at every clock frequency: slowing the clock gives the data more time to arrive, which only helps setup. A hold violation has to be fixed in the path itself, typically by adding a delay buffer to the short path. Here a 0.1 ns buffer restores the hold slack to +0.05 ns, and as long as the buffer is not on the slowest path, the setup slack is unaffected. Reducing the skew also helps hold.
How does skew trade setup against hold?
Positive skew delays the capture edge, which gives the slow path more time (setup slack up by the skew) but also keeps the old data in demand longer (hold slack down by the skew). In the example, 0.2 ns of positive skew moved setup slack from 0.7 to 0.9 ns and hold slack from 0.25 to 0.05 ns. Negative skew does the opposite.
What happens when a check fails?
A setup violation means the new data may not have settled when FF2 samples it, so FF2 can capture the old value, a mix of old and new bits, or go metastable. A hold violation means the new data overwrites the old one inside FF2's hold window, with the same results. In simulation with ideal timing, neither shows up; only static timing analysis, or a gate-level simulation with timing checks, finds them. Inputs from another clock domain violate setup and hold by design, which is why they need a synchronizer.
Common mistakes
- Using maximum delays in the hold check or minimum delays in the setup check.
- Putting the clock period into the hold check, then trying to fix hold by changing the frequency.
- Getting the skew sign backwards: with skew defined as capture minus launch, it adds to the setup side and subtracts from the hold side.
- Forgetting tcq and adding only the logic delay.
- Reading a small positive slack as a failure. Any slack of zero or more meets the constraint.
Interview questions
- Q1. Two flip-flops are connected directly, with no logic between them, and the path fails hold. How? Answer: hold slack is tcq,min − (thold + skew) with no logic delay. If the capture clock arrives later than the launch flop's clock-to-Q minus its hold time, the new data races through. Fix it by adding delay to the data path, as tools do with hold-fixing buffers, or by reducing the skew.
- Q2. A path fails setup by 0.3 ns at 250 MHz. Name three fixes. Answer: lower the clock frequency (the only fix that changes nothing in the design); shorten the logic, for example by restructuring it or moving part of it into the previous or next stage with a pipeline register; or use positive skew on the capture flop if the following path has slack to spare, since that skew steals the same amount from the next stage.
- Q3. Why does a timing report check hold at the fast corner and setup at the slow corner? Answer: setup fails when delays are long, so it is checked with the slowest process, lowest voltage and the temperature that slows the device most; hold fails when delays are short, so it is checked with the fastest conditions. A path must pass both checks at every corner.
Check your understanding
- Q1. The same path is clocked at T = 4 ns. What is the setup slack? Answer: (4 + 0.2) − 4.3 = −0.1 ns, a violation.
- Q2. The skew is −0.2 ns instead (capture clock early). What are the setup and hold slacks at T = 5 ns? Answer: setup (5 − 0.2) − 4.3 = 0.5 ns; hold 0.5 − (0.25 − 0.2) = 0.45 ns.
- Q3. At 200 MHz with +0.2 ns skew, what is the largest maximum logic delay that still meets setup? Answer: 5 + 0.2 − 0.4 − 0.3 = 4.5 ns.
Related
Sources
Last verified
Every slack value, the minimum period and the numbers on both timing diagrams are computed in lib/digitalTiming.mjs and checked in lib/digitalDesign.test.js (25 November 2026). The setup and hold definitions follow the AMD and Intel timing analysis guides; the GATE 2027 EC syllabus lists propagation delay, setup and hold time and critical path delay under Section 5, Digital Circuits (checked against the official PDF from IIT Madras on 10 October 2026).