Imagine a sports photographer trying to capture a sprinter at the exact moment of crossing the finish line using a flash burst (the clock edge). For the picture to come out sharp and not blurry, the sprinter must get into pose and be steady just before the flash fires (the setup time), and stay in the same position for a split second even after the flash goes off (the hold time). If the sprinter moves exactly while the shutter is open and the exposure window is taking place, the picture will come out smeared and completely blurry, and the photographer will not be able to tell for sure on which side of the line the sprinter was. This blurry state is exactly equivalent to metastability, in which the system loses its direction and is unable to decide on an unambiguous outcome.
In the world of digital circuits, flip-flops sample data signals according to the edge of the clock signal (the clock edge). To guarantee reliable sampling, the data at the input \((D)\) must be absolutely stable within a critical time window defined by two parameters: the Setup time \((t_{su})\), which determines how long before the clock rises the signal must be stable, and the Hold time \((t_{h})\), which determines how long after the clock rises the signal must remain unchanged.
A violation of this window causes metastability – a state in which the flip-flop output gets stuck at an intermediate value between '0' and '1' and settles randomly only after an unknown period of time, which leads to logic errors and to nondeterminism in the system.
In addition to the flip-flop, every logic gate has delay times that characterize its response: the contamination delay \((t_{cd})\), which is the absolute minimum time until the output starts to change following a new input, and the propagation delay \((t_{pd})\), which is the maximum time until the output finishes changing and fully settles to its new value. For the flip-flop itself, these values are denoted \(t_{ccq}\) and \(t_{pcq}\) respectively (the times from the rising clock edge until the initial change or the final settling of the output \(Q\)), and they form the basis for the critical-path equations of the whole circuit.
The green line. Its rising edge (the step up) is the moment the flip-flop samples.
The blue line. Grab its step with the mouse and drag it left and right.
The orange line. It is drawn behind the laser marker while sampling.
\(t_{su}\) before the clock rises. A transition of D inside it is a Setup violation.
\(t_{h}\) after the clock rises. A transition of D inside it is a Hold violation.
Sweeps the screen from left to right after "Fire sample". When it hits the rising clock edge, the flip-flop samples D.
\(t_{ccq}\): Q starts to respond. \(t_{pcq}\): Q has settled. The arrows measure the time from the rising clock edge.
The two wells are the logic values '0' and '1'. The peak in the middle is an unstable intermediate state.
The state of the output Q. Inside a well: a valid value. On the peak, vibrating and throwing sparks: metastability.
Q is stuck between '0' and '1' and does not decide.
\(t_{pcq}\) in real time. During metastability it only grows, until Q settles.