LIMA
With God’s help
עברית

Metastability and Timing

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.

The theory in brief

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.

tsu th CLK D Q tccq tpcq D must be stable inside the red and blue bands Q starts changing at tccq and settles at tpcq

How to read the lab

CLK: the clock signal

The green line. Its rising edge (the step up) is the moment the flip-flop samples.

D: the data signal

The blue line. Grab its step with the mouse and drag it left and right.

Q: the flip-flop output

The orange line. It is drawn behind the laser marker while sampling.

Red band: the Setup window

\(t_{su}\) before the clock rises. A transition of D inside it is a Setup violation.

Blue band: the Hold window

\(t_{h}\) after the clock rises. A transition of D inside it is a Hold violation.

The laser marker

Sweeps the screen from left to right after "Fire sample". When it hits the rising clock edge, the flip-flop samples D.

The guide lines on Q

\(t_{ccq}\): Q starts to respond. \(t_{pcq}\): Q has settled. The arrows measure the time from the rising clock edge.

The energy hill

The two wells are the logic values '0' and '1'. The peak in the middle is an unstable intermediate state.

The orange ball of light

The state of the output Q. Inside a well: a valid value. On the peak, vibrating and throwing sparks: metastability.

Noise cloud on Q

Q is stuck between '0' and '1' and does not decide.

The equation in the corner

\(t_{pcq}\) in real time. During metastability it only grows, until Q settles.

To the lab ↓
Loading the lab...
1

Experiments to try in the lab

  1. The comfort zone experiment (ideal timing). Drag the Data Shift slider so that the transition of the signal (D) from '0' to '1' happens and fully settles to the left of the red band. Fire the sample, watch the ball sliding into the well, and notice the vertical lines \(t_{ccq}\) and \(t_{pcq}\) that appear on the Q output wave.
    This experiment shows the healthy, correct state of the system. When the data settles safely outside the Setup time \((t_{su})\), the internal mechanism of the flip-flop manages to sample it efficiently. The two-dimensional ball is pushed immediately into the correct logic valley, and the delay times – from the initial contamination to the final settling (\(t_{ccq}\) and \(t_{pcq}\)) – are kept at the necessary minimum, with no unnecessary delays.
  2. The Setup trap (sampling while changing). Drag the data change right into the red band. Fire the laser and watch the ball getting stuck on the central peak in the lower panel, and the "noise" effect appearing in the Q wave.
    Here we force a Setup violation on purpose. When the data signal changes inside the critical window before the clock rises, the flip-flop actually samples an intermediate voltage value that is undefined. The physical result is metastability: the ball gets stuck in a precarious equilibrium on the "energy hill", and the flip-flop output is stuck somewhere between logic '0' and '1'. The system is temporarily paralyzed and unable to resolve to a valid value.
  3. Early escape (Hold violation). Place the data so that it settles far before the red band, but change it back unexpectedly right inside the blue band after the clock edge.
    This experiment proves that arriving on time is not enough; the signal must also be preserved after the clock edge (the \(t_{hold}\) time). Changing the signal in the blue window disrupts the component's capture process just before it is completed. Even though the system has already begun to settle, the sudden fluctuation throws it back into a spin and into metastability. The phenomenon highlights that the internal circuit needs a minimal, disturbance-free period of time to finally lock in the data.
  4. The fateful delay (the stretching of \(t_{pcq}\)). Create a timing violation (metastability) again, but this time focus solely on the upper waveform display. Follow the guide line of the settling delay \((t_{pcq})\) while the Q output vibrates unstably.
    During metastability, the output is not deterministic, and it will eventually settle after some random time. In this experiment you can see how the \(t_{pcq}\) line is pushed to the right along the time axis as long as the vibration continues, and does not settle. This illustrates the system-level danger: even if the flip-flop eventually falls randomly to the correct logic value, the long delay may cause the data to arrive late at the next flip-flops in line (a Max Delay path violation), which would lead to the collapse of the processor's operation.
  5. The tolerance test (a virtual component swap). Using the Tolerance slider, widen the red and blue bands around the clock significantly. Now, try again to pass the very same signal from "Experiment 1" that previously worked smoothly, and watch the result.
    Widening the timing windows simulates the use of slower or older silicon hardware, which requires a wider safety margin around the sample. A data signal that was perfectly fine for a fast component now penetrates the danger zones of the new component and causes a severe timing violation. The experiment instills the understanding that the Setup and Hold times are absolute physical properties of the component, and the design of the whole system must be rigidly based on its unique sensitivity specification.