Home / Learn Chip Programming / Timing Diagrams, Setup and Hold
Timing Diagrams, Setup and Hold
Timing diagrams show signals over time. Every bus and chip datasheet uses them.
Theory in plain words
What it is
A timing diagram plots each signal as a horizontal waveform. Setup time is how long data must be stable before the clock edge; hold time is how long after.
Why we use it
If you violate setup or hold, the receiving flip-flop can capture the wrong value or go metastable. Reading timing diagrams is required for I2C, SPI, memory and display interfaces.
How it works
Find the active clock edge. Check that data is stable for tsu before it and th after it. Check the minimum pulse width and the maximum clock frequency in the datasheet.
Where it is used
- SPI modes (CPOL, CPHA)
- Memory and LCD parallel interfaces
- FPGA timing closure
Setup and hold checker
Move the data change into the red window and see the violation. Slow the clock or fix the path delay to repair setup problems; hold violations need extra delay on the data.
| Term | Meaning |
|---|---|
| tsu (setup) | data stable before the clock edge |
| th (hold) | data stable after the clock edge |
| tco (clock to output) | delay from the edge to the output change |
| tpd (propagation delay) | delay through combinational logic |
| Fmax | highest clock: 1 / (tco + tpd + tsu) |
| Duty cycle | percent of the period the clock is high |
- Maximum frequency of a path: f = 1 / (tco + longest logic delay + tsu).
- Fix setup problems with a slower clock or pipelining (split logic with flip-flops).
- Hold problems do not depend on clock speed: add delay or change clocking.
- Datasheet diagrams show min and max values; design for the worst case.
Quick quiz
1. What is hold time?
The data must not change for th after the edge.
2. How do you fix a setup violation?
Give the signal more time or shorten the logic.
Common questions
What is hold time?
Data must remain stable after the clock edge. The data must not change for th after the edge.
How do you fix a setup violation?
Slow the clock or shorten the path. Give the signal more time or shorten the logic.