Metastable Persons

My last column mentioned the metastability problem, which happens when a synchronous circuit attempts to sample an asynchronous signal. You can use the following simple experiments to enhance your understanding of metastability.

You'll need a partner, two nearby light-bulb circuits; and switches, so you and your partner can turn your light bulbs on and off. The object of this experiment is for your partner to make the state of his or her light bulb match yours. That is, when your light bulb goes on, your partner's light bulb goes on, and when your light bulb goes off, your partner's does the same.

The average reaction time should be a few hundred milliseconds with a bell-shaped distribution of values around the average. For most people, the reaction time should never be less than zero (unless your partner can see your face or see your finger begin to move the switch). The reaction time should also have a fixed upper bound after which your partner's light bulb always displays the correct result. This distribution is the normal form of the delay histogram for asynchronous operation.

Now, modify the experiment by introducing a bell. Ring the bell at a regular rate of once every 3 sec. Your partner must now match the state of your light bulb only when the bell rings. You have now made a kind of synchronous circuit, in which the bell acts like a clock symbol.

Provided that you establish the state of your light bulb early in each cycle and hold the state constant to give your partner plenty of time to preview the next new value, the bell-to-output reaction times for your partner will closely track those that you measured in the first experiment. So far, the experiment has produced no unexpected results.

The final experiment introduces a new complication. This time, without warning, just before you ring the bell, you should suddenly change the state of your light bulb, depriving your partner of the normal setup time. Without fail, your partner will stumble over this new problem. You were supposed to provide an adequate setup time, but you didn't. Reaction times for this new test always exceed the reaction times for the previous test. If the light bulb changes state just as the bell rings, some people will delay setting the state of their light bulb. Other people will go one way, then decide they made a mistake and flip back. Reactions vary among subjects, but one thing remains consistent: It always takes longer to get a stable result if you change the state of the light bulb just before the bell rings. If some subsequent circuit were depending on your partner's reaction time, under these conditions, your partner's extra delay might cause a state-machine failure.

Ordinary digital logic works the same way. When you violate the setup-and-hold times on a flip-flop, the output might erratically go high, stay low, or pop one way and then back again. Anything can happen. The extra delay before the flip-flop converges on its final decision is called "metastable resolution time," and the whole subject of what happens when you violate setup-and-hold times is called "metastability."

If you do your job correctly, every data transition within your synchronous machine will occur before the specified setup time for the next stage and will hold stable until the end of the required hold window.

Metastability can hurt your design in areas in which you have to sample a signal from the external world or from an independent clock domain. You have no control over when the sampled data might change from one state to another. Violations of the setup-and-hold times can occur at any moment. These violations often cause an unusually long delay in the output timing of your sampling register, forcing you to design substantial amounts of excess timing margin into the subsequent circuits (Figure 1).

A typical histogram depicts clock-to-Q transition times showing metastable events outside the normal CLK-Q specification
(courtesy EDN Magazine)

A proper respect for flip-flop behavior under this condition will make your designs more reliable and serviceable.

Now turn the lights on and get back to work.