3.4.5Sequential Circuits

Setup and hold time constraints

1,936 words9 min readdifficulty · medium6 backlinks

WHAT are we constraining?

WHY these exist: a real flip-flop is built from feedback loops (cross-coupled gates). The loop needs time to acquire the input and regenerate it into a stable state. Violate the window → the loop can hang half-way between 0 and 1 = metastability.


The pipeline picture (deriving the constraints)

Consider two flip-flops in a pipeline separated by combinational logic:

FF1 --Q--> [ combinational logic ] --D--> FF2
  ^                                          ^
  |------------------ CLK --------------------|
Figure — Setup and hold time constraints

Data leaves FF1 on a clock edge, travels through logic, and must arrive at FF2 in time for the next edge (setup) but not too early to disturb the current edge (hold).


Deriving the SETUP constraint (from first principles)

HOW: Track the arrival time of the new data at FF2's D, relative to the next clock edge.

Let the clock period be TT. Assume the launching edge is at time 00; the capturing edge at FF2 is at time TT (ignore clock skew for now).

  1. Data becomes valid at FF1's Q at time = tcqt_{cq} (worst case tcqmaxt_{cq}^{max}).
  2. It passes through logic taking tlogicmaxt_{logic}^{max}. It arrives at FF2's D at: tarrive=tcqmax+tlogicmaxt_{arrive} = t_{cq}^{max} + t_{logic}^{max}
  3. FF2 requires D stable tsut_{su} before its edge at TT, i.e. arrival must be Ttsu\le T - t_{su}.

WHY the subtraction? We must reserve the last tsut_{su} seconds of the period for FF2's "keep-still" window, so nothing may still be arriving there.

tcqmax+tlogicmax+tsuT\boxed{\,t_{cq}^{max} + t_{logic}^{max} + t_{su} \le T\,}


Deriving the HOLD constraint (from first principles)

WHY a second constraint? Setup worries about data arriving too late for the next edge. Hold worries about new data arriving too early and corrupting the value FF2 is trying to latch on this same edge.

Same edge at time 00 launches from FF1 and captures at FF2:

  1. Fastest possible change at FF1's Q after the edge: tcqmint_{cq}^{min}.
  2. Fastest path through logic: tlogicmint_{logic}^{min} (contamination delay).
  3. So FF2's D could start changing as early as tcqmin+tlogicmint_{cq}^{min} + t_{logic}^{min} after the edge.
  4. FF2 needs D held stable until tht_h after the edge. So the earliest change must be th\ge t_h:

tcqmin+tlogicminth\boxed{\,t_{cq}^{min} + t_{logic}^{min} \ge t_h\,}


Adding clock skew

Let the capturing clock arrive at FF2 later than the launching clock by skew tskewt_{skew} (positive = capture clock delayed).

  • Setup gets easier (more time before the delayed capture edge): T+tskewtcqmax+tlogicmax+tsuT + t_{skew} \ge t_{cq}^{max} + t_{logic}^{max} + t_{su}
  • Hold gets harder (the delayed edge extends the keep-still window into the fast data): tcqmin+tlogicminth+tskewt_{cq}^{min} + t_{logic}^{min} \ge t_h + t_{skew}

Worked Examples


Recall Feynman: explain to a 12-year-old

Imagine you're passing a note to a friend right when the teacher claps. If you shove the note too late, your friend hasn't grabbed it before the clap — they read garbage (setup problem: give them the note earlier or clap slower). If you snatch the note back too fast right after the clap, your friend never finished reading it (hold problem: hold the note a moment longer — clapping slower doesn't help, you just have to hold it). The tiny "please don't move the note" moment around each clap is the flip-flop's keep-still window.


Flashcards

Setup time definition
Minimum time data must be stable BEFORE the active clock edge for correct sampling.
Hold time definition
Minimum time data must remain stable AFTER the active clock edge.
Setup constraint formula
Ttcqmax+tlogicmax+tsuT \ge t_{cq}^{max} + t_{logic}^{max} + t_{su}
Hold constraint formula
tcqmin+tlogicmintht_{cq}^{min} + t_{logic}^{min} \ge t_h
Which constraint limits max clock frequency?
Setup (it contains TT); fmax=1/(tcqmax+tlogicmax+tsu)f_{max}=1/(t_{cq}^{max}+t_{logic}^{max}+t_{su}).
Why can't slowing the clock fix a hold violation?
Hold constraint has no TT term; it's a same-edge race, so period cancels. Fix by adding delay/buffers.
Setup uses which delays?
Maximum (worst-case) delays: tcqmaxt_{cq}^{max}, tlogicmaxt_{logic}^{max}.
Hold uses which delays?
Minimum (contamination/fastest) delays: tcqmint_{cq}^{min}, tlogicmint_{logic}^{min}.
Effect of positive capture-clock skew on setup?
Relaxes it: T+tskewtcqmax+tlogicmax+tsuT + t_{skew} \ge t_{cq}^{max}+t_{logic}^{max}+t_{su}.
Effect of positive capture-clock skew on hold?
Tightens it: tcqmin+tlogicminth+tskewt_{cq}^{min}+t_{logic}^{min} \ge t_h + t_{skew}.
What happens if the keep-still window is violated?
Metastability — the output may hover between 0 and 1 unpredictably.
What is tcqt_{cq}?
Clock-to-Q delay: time from clock edge until Q outputs the new value.
How to fix a hold violation?
Add buffer/delay elements on the fast (min-delay) combinational path.

Connections

Concept Map

built from feedback loops

D changes inside

defines start of

defines end of

stable before edge

stable after edge

delay from edge to Q

adds to

max delay adds to

reserved before edge

T >= tcq+tlogic+tsu

slow clock to fix

min delay used in

must hold after edge

Flip-Flop as camera

Metastability

Setup time t_su

Hold time t_h

Clock-to-Q delay t_cq

Keep-still window [-t_su, +t_h]

Combinational logic delay

Setup constraint

Max clock frequency

Hold constraint

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, ek flip-flop basically clock edge par apne D input ka "photo" leta hai. Agar photo lete waqt data hil raha hai, toh photo blur ho jaata hai — isko metastability bolte hain. Isse bachne ke liye data ko clock edge se thoda pehle stable hona chahiye (yeh setup time tsut_{su} hai) aur edge ke thoda baad tak bhi stable rehna chahiye (yeh hold time tht_h hai). Matlab har clock edge ke around ek chhota "hilna mana hai" window hota hai.

Ab do flip-flops ke beech combinational logic hoti hai. Data FF1 se nikalta hai (tcqt_{cq} ke baad), logic se guzarta hai (tlogict_{logic}), aur FF2 tak pahuchta hai. Setup constraint kehti hai ki data agle edge se pehle pahunch jaaye: Ttcqmax+tlogicmax+tsuT \ge t_{cq}^{max}+t_{logic}^{max}+t_{su}. Isse tumhara maximum clock frequency decide hota hai — agar setup fail ho raha hai, toh clock slow kar do, kaam ban jaata hai.

Hold constraint thodi tricky hai: tcqmin+tlogicmintht_{cq}^{min}+t_{logic}^{min} \ge t_h. Isme dekho TT hai hi nahi! Kyunki hold same edge ke andar ka race hai — naya fast data purane value ko corrupt na kar de. Isliye hold violation ko clock slow karke kabhi theek nahi kar sakte. Fix karna hai toh fast path par buffers/delay add karo. Yaad rakho: Setup = MAX delays, Hold = MIN delays.

Ek important baat — clock skew. Agar capture clock late aaye (positive skew), toh setup easy ho jaata hai par hold aur mushkil ho jaata hai. Isliye "skew badhao aur speed lo" wali soch dangerous hai; woh hold violations create kar deta hai jinko koi frequency change theek nahi karega. Balance zaroori hai.

Go deeper — visual, from zero

Test yourself — Sequential Circuits

Connections