1. Why Latches and Flip-Flops Exist
Combinational circuits such as adders and multiplexers produce outputs that depend only on their present inputs. Real systems also need memory: counters, registers and processors must remember earlier values. The basic one-bit memory elements are latches and flip-flops. Both are bistable, meaning they have two stable states (0 and 1), but they differ in when they are allowed to change.
2. What Is a Latch in Digital Electronics?
A latch in digital electronics is a bistable circuit whose output depends on its inputs and its previous state. A latch is level-sensitive: while its enable input is active it is transparent and can change, and when enable is inactive it holds ("latches") the stored value.
The common types of latches in digital electronics are:
- SR latch (NOR-based or NAND-based)
- Gated SR latch (SR latch with an enable input)
- D latch (transparent latch, no forbidden state)
- JK and T latches (rare, because of the race problem)
3. SR Latch: NOR and NAND Versions
The SR (Set-Reset) latch is the simplest memory circuit. It is made from two cross-coupled gates, so each output feeds the other gate's input.
Figure 1: NOR-based SR latch. S sets Q to 1, R resets Q to 0.
Truth Table: NOR-Based SR Latch
| S | R | Q (next) | Q' (next) | Operation |
|---|---|---|---|---|
| 0 | 0 | Q (previous) | Q' (previous) | Hold |
| 0 | 1 | 0 | 1 | Reset |
| 1 | 0 | 1 | 0 | Set |
| 1 | 1 | 0 | 0 | Invalid (forbidden) |
Truth Table: NAND-Based SR Latch (Active-Low)
| S' | R' | Q (next) | Operation |
|---|---|---|---|
| 0 | 0 | 1 (and Q' = 1) | Invalid (forbidden) |
| 0 | 1 | 1 | Set |
| 1 | 0 | 0 | Reset |
| 1 | 1 | Q (previous) | Hold |
The Forbidden State
In the NOR latch, S = R = 1 forces both outputs to 0, so Q and Q' are no longer complements. If S and R then return to 0 together, the final state is unpredictable. Designers avoid this input combination.
4. Gated SR Latch and D Latch
A gated SR latch adds an enable input (EN). When EN = 0 the latch ignores S and R and holds its state. When EN = 1 it behaves as a normal SR latch.
The D latch removes the forbidden state by deriving R from S through an inverter (S = D, R = D'). Only one input, D, is needed.
| EN | D | Q (next) | Operation |
|---|---|---|---|
| 0 | X | Q (previous) | Hold (opaque) |
| 1 | 0 | 0 | Transparent, Q follows D |
| 1 | 1 | 1 | Transparent, Q follows D |
Transparent Latch
While EN = 1 the D latch is transparent: any change on D passes straight to Q. This is why a latch is called level-sensitive.
5. What Is a Flip Flop?
A flip flop is a bistable memory element that changes state only on a clock edge: the rising (positive) edge or the falling (negative) edge. Between edges it ignores changes at its inputs. This edge-triggering lets the many flip-flops in a processor change in step with a shared clock.
Figure 2: Block symbols of the SR, D, JK and T flip-flops. The small triangle marks an edge-triggered clock input.
6. Latch vs Flip-Flop: Key Differences
Figure 3: The latch (red) follows D for the whole time it is transparent, while the flip-flop (green) updates only at rising clock edges.
| Feature | Latch | Flip-Flop |
|---|---|---|
| Trigger | Level-sensitive (enable) | Edge-triggered (clock edge) |
| Output changes | Any time enable is active | Only at the clock edge |
| Built from | Cross-coupled gates | Two latches (master-slave) or edge-detect logic |
| Clock | Enable / gate signal | Clock signal |
| Speed and area | Faster, fewer transistors | Slightly larger and slower |
| Timing analysis | Harder (time borrowing) | Simple, synchronous |
| Typical use | Storage, debouncing, address latching | Registers, counters, state machines |
7. SR Flip-Flop
The SR flip-flop is a clocked version of the SR latch. At the active edge it sets (S = 1), resets (R = 1) or holds (S = R = 0). S = R = 1 remains forbidden.
| S | R | Q(next) | Action |
|---|---|---|---|
| 0 | 0 | Q | No change |
| 0 | 1 | 0 | Reset |
| 1 | 0 | 1 | Set |
| 1 | 1 | X | Invalid |
Characteristic Equation
8. D Flip-Flop
The D flip-flop (data or delay flip-flop) copies D to Q at the active clock edge. It is the most used flip-flop because it has one input and no forbidden state.
| D | Q(next) | Action |
|---|---|---|
| 0 | 0 | Reset |
| 1 | 1 | Set |
Characteristic Equation
9. JK Flip-Flop and Race-Around
The JK flip-flop improves the SR flip-flop by giving the J = K = 1 case a useful meaning: toggle.
| J | K | Q(next) | Action |
|---|---|---|---|
| 0 | 0 | Q | Hold |
| 0 | 1 | 0 | Reset |
| 1 | 0 | 1 | Set |
| 1 | 1 | Q' | Toggle |
Characteristic Equation
Figure 4: JK flip-flop state diagram showing hold, set, reset and toggle.
Race-Around Condition
With J = K = 1 and a level-triggered clock that stays high longer than the gate delay, the output toggles over and over during one pulse and ends in an unpredictable state. Use a master-slave or edge-triggered JK flip-flop to avoid it.
10. T Flip-Flop
The T (toggle) flip-flop holds its state when T = 0 and toggles on each active edge when T = 1. It is a JK flip-flop with J and K tied together.
| T | Q(next) | Action |
|---|---|---|
| 0 | Q | Hold |
| 1 | Q' | Toggle |
Characteristic Equation
With T = 1 the output frequency is half the clock frequency, so a T flip-flop is a divide-by-2 circuit and the basis of binary counters.
11. Master-Slave Flip-Flop
A master-slave flip-flop connects two latches in series with opposite clock phases. The master captures the input while the clock is low, and the slave copies the master while the clock is high. The output therefore changes only at the clock transition.
Figure 5: A D flip-flop built as a master-slave pair of D latches.
12. Characteristic and Excitation Tables
The excitation table tells you which inputs are needed to move from the present state Q to the next state Q(next). It is used to design counters and state machines. X means don't care.
| Q | Q(next) | S R | D | J K | T |
|---|---|---|---|---|---|
| 0 | 0 | 0 X | 0 | 0 X | 0 |
| 0 | 1 | 1 0 | 1 | 1 X | 1 |
| 1 | 0 | 0 1 | 0 | X 1 | 1 |
| 1 | 1 | X 0 | 1 | X 0 | 0 |
| Flip-flop | Characteristic equation | Behaviour |
|---|---|---|
| SR | Q+ = S + R'Q | Set, reset, hold (S=R=1 invalid) |
| D | Q+ = D | Copies input |
| JK | Q+ = JQ' + K'Q | Set, reset, hold, toggle |
| T | Q+ = T ⊕ Q | Hold or toggle |
13. Applications and Which to Use
Registers and Memory
Groups of D flip-flops store multi-bit words.
Counters
T and JK flip-flops chain together to count in binary.
Frequency Division
A T flip-flop halves the clock frequency each stage.
Switch Debouncing
An SR latch cleans up bouncing mechanical contacts.
Synchronisers
Cascaded D flip-flops pass asynchronous signals safely into a clock domain.
State Machines
Flip-flops hold the present state of a sequential circuit.
Rule of Thumb
Use D flip-flops for most synchronous design, T for counters and dividers, JK when you need set, reset and toggle, and an SR latch for simple asynchronous storage.
Quick Summary: Latches vs Flip-Flops
| Element | Trigger | Next state |
|---|---|---|
| SR latch | Level | S sets, R resets |
| D latch | Level (EN) | Q = D when EN = 1 |
| SR / D / JK / T flip-flop | Clock edge | See characteristic equations |
Frequently Asked Questions (FAQ)
A latch is a basic bistable memory circuit that stores one bit. It is level-sensitive: its output can change whenever its enable (or control) input is active, and it holds its value when enable is inactive. The simplest form is the SR latch built from two cross-coupled NOR or NAND gates.
A flip-flop is a bistable circuit that stores one bit and changes its output only on a clock edge, either the rising or the falling edge. This edge-triggered behaviour makes flip-flops the building block of registers, counters and synchronous sequential circuits.
A latch is level-sensitive and is transparent while its enable input is active, so the output can follow the input for the whole enable period. A flip-flop is edge-triggered and samples its input only at a clock edge, so the output changes once per clock cycle. Flip-flops are usually built from two latches in a master-slave arrangement.
The main types of latches are the SR latch (NOR or NAND based), the gated SR latch, the D latch (transparent latch) and, less commonly, the JK and T latches. The SR latch is the fundamental one, the gated SR latch adds an enable input, and the D latch removes the forbidden state.
The four standard flip-flops are SR, D, JK and T. SR sets and resets, D copies its input, JK extends SR by toggling when both inputs are 1, and T toggles on every clock edge when T is 1. Each is described by a truth table, a characteristic equation and an excitation table.
In a NOR-based SR latch, S = 1 and R = 1 forces both outputs to 0, which breaks the rule that Q and Q' are complements. When both inputs return to 0 together, the final state is unpredictable because of a race between the gates. This input combination is therefore avoided.
If a level-triggered JK flip-flop has J = K = 1 and the clock stays high longer than the propagation delay, the output toggles repeatedly during that single clock pulse. The final state is unpredictable. It is solved with a master-slave or edge-triggered JK flip-flop.
SR: Q(next) = S + R'Q with SR = 0. D: Q(next) = D. JK: Q(next) = JQ' + K'Q. T: Q(next) = T XOR Q. These equations give the next state in terms of the inputs and the present state.
To make a T flip-flop, tie J and K together and use that line as T. To make a D flip-flop, connect D to J and connect an inverter from D to K. These conversions use the characteristic equation of the JK flip-flop.
A master-slave flip-flop uses two latches in series with opposite clock phases. The master is enabled while the clock is one level and the slave while it is the other, so the output changes only at the clock transition. It prevents the race-around condition and gives edge-like behaviour.
A D latch passes D to Q the whole time its enable is high, so Q can change several times during one enable pulse. A D flip-flop captures D only at the clock edge and holds it until the next edge. Use latches for simple storage and flip-flops for synchronous design.
Flip-flops are used in registers, counters, shift registers, frequency dividers, finite-state machines and synchronisers. Latches are used in switch debouncing, simple data storage, address latching and as the internal cells of flip-flops and some memory circuits.