Sub topic 12
Latches and flip-flops: characteristic and excitation tables
This chapter assumes you know Boolean algebra, truth tables and NAND/NOR gates from earlier chapters. It covers how a circuit stores one bit, how to describe each storage element with two tables, and how to convert one element type into another.
Why storage needs feedback
A combinational circuit's output depends only on its present inputs. To remember a bit, the output must depend on past inputs too. Feeding a gate's output back into its own input does this.
A latch is a storage element that responds to its inputs whenever it is enabled (level-sensitive). A flip-flop is a storage element that samples its inputs only at a clock edge (edge-triggered). GATE questions test the difference often.
Notation: Q is the present state and Q+ (also written Q(t+1)) is the next state.
The SR latch
Two cross-coupled NOR gates form an SR latch. S sets the output to 1 and R resets it to 0.
| S | R | Q+ | Meaning |
|---|---|---|---|
| 0 | 0 | Q | Hold |
| 0 | 1 | 0 | Reset |
| 1 | 0 | 1 | Set |
| 1 | 1 | undefined | Forbidden |
With S = R = 1, both NOR outputs are forced to 0. If both inputs then return to 0 together, the final state depends on which gate is faster, so the result is unpredictable. The characteristic equation is Q+ = S + R'Q, valid under the constraint S·R = 0.
A latch built from cross-coupled NAND gates has active-low inputs. There, S' = R' = 0 is the forbidden case and S' = R' = 1 means hold.
A gated SR latch adds an enable input E. The latch responds only while E = 1. A D latch removes the forbidden case by driving S = D and R = D'. While enabled, Q+ = D. While disabled, it holds.
Level-triggered versus edge-triggered
A latch is transparent while its enable is active. Changes at D pass straight to Q during that whole interval. This is a problem in feedback circuits, because a new output can race back to the input within the same enable pulse.
A flip-flop avoids this. A master-slave D flip-flop uses two D latches with opposite enables. The master is transparent while the clock is low and the slave while it is high. The output therefore changes only when the clock rises, so the flip-flop is positive-edge-triggered. Inputs are read once per cycle, at the edge.
Characteristic tables
A characteristic table gives Q+ as a function of the inputs and the present state Q. Use it to analyze a circuit: given the inputs, find the next state.
| Type | Characteristic equation | Behavior |
|---|---|---|
| SR | `Q+ = S + R'Q` (with SR = 0) | Set, reset, hold |
| D | `Q+ = D` | Copies D |
| JK | `Q+ = JQ' + K'Q` | Set, reset, hold, toggle |
| T | `Q+ = T ⊕ Q` | Hold when T = 0, toggle when T = 1 |
The JK table:
| J | K | Q+ |
|---|---|---|
| 0 | 0 | Q |
| 0 | 1 | 0 |
| 1 | 0 | 1 |
| 1 | 1 | Q' |
JK is an SR flip-flop with the forbidden input redefined as toggle. Its equation follows from the SR one by substituting S = JQ' and R = KQ.
Excitation tables
An excitation table answers the reverse question: for a desired transition Q → Q+, which inputs are needed? Use it for design. You know the state sequence you want and need the flip-flop inputs. An X means don't-care, which feeds directly into Karnaugh maps.
| Q | Q+ | S | R | J | K | D | T |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | X | 0 | X | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 | X | 1 | 1 |
| 1 | 0 | 0 | 1 | X | 1 | 0 | 1 |
| 1 | 1 | X | 0 | X | 0 | 1 | 0 |
Check one row against the characteristic table. For 0 → 1 with JK, J = 1 gives Q+ = 1 whether K is 0 (set) or 1 (toggle from 0). So K is a don't-care.
Two shortcuts are worth memorizing:
- For D, the input is always the desired next state:
D = Q+. - For T, the input is 1 exactly when the state changes:
T = Q ⊕ Q+.
Converting one flip-flop to another
To build flip-flop A from flip-flop B:
- Write a table with the present state Q and the inputs of A (the type you want).
- Use A's characteristic table to find
Q+. - Use B's excitation table to find the B inputs that produce each
Q → Q+. - Simplify those B inputs as functions of A's inputs and Q.
Worked example: build a T flip-flop from a D flip-flop.
| T | Q | Q+ | D needed |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
The D column equals T ⊕ Q. So one XOR gate in front of a D flip-flop makes a T flip-flop.
Other results to remember:
- JK to T: tie J = K = T.
- JK to D: J = D, K = D'.
- SR to JK: S = JQ', R = KQ.
- D to JK: D = JQ' + K'Q.
Asynchronous preset and clear
Many flip-flops have asynchronous PRE and CLR inputs. They act immediately and override the clock. Because they are not tied to the clock edge, the characteristic table applies only while both are inactive. Real parts use active-low versions, often written PRE' and CLR'.
The race-around condition
A level-triggered JK latch with J = K = 1 toggles continuously while the enable is high. The output toggles, returns to the input through feedback, and toggles again. The final value depends on how long the enable lasts compared with the propagation delay, so the result is unpredictable.
There are two standard fixes:
- Use a master-slave or edge-triggered design, so the output changes once per clock edge.
- Make the enable pulse shorter than the propagation delay. This is fragile and rarely done.
Verilog model
This is the JK flip-flop from the plan, with a small testbench. The case statement is the characteristic table written directly.
module jk_ff(input clk, input j, input k, output reg q);
always @(posedge clk) begin
case ({j, k})
2'b00: q <= q;
2'b01: q <= 1'b0;
2'b10: q <= 1'b1;
2'b11: q <= ~q;
endcase
end
endmodule
module tb;
reg clk = 0, j, k;
wire q;
jk_ff dut(clk, j, k, q);
always #5 clk = ~clk;
initial begin
$monitor("t=%0t j=%b k=%b q=%b", $time, j, k, q);
j = 0; k = 1;
#10 j = 1; k = 0;
#10 j = 1; k = 1;
#10 j = 1; k = 1;
#10 j = 0; k = 0;
#10 $finish;
end
endmoduleThe clock rises at t = 5, 15, 25, 35 and 45, and the inputs change on falling edges. The expected Q values after those edges are 0 (reset), 1 (set), 0 (toggle), 1 (toggle), 1 (hold). The initial Q is unknown (x) until the first reset. This matches real hardware, which needs a reset or a set/clear input to start in a known state.
Common errors
- Using the wrong table. Analysis (given inputs, find Q+) uses the characteristic table. Design (given Q → Q+, find inputs) uses the excitation table.
- Treating X as a value. A don't-care means either value works. Use it in K-maps to get larger groups.
- Forgetting the SR constraint.
Q+ = S + R'Qis valid only if S and R are never both 1. - Confusing latch and flip-flop. A transparent latch can pass several input changes in one enable period. A flip-flop samples once per edge.
- Mixing up toggling. JK toggles when J = K = 1 and T toggles when T = 1. D has no toggle mode, so the toggle must be built with
D = Q'.
Exercise
A JK flip-flop has J = 1 and K = 1 on every clock edge, and its initial state is Q = 0. What is Q after five clock edges, and what flip-flop behavior is this?
Show answer
The flip-flop toggles on every edge, so Q goes 1, 0, 1, 0, 1. After five edges Q = 1. This is T-flip-flop behavior with T = 1, and Q changes at half the clock frequency.
Exercise
Using the excitation table, find the JK inputs for a flip-flop that must make the transitions 0 → 1, 1 → 1, 1 → 0 and 0 → 0 in that order.
Show answer
0 → 1 needs J = 1, K = X. 1 → 1 needs J = X, K = 0. 1 → 0 needs J = X, K = 1. 0 → 0 needs J = 0, K = X.
Exercise
Show that a D flip-flop becomes a JK flip-flop when D = JQ' + K'Q.
Show answer
A D flip-flop has Q+ = D. Substituting D = JQ' + K'Q gives Q+ = JQ' + K'Q, which is the JK characteristic equation.