Latch vs Flip-Flop (Complete Explanation with Math Examples)
1. Main Difference
| Feature | Latch | Flip-Flop |
|---|---|---|
| Triggering | Level-sensitive | Edge-sensitive |
| Control Signal | Enable (EN) | Clock (CLK) |
| Output Change | Changes whenever Enable is active | Changes only at clock edge |
| Complexity | Simpler | More complex |
| Speed | Usually faster | Slightly slower |
| Typical Use | Temporary storage | Synchronous digital systems |
2. Visual Timing Concept
Latch (Transparent While Enable=1)
When Enable = 1, output follows input immediately. When Enable = 0, output holds previous value.
Flip-Flop (Updates Only on Clock Edge)
Output changes only at rising clock edges. Between clock edges, Q remains constant.
3. Mathematical Model of a D-Latch
D-Latch equation:
Where:
- EN = Enable signal
- D = Data input
- Q(t) = Current state
- Q(t+1) = Next state
Example
Given:
D = 0
Q(t) = 1
Substitute:
Result: Q becomes 0.
Latch Hold Example
D = 1
Q(t) = 0
Even though D=1, output remains 0 because Enable is inactive.
4. Mathematical Model of a D Flip-Flop
At a clock edge:
The output simply copies D at the triggering edge.
Example Sequence
| Clock Edge | D | Q After Edge |
|---|---|---|
| 1 | 0 | 0 |
| 2 | 1 | 1 |
| 3 | 1 | 1 |
| 4 | 0 | 0 |
Notice that Q changes only at clock edges, not continuously.
5. SR Latch Mathematical Example
SR Latch equations:
Q' = R + S'Q'
Case 1
R=0
Output is SET.
Case 2
R=1
Output is RESET.
Case 3
R=0
Output holds previous value.
Case 4 (Invalid)
R=1
Both outputs become contradictory. This state is forbidden in a basic SR latch.
6. Why Flip-Flops Are Built from Latches
A common edge-triggered flip-flop uses:
- Master Latch
- Slave Latch
The master captures data during one clock level and the slave updates during the opposite level. Together they create edge-triggered behavior.
7. Final Summary
- Latch: Level-sensitive memory element.
- Flip-Flop: Edge-sensitive memory element.
- Latch Equation: Q(t+1)=EN·D + EN'·Q(t)
- D Flip-Flop Equation: Q(t+1)=D (at clock edge only)
- Flip-flops provide predictable synchronous operation.
- Modern CPUs, registers, counters, and state machines mainly use flip-flops.