By combining logic gates like AND, OR, and NOT, we can build a calculator that adds. But this calculator has a big limitation: it can’t remember its results. When the input changes, the output changes right away, and nothing of the previous input is left.
Think of a light switch that turns on when you press it and off when you press it again. The circuits we have built so far can’t make such a switch, because deciding the new state requires remembering the light’s previous state.
How can a circuit remember a value? The key is feedback, where a circuit’s output loops back into its input. With it, we can build the simplest memory device, the SR latch.
The NOR gate, which we briefly saw in the NAND post, inverts the result of OR, so it outputs 1 only when both inputs are 0. Click A and B to check.
An SR latch can be built from just two of these NOR gates.
Click S and R to toggle their values. Try these steps in order:
S (Set) makes the latch remember 1, and R (Reset) makes it remember 0. Q is the remembered value, and Q̅ is always its opposite.
| S | R | Q | Q̅ | Action |
|---|---|---|---|---|
| 0 | 0 | Previous state | Previous state | Hold |
| 0 | 1 | 0 | 1 | Reset |
| 1 | 0 | 1 | 0 | Set |
| 1 | 1 | Unstable | Unstable | Forbidden |
In the truth tables we’ve seen so far, the inputs alone determined a single output. This table has a previous state entry. Even with the same S=0, R=0, Q depends on what was remembered before.
The trouble comes when S and R are both 1 at the same time. Both NOR gates output 0, breaking the rule that “Q and Q̅ are always opposite.”
Switching back to S=0, R=0 from this state is even worse. Each NOR now just inverts the other’s output, so both try to become 1. But as soon as one of them becomes 1 first, that 1 goes into the other NOR, forces its output to 0, and the latch settles there. So Q is decided by whichever gate reacts even slightly faster.
In a real circuit, that tiny difference in speed can’t be known in advance. A situation like this is called a race condition, and its result is unpredictable.
In the next post, let’s build a D latch that keeps these forbidden inputs from ever coming in.
Suppose the two gates of an SR latch built from two NORs react at exactly the same speed, at the same time. With S=R=1, both Q and Q̅ are 0. If S and R drop to 0 at the same time, what happens to Q?