The SR Latch
The previous article explained how two cross-coupled inverters provide two stable states. However, that circuit does not include control inputs to select a state.
This article replaces the inverters with NAND gates. When one input of a NAND gate is logic 0, its output is logic 1 regardless of other inputs. When that input is logic 1, the gate operates as an inverter.
This configuration creates the Set-Reset (SR) latch. The SR latch is a basic memory element that provides controlled data storage.
Circuit Configuration
The SR latch consists of two NAND gates connected in a feedback loop (Figure 1).
The upper NAND gate receives input $\bar{S}$ and feedback signal $\bar{Q}$ to produce output $Q$. The lower NAND gate receives input $\bar{R}$ and feedback signal $Q$ to produce output $\bar{Q}$.
The overbars indicate active-low inputs. Driving $\bar{S}$ to logic 0 sets the latch. In normal operation, output $Q$ and output $\bar{Q}$ are logical complements.
The Four Input Conditions
The truth table for the NAND SR latch contains four operating conditions:
| $\bar{S}$ | $\bar{R}$ | $Q$ | $\bar{Q}$ | Operating Mode |
|---|---|---|---|---|
| 0 | 1 | 1 | 0 | Set |
| 1 | 0 | 0 | 1 | Reset |
| 1 | 1 | Previous $Q$ | Previous $\bar{Q}$ | Hold |
| 0 | 0 | 1 | 1 | Forbidden (Invalid) |
Set Mode
When $\bar{S} = 0$, the upper NAND gate drives output $Q$ to 1. The lower NAND gate receives $\bar{R} = 1$ and $Q = 1$, which forces output $\bar{Q}$ to 0.
This 0 feeds back to the upper gate. Output $Q$ remains 1 even if $\bar{S}$ returns to 1. The latch is set.
Reset Mode
When $\bar{R} = 0$, the lower NAND gate drives output $\bar{Q}$ to 1. The upper NAND gate receives $\bar{S} = 1$ and $\bar{Q} = 1$, which forces output $Q$ to 0. The latch is reset.
Hold Mode
When both inputs are logic 1, both gates operate as inverters. The circuit operates like the cross-coupled inverter pair. It preserves the existing stored state.
Forbidden (Invalid) Mode
When both inputs equal 0, both NAND gates drive their outputs to 1. Outputs $Q$ and $\bar{Q}$ are no longer complementary. The circuit does not represent a valid binary state.
The primary hazard occurs when the circuit exits this mode. If both inputs change from 0 to 1 at the same instant, both gates attempt to drive their outputs low.
Slight differences in propagation delay, supply voltage, or temperature determine which gate changes first. The final state is non-deterministic. Digital systems must prevent the condition $\bar{S} = \bar{R} = 0$.
The NOR Implementation
You can also construct an SR latch using two cross-coupled NOR gates with active-high inputs.
The upper NOR gate receives inputs $S$ and $\bar{Q}$ to produce output $Q$. The lower NOR gate receives inputs $R$ and $Q$ to produce output $\bar{Q}$.
| $S$ | $R$ | $Q$ | $\bar{Q}$ | Operating Mode |
|---|---|---|---|---|
| 0 | 0 | Previous $Q$ | Previous $\bar{Q}$ | Hold |
| 1 | 0 | 1 | 0 | Set |
| 0 | 1 | 0 | 1 | Reset |
| 1 | 1 | 0 | 0 | Forbidden (Invalid) |
The NOR implementation inverts the control logic levels. The hold condition requires $S = R = 0$. The invalid condition occurs when $S = R = 1$, which forces both outputs to 0.
In CMOS technology, NAND gates are faster than NOR gates due to NMOS carrier mobility. Therefore, designers use NAND-based latches more frequently.
Timing Characteristics
The basic SR latch has no clock signal. The outputs change immediately after input transitions, delayed only by gate propagation delays.
When input $\bar{S}$ falls to 0, output $Q$ rises after one NAND propagation delay. Then output $\bar{Q}$ falls after an additional NAND delay (Figure 2).
Because the circuit responds directly to input levels rather than clock edges, this circuit is classified as a latch.
Switch Debouncing Application
Mechanical switches do not make clean electrical contact immediately. Physical contacts bounce for several milliseconds, causing multiple high-frequency voltage transitions before settling.
Digital counters count each contact bounce as a distinct event, causing counting errors.
A single-pole double-throw (SPDT) switch combined with an SR latch removes these contact bounces (Figure 3).
Connect the common terminal of the switch to ground. Connect the two remaining terminals to inputs $\bar{S}$ and $\bar{R}$ with pull-up resistors to $V_{DD}$.
When the switch moves toward the set terminal, the first contact pulls $\bar{S}$ to logic 0. Output $Q$ transitions to logic 1.
Subsequent mechanical bounces cause $\bar{S}$ to disconnect and return to logic 1. This condition is the hold mode. Therefore, output $Q$ remains at logic 1.
The output changes only when the switch moves completely to the opposite terminal and contacts $\bar{R}$. The circuit produces a single clean edge for each switch operation.
Practice Exercises
Problem 1
An SR latch begins with $Q = 0$. The active-low inputs $(\bar{S}, \bar{R})$ apply this sequence:
- $(1,1)$
- $(0,1)$
- $(1,1)$
- $(1,0)$
- $(1,1)$
Determine the value of output $Q$ at each step.
Solution
- Input $(1,1)$ is hold mode: $Q = 0$.
- Input $(0,1)$ is set mode: $Q = 1$.
- Input $(1,1)$ is hold mode: $Q = 1$.
- Input $(1,0)$ is reset mode: $Q = 0$.
- Input $(1,1)$ is hold mode: $Q = 0$.
Problem 2
A NAND SR latch is in the forbidden state with $\bar{S} = 0$ and $\bar{R} = 0$. Both inputs change to logic 1 at the same instant. Explain why the final state cannot be determined.
Solution
During the condition $\bar{S} = \bar{R} = 0$, both outputs $Q$ and $\bar{Q}$ equal logic 1.
When both inputs return to 1, both NAND gates receive two high inputs simultaneously. Both gates attempt to drive their outputs to logic 0.
If the upper gate transitions faster, output $Q$ becomes 0 and forces output $\bar{Q}$ to 1 (reset state). If the lower gate transitions faster, output $\bar{Q}$ becomes 0 and forces output $Q$ to 1 (set state).
Minor variations in gate threshold voltages and propagation delays dictate the outcome. The final output is unpredictable.
Problem 3
Design a set-dominant latch using logic equations. In this latch, applying $S = 1$ and $R = 1$ simultaneously must result in $Q = 1$.
Solution
Disable the reset signal when the set signal is asserted. Using active-high inputs, define an effective reset signal:
$$R_{\text{eff}} = R \cdot \bar{S}$$
When $S = 1$ and $R = 1$, the effective reset signal becomes $R_{\text{eff}} = 0$, allowing the latch to set.
The characteristic equation for the set-dominant latch is:
$$Q_{\text{next}} = S + \bar{R}Q$$
The corresponding equation for a reset-dominant latch is:
$$Q_{\text{next}} = \bar{R}(S + Q)$$
The basic SR latch requires separate control lines and produces an invalid state when both inputs are asserted. The next article introduces the D latch, which eliminates the invalid state by using a single data input.