1. The SR latch: memory from feedback
A latch stores one bit by feeding each gate's output back to the other gate's input. It has two stable states, (set) and (reset), with the complement.
NOR SR latch (active-high inputs): , .
| S | R | NOR latch | NAND latch | |||
|---|---|---|---|---|---|---|
| 0 | 0 | hold | 1 | 1 | hold | |
| 1 | 0 | 0 | 1 | |||
| 0 | 1 | 1 | 0 | |||
| 1 | 1 | not allowed: | 0 | 0 | not allowed: |
The NAND latch has active-low inputs, so its hold and forbidden rows are swapped compared with the NOR latch.
The forbidden input is a problem for two reasons: the outputs are no longer complements, and if both inputs then return to the inactive level at the same time, the final state depends on which gate is faster (a race), so it is unpredictable.
Adding an enable (clock) input in front of S and R gives a gated SR latch: the latch responds only while enable is active, and holds otherwise.