Byte Rex
Flip-Flop Setup/Hold Margin Calculator

Flip-Flop Setup and Hold Timing

Field: Digital Logic / Computer Engineering

Written and maintained by the PhDino author · Last reviewed 21 September 2026 · Checked against 1 independent reference calculation · how PhDino checks its numbers

The two timing checks that determine whether a synchronous digital circuit will actually work at a given clock speed.

A flip-flop only reliably captures the data at its input if that data has been stable for a minimum time before the clock edge (setup time) and remains stable for a minimum time after the clock edge (hold time). If either requirement is violated, the flip-flop can enter an unpredictable, unstable state (metastability) instead of cleanly capturing a 0 or a 1 — a real failure mode in synchronous digital design, not just a theoretical concern.

Setup checking asks whether data arrives early enough: starting from one clock edge, data has to travel through a launching flip-flop's own clock-to-Q delay, then through any combinational logic between the two flip-flops, and still arrive with enough time left before the next clock edge to satisfy the receiving flip-flop's setup requirement. Hold checking is different in character: it asks whether data changes too soon after the clock edge that just captured the previous value, which is why hold checks depend on the fastest (not slowest) path delay and don't involve the clock period at all.

Key formula

Setup margin = clock period − (clock-to-Q delay + combinational delay + setup time)
Hold margin = (clock-to-Q delay + combinational delay) − hold time
No. 092 / 092Digital Logic / Computer Engineering
Flip-Flop Setup/Hold Margin
Presented by Byte Rex · Digital Logic & Computing
No. 092 / 092Flip-Flop Setup/Hold Margin
Setup margin = clock period − (clock-to-Q delay + combinational delay + setup time)
Hold margin = (clock-to-Q delay + combinational delay) − hold time
clock-to-Q
delay from a clock edge to the launching flip-flop's output actually changing
Worked example
Clock Period: 10 ns · Clock-to-Q Delay: 1 ns · Combinational Logic Delay: 5 ns
→ Setup Margin: 3.5 ns
Checked: this exact example is one of the automated reference tests, its answer worked out independently of the calculator.
phdino.com/calc/flipflop-timing-margin

Variables

clock-to-Q
delay from a clock edge to the launching flip-flop's output actually changing

How to use the Flip-Flop Setup/Hold Margin calculator

Checks whether data launched by one flip-flop reaches the next in time. The setup margin is what is left of the clock period after the clock-to-Q delay, the logic delay and the setup time; the hold margin is how long the new data takes to arrive beyond the hold time. Positive means the check passes.

Use it for one register-to-register path at a time, the same check a static timing tool repeats on every path of a design. It is the quickest way to see whether a clock speed is realistic and which delay is eating the budget.

Clock Period (ns)
The clock period in nanoseconds, 1,000 divided by the frequency in MHz.
Clock-to-Q Delay (ns)
How long the launching flip-flop takes to change its output after the clock edge, from its datasheet.
Combinational Logic Delay (ns)
The delay through the logic between the two flip-flops. For the setup check use the slowest path; see the note on hold below.
Flip-Flop Setup Time (ns)
How long before the clock edge the data must be stable at the capturing flip-flop.
Flip-Flop Hold Time (ns)
How long after the clock edge the data must stay stable at the capturing flip-flop.

Worked example: a register-to-register path at 200 MHz

A path in a design clocked every 5 ns (200 MHz). The flip-flops have a clock-to-Q delay of 0.6 ns, a setup time of 0.5 ns and a hold time of 0.3 ns, and the logic between them takes 3.6 ns on its slowest path. Does the path meet timing?

You enterValue
Clock Period5 ns
Clock-to-Q Delay0.6 ns
Combinational Logic Delay3.6 ns
Flip-Flop Setup Time0.5 ns
Flip-Flop Hold Time0.3 ns
The calculator returnsValue
Setup Margin0.3 ns
Hold Margin3.900 ns

Worked by hand:

  1. Time used. Data leaves the first flip-flop 0.6 ns after the edge, spends 3.6 ns in logic and must be ready 0.5 ns before the next edge: 4.7 ns in all.
  2. Setup margin. 5 − 4.7 = 0.30 ns. Positive, so the data arrives in time.
  3. Hold margin. The new data must not reach the second flip-flop until 0.3 ns after the edge: 0.6 + 3.6 − 0.3 = 3.90 ns.
  4. Fastest clock for this path. 1,000 ÷ 4.7 = 213 MHz, before any allowance for skew or jitter.

The path passes setup with 0.30 ns to spare, which is thin: clock jitter and skew between the two flip-flops can easily take a few tenths of a nanosecond, and this calculator does not subtract them. The hold check passes comfortably here, but only because it used the same slow logic delay. A real hold check uses the shortest path; if one flip-flop fed the next through a plain wire, the margin would be just 0.6 − 0.3 = 0.3 ns.

Reading the result: two checks pulling opposite ways

A negative setup margin means the data arrives after the window closes at this clock speed: slow the clock, shorten the logic or add a register stage. A negative hold margin is worse, because slowing the clock does not fix it. The new data races through too fast and spoils the value being captured.

  • Setup margin depends on the clock period; hold margin does not. That is why a hold problem persists at any frequency and is fixed by adding delay to the short path.
  • Use the slowest logic delay for the setup check and the fastest for the hold check. Datasheets and timing tools give both.
  • Clock skew shifts both checks. If the capturing flip-flop gets its clock later than the launching one, setup gains time and hold loses it.
  • Timing tools call the margin slack, and a static timing analysis repeats this check on every path in the design.

Notes & limitations

  • Both margins need to be positive for the design to work reliably — a negative setup margin means the clock is running faster than the logic can keep up with; a negative hold margin means data is changing too soon, which no amount of slowing the clock down can fix (hold violations are a same-cycle problem, independent of clock speed).
  • This is a simplified single-number model — a rigorous timing analysis uses separate maximum-delay and minimum-delay values for the combinational path (since the true worst case for setup and the true worst case for hold generally come from different physical paths) and also accounts for clock skew (the clock arriving at the two flip-flops at slightly different times), neither of which this simplified version includes.

Common mistakes

  • Using the same logic delay for setup and hold. The setup check needs the longest path, the hold check the shortest, and the two are often far apart.
  • Forgetting the clock-to-Q delay, which is easy to overlook because it happens inside the flip-flop.
  • Treating a small positive margin as safe. Jitter, skew, temperature and supply voltage all shave it, so designs keep a guard band.
  • Trying to cure a hold violation by lowering the clock frequency. The hold check has no clock period in it.

Frequently asked questions

What happens when setup or hold is violated?

The flip-flop may capture the wrong value or go metastable, hovering between 0 and 1 for an unpredictable time before settling. Either can corrupt data further down the line.

How do I fix a negative setup margin?

Lower the clock frequency, reduce the logic on the path, use faster parts, or split the logic with an extra register (pipelining), which adds a cycle of latency but shortens each stage.

How do I fix a negative hold margin?

Add delay to the short path, for example with buffer cells, or reduce the clock skew. Changing the clock frequency does not help.

What is the maximum clock frequency of a path?

The reciprocal of its minimum period: clock-to-Q plus logic delay plus setup time, before allowing for skew and jitter. For the path above that is 213 MHz.

Further reading

PhDino earns a commission on qualifying purchases made through this link, at no extra cost to you.

Code: The Hidden Language of Computer Hardware and Software by Charles Petzold — Builds from switches and logic gates up to a working computer, one clear step at a time. (Bookshop.org UK, UK delivery only)

→ The full PhDino bookshelf on Bookshop.org (UK delivery only)

Educational tool — not a substitute for a licensed engineer or the official code text.