Interview Question · Concept
Setup and Hold from First Principles
- Asked at NVIDIA
- Asked at Texas Instruments
- Asked at Infineon
The Question
The interviewer asks
What are setup time and hold time? Write the two timing checks for a path from one flop to the next.
You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Setup time is how long D must be stable before the clock edge. Hold time is how long it must stay stable after the edge. Setup: clock-to-Q plus the slowest logic plus setup must fit in one period. Hold: clock-to-Q plus the fastest logic must be at least the hold time. The period appears only in the setup check. So a faster clock can break setup, but the clock speed never changes hold.
- Edge k launches
The launch flop takes its input at edge k. Its output changes a little later: the clock-to-Q delay.
Follow the calls, values and waits
- call edge k: clk → launch flop
- The long path
The new value ripples through 21 cells. Each cell adds its delay, so the arrival time grows with the levels.
Follow the calls, values and waits
- data new value: launch flop → long path: 21 levels
- data new value: long path: 21 levels → capture flop
- Edge k+1 captures: setup
D must be stable a setup time before edge k+1. So the period must cover clock-to-Q, the path delay and the setup time. A slower clock fixes a setup failure.
Follow the calls, values and waits
- call edge k+1: clk → capture flop
- The short path: hold
Edge k+1 also launches the next value. Through one cell it reaches the capture flop quickly. D must stay put for a hold time after the edge, and no clock period changes this race.
Follow the calls, values and waits
- data new value: launch flop → short path: 1 level
- data new value: short path: 1 level → capture flop
Read the diagram as text
- clk: edge k, then edge k+1 one period later
- launch flop: Q changes clock-to-Q after edge k
- long path: 21 levels: input a[0] through the carry chain
- short path: 1 level: settles soon after any edge
- capture flop: D stable from setup before edge k+1 to hold after it
- clk → launch flop: edge k
- launch flop → long path: 21 levels: Q
- long path: 21 levels → capture flop: D
- launch flop → short path: 1 level: Q
- short path: 1 level → capture flop: D
- clk → capture flop: edge k+1
Setup is checked against the next edge, so the longest path sets the period. Hold is checked against the same edge, so the shortest path can fail at any period.
| Check | Must be true (zero skew) | Fails when |
|---|---|---|
| Setup | Tcq + Tlogic_max + Tsetup <= Tperiod | the logic is too slow for the period |
| Hold | Tcq + Tlogic_min >= Thold | new data races through too fast and replaces the value being captured |
With clock skew, the capture clock arrival adds to the right side of setup and to the right side of hold.
One path needing 5100 ps (300 clock-to-Q, 4600 logic, 200 setup) at three clock periods.
period 4000 ps: late=49 early=0 window=0 period 5000 ps: late=0 early=0 window=39 period 6000 ps: late=0 early=0 window=0Self-Check
Tick each key point you covered in your answer.
What Interviewers Listen For (Fresher)
A good fresher answer draws the launch flop, the logic and the capture flop. It writes both inequalities and points to where the period appears.
What Interviewers Listen For (Mid-Level)
A good mid-level answer adds clock skew to both checks with the right sign. It says the 5000 ps case is worse than a wrong value, because the flop may go metastable.
Cross-Questions
Where the interviewer goes next. Open a node to practise that follow-up.
WhyWhat IfProve ItBreak ItCompare
- Setup and Hold from First Principles
-
WhyWhy the Period Is Not in the Hold CheckL1 Junior
Why does the clock period not appear in the hold check?
2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Hold is a race inside one clock edge. The same edge launches new data from the first flop and captures old data in the second flop. If the new data arrives before the hold time ends, it replaces the old value. Both events hang off the same edge, so the time to the next edge never enters.
Self-Check
Tick each key point you covered in your answer.
Half-Truth
"Hold is checked against the previous edge, so the period matters there."
For a normal single-cycle path, both the launch and the capture in the hold check use the same edge. A multicycle exception moves the hold edge, which is a different case.
Source OpenSTA 3.1.0 command reference (set_multicycle_path, set_false_path), as cited in lesson L2.8
-
What IfThe Hold Check After a Multicycle ExceptionL2 Mid-Level
What if you add
set_multicycle_path 2 -setupto a path? What happens to its hold check?2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
The setup check moves one capture edge later, and by default the hold check moves with it. Hold is then checked one edge after launch, which is almost always a false violation. The usual pair is
-setup 2with-hold 1, which moves hold back to the launch edge.Where the Setup and Hold Edges SitData launched by aat edge 0. A 1 marks the edge each check uses.All cycles- Cycle 0
By default, setup is checked at edge 1 and hold at edge 0, the launch edge itself.
- Cycle 1
With
-setup 2alone, hold moves to edge 1. D0 must stay stable for a whole period after launch. - Cycle 2
Setup is at edge 2, where
yloads.-hold 1brings hold back from edge 1 to edge 0.
Edges 0 to 3 of the 1 ns clock, with the edge each check uses marked as a 1.
Self-Check
Tick each key point you covered in your answer.
Spec Misquote
"A multicycle exception only relaxes setup; hold is unchanged."
In the default SDC rule, hold follows the setup multiplier. Forgetting
-hold 1gives a sea of hold violations that the tool then tries to fix with delay cells.Source OpenSTA 3.1.0 command reference (set_multicycle_path, set_false_path), as cited in lesson L2.8
- Cycle 0
-
CompareFixing Setup Versus Fixing HoldL1 JuniorL2 Mid-Level
Compare how you fix a setup violation with how you fix a hold violation.
2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Setup is fixed by making the slow path faster or giving it more time. Options are a faster cell or a restructured expression, a pipeline register, or a slower clock. Hold is fixed by making the fast path slower, usually with delay cells near the capture flop. Hold must be fixed at every corner, because a chip with a hold violation fails at any clock speed.
Timing pathThe Shift Register with a Delay CellThe same five-buffer capture clock; hd1(dlygate4sd3_1) sits between ff1 and ff2.Whole pathff1 → ff2hold check, earliest arrival2 cells
- Clock latency
- Cell delay
- Hold time
- The delay cell
hd1adds 0.5205 ns to the fastest path. - Hold met
Hold slack 0.4835 ns.
Read the path as a table
Launch: clk rise edge at 0.0000 ns, clock latency 0.0000 ns. Capture: clk rise edge at 0.0000 ns, latency 0.3818 ns, library hold time −0.0326 ns.
Arrival 0.8327 ns, required 0.3492 ns, slack 0.4835 ns (met).
Cell Arc Through Edge Delay (ns) Time (ns) Slew (ns) 1 ff1/CLK→ff1/Qdfxtp_1 rise 0.3123 0.3123 0.0333 ff1/Q→hd1/Awire q1 rise 0.0000 0.3123 0.0333 2 hd1/A→hd1/Xdlygate4sd3_1 rise 0.5205 0.8327 0.0451 hd1/X→ff2/Dwire q1d rise 0.0000 0.8327 0.0451 The report
Startpoint: ff1 (rising edge-triggered flip-flop clocked by clk) Endpoint: ff2 (rising edge-triggered flip-flop clocked by clk) Path Group: clk Path Type: min Fanout Cap Slew Delay Time Description ------------------------------------------------------------------------------------- 0.0000 0.0000 clock clk (rise edge) 0.0000 0.0000 clock source latency 2 0.0041 0.1000 0.0000 0.0000 ^ clk (in) clk (net) 0.1000 0.0000 0.0000 ^ ff1/CLK (sky130_fd_sc_hd__dfxtp_1) 1 0.0017 0.0333 0.3123 0.3123 ^ ff1/Q (sky130_fd_sc_hd__dfxtp_1) q1 (net) 0.0333 0.0000 0.3123 ^ hd1/A (sky130_fd_sc_hd__dlygate4sd3_1) 1 0.0017 0.0451 0.5205 0.8327 ^ hd1/X (sky130_fd_sc_hd__dlygate4sd3_1) q1d (net) 0.0451 0.0000 0.8327 ^ ff2/D (sky130_fd_sc_hd__dfxtp_1) 0.8327 data arrival time 0.0000 0.0000 clock clk (rise edge) 0.0000 0.0000 clock source latency 2 0.0041 0.1000 0.0000 0.0000 ^ clk (in) clk (net) 0.1000 0.0000 0.0000 ^ cb1/A (sky130_fd_sc_hd__clkbuf_1) 1 0.0022 0.0395 0.0906 0.0906 ^ cb1/X (sky130_fd_sc_hd__clkbuf_1) ck1 (net) 0.0395 0.0000 0.0906 ^ cb2/A (sky130_fd_sc_hd__clkbuf_1) 1 0.0022 0.0388 0.0736 0.1642 ^ cb2/X (sky130_fd_sc_hd__clkbuf_1) ck2 (net) 0.0388 0.0000 0.1642 ^ cb3/A (sky130_fd_sc_hd__clkbuf_1) 1 0.0022 0.0388 0.0734 0.2376 ^ cb3/X (sky130_fd_sc_hd__clkbuf_1) ck3 (net) 0.0388 0.0000 0.2376 ^ cb4/A (sky130_fd_sc_hd__clkbuf_1) 1 0.0022 0.0388 0.0734 0.3110 ^ cb4/X (sky130_fd_sc_hd__clkbuf_1) ck4 (net) 0.0388 0.0000 0.3110 ^ cb5/A (sky130_fd_sc_hd__clkbuf_1) 1 0.0019 0.0353 0.0708 0.3818 ^ cb5/X (sky130_fd_sc_hd__clkbuf_1) ck5 (net) 0.0353 0.0000 0.3818 ^ ff2/CLK (sky130_fd_sc_hd__dfxtp_1) 0.0000 0.3818 clock reconvergence pessimism -0.0326 0.3492 library hold time 0.3492 data required time ------------------------------------------------------------------------------------- 0.3492 data required time -0.8327 data arrival time ------------------------------------------------------------------------------------- 0.4835 slack (MET)Measured in lesson L2.4: a delay cell slows the short path of a shift register, so hold is met.
Self-Check
Tick each key point you covered in your answer.
Missed Corner
"Fix hold first, then setup."
Hold is usually repaired after clock tree synthesis, when real clock skew is known. Fixing it on an ideal clock adds delay cells that may not be needed, and they can hurt setup.
Source Lesson L5.5 claims: hold is repaired after CTS with propagated clocks (UC Berkeley EECS 151/251A lecture on sequential timing)
-
Prove ItSolve R4.5.1: A Two-Lane MAC on a Levels BudgetSimulator-graded
Show it, don't just say it: this Silicon Lab problem is graded by the simulator.
-
Break ItWhy RTL Simulation Cannot See a Setup ViolationL1 Junior
Your RTL simulation passes at any clock frequency you choose. Why can it never catch a setup violation?
2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
RTL flops and gates have zero delay, and they have no setup or hold windows. Data is always ready at the next edge, however short the period. Timing is checked by static timing analysis on the netlist, using library delays. Gate-level simulation with delays can also show it, but it is slower and covers fewer paths.
Self-Check
Tick each key point you covered in your answer.
Misconception
"Add
#1delays to the RTL and simulation will check timing."A hand-written delay is not the cell delay of the library. It shows nothing about the real paths and can create races of its own.
Source Sutherland, RTL Modeling with SystemVerilog (2017) ch. 1.6 Digital synthesis
-
What IfWhat a Timing Violation Does in SiliconL1 JuniorL2 Mid-Level
Asked if they say a violation "just fails timing"
What actually happens in silicon when a path violates setup?
2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
If the data arrives well after the edge, the flop simply keeps the old value, and the logic computes with stale data. If it changes inside the setup window, the flop can go metastable and settle late to either value. The run shows both: wrong values at 4000 ps and window hits at 5000 ps.
Self-Check
Tick each key point you covered in your answer.
Half-Truth
"A setup violation always gives a metastable flop."
Only a change inside the window risks metastability. A path that is very late just captures the old value cleanly, which is a plain functional bug.
Source Sutherland, RTL Modeling with SystemVerilog (2017) ch. 8.1.6 Multiple clocks and clock domain crossing
-
CompareWhy One Flop Is Not EnoughL0 FresherL1 Junior
Why is a single flop not enough to synchronize an asynchronous input?
2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
With one flop, logic reads its output in the same cycle that it might be metastable. Only the slack left after that logic is available for settling. Different gates can even read the same hanging value as different levels. The second flop isolates that settling from all other logic, and gives it about a full period.
The Model's Bad Cycle, One FlopEdges 11 to 17 of a simulator bench with a metastability model, sampled on clk. One value per edge, printed 1 ns after it. All cycles- Cycle 2
Edge 13: s1 has been 1 since edge 12, and the machine is in BUSY.
- Cycle 3
Edge 14: status fell 0.70 ns before the edge. The model makes s1 metastable; it settles to the old 1, after 3 ns.
- Cycle 4
Edge 15: 3 ns is more than the 2 ns the state flops can wait. Each reads its own bit, and both read 0: the bench prints
ILLEGAL. - Cycle 5
Edge 16: s1 is a clean 0 again and the machine recovers into IDLE.
Over 2000 edges of this bench, s1 went metastable 90 times. The state flops read it unsettled 22 times, and the machine was in an illegal state for 12 edges.
Self-Check
Tick each key point you covered in your answer.
Half-Truth
"One flop is enough if the clock is slow."
A slower clock helps MTBF. But logic after a single flop still reads a possibly unsettled value. The exponent depends on the time left after that logic.
- Cycle 2
-
What IfWhen One Period Is Not Enough Settling TimeL1 JuniorL2 Mid-Level
What if the clock is so fast that one period is not enough settling time? What do you change?
2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
MTBF grows exponentially with settling time, so a third flop adds a full period and multiplies MTBF. Compute MTBF from the flop's library data at the worst corner. Add stages until it is far beyond the product lifetime. Each stage also adds one cycle of latency to the crossing.
Self-Check
Tick each key point you covered in your answer.
Half-Truth
"A third flop is always safer, so use three everywhere."
Every stage adds a cycle of latency to each crossing. Add it only where the MTBF calculation needs it.
What People Get Wrong
Common wrong answers and why they fail. Run It shows the wrong belief failing on a real simulator.
Misconception
"A hold violation goes away if we slow the clock down."
Hold compares new data from one edge with capture at that same edge. No period is involved. The twin halves the frequency and the flop still catches the next value early.
Run It
A 50 ps path into a flop whose clock is 500 ps late, at 1000 ps and 2000 ps periods.
period 1000 ps: early=39 period 2000 ps: early=20 FAIL: halving the clock frequency did not fix hold; the period is not in the hold checkSee the Fix
`timescale 1ps/1ps
// One timing path, simulated with real delays (ps). A 4-bit counter launches a new value at
// every edge. The logic delays it by DLY. A capture flop with setup TSU and hold TH samples it
// on a clock that arrives SKEW ps late. Each capture is compared with the value it should get.
module path #(parameter int PERIOD = 1000, DLY = 50, SKEW = 0, TCQ = 300, TSU = 200, TH = 100) ();
logic clk = 0, clk_cap;
logic [3:0] cnt = 0, d = 0, want = 0;
int late = 0, early = 0, window = 0;
time t_d = 0, t_edge = -1000000;
always #(PERIOD/2) clk = ~clk;
assign #(SKEW) clk_cap = clk;
always @(posedge clk) cnt <= #(TCQ) cnt + 1; // launch flop, clock-to-Q
always @(cnt) d <= #(DLY) cnt; // the logic: a pure transport delay
always @(d) begin // hold window: D must not move within TH after the edge
t_d = $time;
if ($time - t_edge < TH) window++;
end
always @(posedge clk_cap) begin // edge k should capture the value launched at edge k-1
t_edge = $time;
if ($time - t_d < TSU) window++; // setup window
if (d == want - 4'd1) late++; // an older value: setup failed
else if (d == want + 4'd1) early++; // the next value: hold failed
want = want + 4'd1;
end
endmodule
module tb;
// The fix: 400 ps more delay on the short path, at the original 1000 ps period.
path #(.PERIOD(1000), .DLY(450), .SKEW(500)) padded ();
initial begin
#40000;
$display("period 1000 ps, path 450 ps: late=%0d early=%0d window=%0d", padded.late, padded.early, padded.window);
if (padded.late + padded.early + padded.window == 0) $display("PASS: delay on the short path fixed hold at full speed");
$finish;
end
endmodule
Prints: period 1000 ps, path 450 ps: late=0 early=0 window=0 PASS: delay on the short path fixed hold at full speed
Misconception
"Setup time is the delay through the flip-flop."
That delay is clock-to-Q. Setup is a window before the edge in which D must not move. Mixing the two puts the wrong number in the inequality.
Source Sutherland, RTL Modeling with SystemVerilog (2017) ch. 8.1.3 Sequential logic clock-to-Q propagation and setup/hold times
Buzzword Without Mechanism
Says "setup is for the max path and hold is for the min path" and stops.
True, but it is a label, not a mechanism. The interviewer next asks which edge each check uses. Someone without the picture cannot answer.