← RTL Design Interviews

Interview Question · Concept

Setup and Hold from First Principles

L0 FresherL1 JuniorL2 Mid-Leveltimingsetup holdsta
  • 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.

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.

One Clock Period, Two Flops, a Long Path and a Short OneArrows carry data from the launch flop to the capture flop, and the clock to both. The long path is the adder's carry chain; the short path is any path with one cell.
One clock period, two flops, a long path and a short oneArrows carry data from the launch flop to the capture flop, and the clock to both. The long path is the adder's carry chain; the short path is any path with one cell. clock clk edge k, then edge k+1one period later flop launch flop Q changes clock-to-Qafter edge k logic long path: 21levels input a[0] throughthe carry chain logic short path: 1level settles soon afterany edge flop capture flop D stable from setupbefore edge k+1 tohold after it edge kQDQDedge k+1
  1. 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
    1. call edge k: clk → launch flop
  2. 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
    1. data new value: launch flop → long path: 21 levels
    2. data new value: long path: 21 levels → capture flop
  3. 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
    1. call edge k+1: clk → capture flop
  4. 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
    1. data new value: launch flop → short path: 1 level
    2. 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.

CheckMust be true (zero skew)Fails when
SetupTcq + Tlogic_max + Tsetup <= Tperiodthe logic is too slow for the period
HoldTcq + Tlogic_min >= Tholdnew 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.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: 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=0

Self-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.

Cross-Questions

Where the interviewer goes next. Open a node to practise that follow-up.

WhyWhat IfProve ItBreak ItCompare

  1. Setup and Hold from First Principles
  2. WhyWhy the Period Is Not in the Hold CheckL1 Junior

    Why does the clock period not appear in the hold check?

    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

  3. What IfThe Hold Check After a Multicycle ExceptionL2 Mid-Level

    What if you add set_multicycle_path 2 -setup to a path? What happens to its hold check?

    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 2 with -hold 1, which moves hold back to the launch edge.

    Where the Setup and Hold Edges SitData launched by a at edge 0. A 1 marks the edge each check uses.
    0123clkena (launched)D0D1setup, defaultsetup, -setup 2hold, -setup 2 onlyhold, plus -hold 1
    1. Cycle 0

      By default, setup is checked at edge 1 and hold at edge 0, the launch edge itself.

    2. Cycle 1

      With -setup 2 alone, hold moves to edge 1. D0 must stay stable for a whole period after launch.

    3. Cycle 2

      Setup is at edge 2, where y loads. -hold 1 brings 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 1 gives 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

  4. CompareFixing Setup Versus Fixing HoldL1 JuniorL2 Mid-Level

    Compare how you fix a setup violation with how you fix a hold violation.

    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.

    ff1 → ff2hold check, earliest arrival2 cells

    • Clock latency
    • Cell delay
    • Hold time
    The shift register with a delay cell00.10.20.30.40.50.60.70.8time (ns)launch and capture clk ↑Data arrivesRequired afterff1/CLK → ff1/Q (dfxtp_1): 0.3123 ns1 dfxtp_1hd1/A → hd1/X (dlygate4sd3_1): 0.5205 ns2 dlygate4sd3_1clock 0.3818 nshold −0.0326 nsslack +0.4835 ns · metarrival 0.8327required 0.3492The shift register with a delay cell00.20.40.60.8time (ns)launch and capture clk ↑Data arrivesRequired afterff1/CLK → ff1/Q (dfxtp_1): 0.3123 ns1 dfxtp_1hd1/A → hd1/X (dlygate4sd3_1): 0.5205 ns2 dlygate4sd3_1clock 0.3818 nshold −0.0326 nsslack +0.4835 ns · metarrival 0.8327required 0.3492
    1. The delay cell

      hd1 adds 0.5205 ns to the fastest path.

    2. 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).

    CellArcThroughEdgeDelay (ns)Time (ns)Slew (ns)
    1ff1/CLK → ff1/Qdfxtp_1rise0.31230.31230.0333
    ff1/Q → hd1/Awire q1rise0.00000.31230.0333
    2hd1/A → hd1/Xdlygate4sd3_1rise0.52050.83270.0451
    hd1/X → ff2/Dwire q1drise0.00000.83270.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)

  5. 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.

    Open Problem R4.5.1

  6. 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?

    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 #1 delays 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

  7. 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?

    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

  8. CompareWhy One Flop Is Not EnoughL0 FresherL1 Junior

    Why is a single flop not enough to synchronize an asynchronous input?

    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.
    0123456clkstatuss1idle_qbusy_q
    1. Cycle 2

      Edge 13: s1 has been 1 since edge 12, and the machine is in BUSY.

    2. 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.

    3. 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.

    4. 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.

  9. 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?

    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.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: 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 check
See 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.

Learn It, Then Prove It