Topic 7 of 13
Sequential Logic: Latches & Flip-Flops
Memory for digital circuits: clocks, latches, flip-flops and the timing rules they obey.
← → move between slides · F full screen · M slide list
Before we start
Why this matters
Why does your laptop instantly forget your unsaved essay the moment the power blinks, but remember it perfectly the millisecond before?
Because one bit of memory is really just two logic gates locked in a petty, endless argument, each one only holding its position because the other hasn't backed down yet. Cut the power and the argument — and your essay — is over. This chapter is about how a circuit can stubbornly “remember” anything at all, no sticky notes required.
Outline
Topics in this chapter
Select a topic to jump to the slide that explains it.
Concept 1 of 6
Clocks and synchronous circuits
A sequential circuit stores state, so its output depends on inputs and history. A clock is a periodic square wave with a period T, frequency f = 1/T, rising and falling edges and a duty cycle. In a synchronous circuit all state changes are coordinated by the clock, which makes timing predictable and design easier. In an asynchronous circuit, state can change as soon as an input changes.
Concept 2 of 6
Latches
A latch is level-sensitive: its output can change while its enable is active. An SR latch is two cross-coupled NOR gates. S = 1 sets Q to 1, R = 1 resets it to 0, and S = R = 0 holds. S = R = 1 is invalid for the NOR version, because both outputs go to 0 and the result is unpredictable when the inputs are released. A gated latch adds an enable. A D latch uses one data input, D, which removes the invalid state: while enabled, Q follows D.
Interactive circuit
SR latch from two NOR gates
Click the switches to change the inputs and watch the LEDs. Use “Show truth table” when it appears.
Concept 3 of 6
Flip-flops
A flip-flop is edge-triggered: it samples its inputs only at a clock edge (rising or falling), so it changes state at one precise moment.
| Type | Behaviour |
|---|---|
| D | Q(next) = D |
| JK | 00 hold, 01 reset, 10 set, 11 toggle |
| T | T = 0 hold, T = 1 toggle |
| SR | 00 hold, 01 reset, 10 set, 11 invalid |
A level-triggered JK with J = K = 1 would keep toggling while the clock is high (race-around). A master-slave JK, built from two latches on opposite clock phases, avoids this.
Interactive circuit
D flip-flop
Click the switches to change the inputs and watch the LEDs. Use “Show truth table” when it appears.
Interactive circuit
JK flip-flop
Click the switches to change the inputs and watch the LEDs. Use “Show truth table” when it appears.
Interactive circuit
JK flip-flop (cont.)
Interactive circuit
Divide-by-2 (D flip-flop, Q′ to D)
Click the switches to change the inputs and watch the LEDs. Use “Show truth table” when it appears.
Concept 4 of 6
Master-slave JK flip-flop
A master-slave JK flip-flop chains two clocked SR latches so the circuit changes state only once per clock cycle, even when J = K = 1. The master latch is enabled while the clock is high and follows J and K; the slave latch is enabled while the clock is low (its clock input is the inverted clock) and simply copies whatever the master is holding. Because the master and slave are never active at the same time, the master's new output can't loop back through the slave and re-trigger itself — this is what removes the race-around problem of a plain level-triggered JK.
| Clock | Master | Slave / output Q |
|---|---|---|
| 1 (high) | Active — follows J, K | Isolated — holds (memory) |
| 0 (low) | Isolated — holds (memory) | Active — copies the master |
With J = K = 1: while the clock is high, the master toggles once to its new value and then sits still for the rest of the high phase, since it cannot see its own new output until the next clock cycle. When the clock falls, the slave copies that single new value through to Q. Net result: exactly one toggle per clock cycle.
Concept 5 of 6
Characteristic and excitation tables
JK: Q+ = J·Q′ + K′·Q
T: Q+ = T ⊕ Q
SR: Q+ = S + R′·Q (with SR = 0)
| Q → Q+ | D | T | J K | S R |
|---|---|---|---|---|
| 0 → 0 | 0 | 0 | 0 X | 0 X |
| 0 → 1 | 1 | 1 | 1 X | 1 0 |
| 1 → 0 | 0 | 1 | X 1 | 0 1 |
| 1 → 1 | 1 | 0 | X 0 | X 0 |
The characteristic table gives the next state from the inputs (used for analysis). The excitation table gives the inputs needed for a wanted transition (used for design).
Concept 6 of 6
Timing
- Setup time: data must be stable this long before the clock edge.
- Hold time: data must stay stable this long after the edge.
- Propagation delay: time for a gate output to respond to an input.
- Clock-to-Q delay: time from the clock edge until Q changes.
Breaking setup or hold time can store the wrong value or leave the flip-flop in an in-between state.
Concept 6 of 6
Timing (cont.)
Truth tables
Truth tables (1 of 2)
SR latch (NOR)
| S | R | Q next |
|---|---|---|
| 0 | 0 | Q (hold) |
| 0 | 1 | 0 |
| 1 | 0 | 1 |
| 1 | 1 | invalid |
D flip-flop
| D | Q next |
|---|---|
| 0 | 0 |
| 1 | 1 |
JK flip-flop (characteristic)
| Q | J | K | Q next |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 0 |
Truth tables
Truth tables (2 of 2)
T flip-flop
| Q | T | Q next |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Excitation table
| Q | Q next | D | T | J | K | S | R |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | X | 0 | X |
| 0 | 1 | 1 | 1 | 1 | X | 1 | 0 |
| 1 | 0 | 0 | 1 | X | 1 | 0 | 1 |
| 1 | 1 | 1 | 0 | X | 0 | X | 0 |
Interactive
Demo: flip-flop timing simulator
Worked example 1 of 3
Worked example 1
Show the solution
- J = 0, K = 1 resets: Q+ = 0.
- J = K = 1 toggles: Q+ = 0 (from 1).
Worked example 2 of 3
Worked example 2
Show the solution
- T = Q ⊕ Q+ = 0 ⊕ 1 = 1.
Worked example 3 of 3
Worked example 3
Show the solution
- f = 1/T = 1 / 20 ns = 50 MHz.
Practice
Practice (1 of 2)
Try each one on paper first, then check your answer.
Show the answer
Show the answer
Show the answer
Practice
Practice (2 of 2)
Try each one on paper first, then check your answer.
Show the answer
Show the answer
Open the SR latch example, then build a D latch and a JK flip-flop and study the Timing diagram.
Gate ForgeA free circuit simulator — place and wire gates, generate truth tables and timing diagrams, and work through 90+ guided problems.Check yourself
Quiz
Summary
Summary
- Latches are level-sensitive. Flip-flops are edge-triggered.
- JK: 00 hold, 01 reset, 10 set, 11 toggle. T: toggle when T = 1. D: Q+ = D.
- Characteristic tables are for analysis, excitation tables are for design.
- Respect setup and hold time around the clock edge.
- f = 1/T.