Flip-flops and latches: SR, D, JK and T

SR, D, JK and T: characteristic tables, excitation tables and timing diagrams.

Conventions on this page

Latches are level-sensitive
A latch with EN = 1 is transparent: its output follows its input continuously. With EN = 0 it holds. Where a latch has an enable it is active-HIGH unless the symbol carries a bubble.
Flip-flops are edge-triggered
Every flip-flop on this page is positive-edge-triggered: it samples its inputs on the rising edge of CLK and changes its output only there. The dynamic-input wedge on the CLK pin marks this; a wedge plus a bubble would mean negative-edge.
State notation
Q is the state before the active edge and Q⁺ is the state after it. A characteristic table gives Q⁺ as a function of the inputs and Q.
Asynchronous inputs
Where they are shown, PRE_n (preset) and CLR_n (clear) are active-LOW and override the clock entirely. Both asserted at once is illegal.
Setup and hold
Inputs must be stable for t_su before the edge and t_h after it. A transition inside that window has no defined result, which is a violation rather than a coin toss.
Propagation and initial state
Outputs change t_co after the edge, not on it. Every trace on this page starts at Q = 0.

A JK flip-flop through all four modes

Timing diagram

A positive-edge JK flip-flop starting at Q = 0, driven through hold, set, hold, toggle, reset, toggle, hold and set.J: 01010101. K: 00011100. Q: 01100111. Every value is also in the trace table beside this diagram.CLKJKQ

Edge-by-edge trace

One line per active clock edge: the inputs sampled, the state before, the mode and the state after.
EdgeJKQModeQ⁺
1000Hold0
2100Set1
3001Hold1
4111Toggle0
5010Reset0
6110Toggle1
7001Hold1
8101Set1

Q after each of the eight edges: 0, 1, 1, 0, 0, 1, 1, 1.

The six elements

SR latch (NOR, active-HIGH)

Characteristic table

SR latch (NOR, active-HIGH): Q⁺ for every input combination.
SRQ⁺Meaning
00QHold
010Reset
101Set
111Forbidden

Q⁺ = S + R′·Q

Valid only under the constraint S · R = 0, which is printed every time the equation is.

Cross-coupled NOR gates. The one place a bare SR latch is still used in practice is contact debouncing.

Excitation table

SR latch (NOR, active-HIGH): the inputs needed to force each transition. X means either value works.
QQ⁺SR
000X
0110
1001
11X0

Derived by inverting the characteristic equation: every legal input vector that produces the transition is collected, and an input the collected vectors disagree about is a don’t-care.

Important:

The forbidden state

With S = R = 1 the NOR latch drives both Q and Q_n to 0. That is not merely “undefined”: it is a concrete, observable state, and it is illegal because the two outputs are supposed to be complements and here they are equal. The real failure comes on release — if S and R return to 0 at the same instant, both NOR gates try to go high at once, each one’s output is the other’s input, and the latch settles into whichever state wins a race decided by gate delays and noise. It can also sit metastable at an intermediate voltage for an unbounded time before resolving.

SR latch (NAND, active-LOW)

Characteristic table

SR latch (NAND, active-LOW): Q⁺ for every input combination.
S_nR_nQ⁺Meaning
001Forbidden
011Set
100Reset
11QHold

Q⁺ = S_n′ + R_n·Q

Valid only under the constraint S_n + R_n = 1, which is printed every time the equation is.

Cross-coupled NAND gates. Inputs are asserted LOW, which is why they are written with a trailing _n.

Excitation table

SR latch (NAND, active-LOW): the inputs needed to force each transition. X means either value works.
QQ⁺S_nR_n
001X
0101
1010
11X1

Derived by inverting the characteristic equation: every legal input vector that produces the transition is collected, and an input the collected vectors disagree about is a don’t-care.

Important:

The forbidden state

For the NAND latch the forbidden combination is S_n = R_n = 0, and it drives both outputs to 1 rather than to 0. This sign flip is the single most common exam error on this topic: the same circuit idea, the opposite assertion level, the opposite illegal state.

D latch (gated, level-sensitive)

Characteristic table

D latch (gated, level-sensitive): Q⁺ for every input combination.
ENDQ⁺Meaning
00QHold
01QHold
100Reset
111Set

Q⁺ = EN·D + EN′·Q

Built from the SR latch by tying S = EN·D and R = EN·D′, which makes S = R = 1 unreachable. That is why the D latch exists. With EN held at 1 the latch is transparent and Q traces D exactly, glitches included — which is the whole difference from a flip-flop.

Excitation table

D latch (gated, level-sensitive): the inputs needed to force each transition. X means either value works.
QQ⁺END
00XX
0111
1010
11XX

Derived by inverting the characteristic equation: every legal input vector that produces the transition is collected, and an input the collected vectors disagree about is a don’t-care.

D flip-flop (positive-edge)

Characteristic table

D flip-flop (positive-edge): Q⁺ for every input combination.
DQ⁺Meaning
00Reset
11Set

Q⁺ = D

A one-clock delay element, which is why it is drawn as z⁻¹ in signal-processing diagrams. Its excitation table is D = Q⁺, which is why D flip-flops are the easiest element to design a state machine with.

Excitation table

D flip-flop (positive-edge): the inputs needed to force each transition. X means either value works.
QQ⁺D
000
011
100
111

Derived by inverting the characteristic equation: every legal input vector that produces the transition is collected, and an input the collected vectors disagree about is a don’t-care.

JK flip-flop (positive-edge)

Characteristic table

JK flip-flop (positive-edge): Q⁺ for every input combination.
JKQ⁺Meaning
00QHold
010Reset
101Set
11Q′Toggle

Q⁺ = J·Q′ + K′·Q

The SR flip-flop with the forbidden state redefined as toggle: S = J·Q′ and R = K·Q can never both be 1, because Q and Q′ cannot both be 1.

Excitation table

JK flip-flop (positive-edge): the inputs needed to force each transition. X means either value works.
QQ⁺JK
000X
011X
10X1
11X0

Derived by inverting the characteristic equation: every legal input vector that produces the transition is collected, and an input the collected vectors disagree about is a don’t-care.

T flip-flop (positive-edge)

Characteristic table

T flip-flop (positive-edge): Q⁺ for every input combination.
TQ⁺Meaning
0QHold
1Q′Toggle

Q⁺ = T ⊕ Q = T·Q′ + T′·Q

There is no standard 74-series T flip-flop part. You make one from a JK with J = K = T, or from a D flip-flop with D = T ⊕ Q.

Excitation table

T flip-flop (positive-edge): the inputs needed to force each transition. X means either value works.
QQ⁺T
000
011
101
110

Derived by inverting the characteristic equation: every legal input vector that produces the transition is collected, and an input the collected vectors disagree about is a don’t-care.

Notation used on this page
Positive logic
1 = HIGH = asserted, 0 = LOW = deasserted. An active-low signal is written with an overbar in figures and a trailing _n in copyable text, for example CLR_n.
Operators
· AND (also written by juxtaposition, AB) · + OR · ′ complement (postfix; an overbar in figures) · ⊕ XOR · ⊙ XNOR · ↑ NAND (Sheffer stroke) · ↓ NOR (Peirce arrow).
Precedence, highest first
( ) then ′ then · (including juxtaposition) then ⊕ and ⊙ then ↑ and ↓ then +. The parser echoes the fully parenthesised reading back, and warns without blocking when ⊕, ↑ or ↓ appears un-parenthesised beside · or +, because textbooks disagree there.
Truth-table row order
Binary counting order from all-zeros to all-ones. The first-listed variable is the most significant bit. Row index k is the integer value of the input vector, and the row is labelled mₖ.
Minterms and maxterms
Σm(…) lists the rows where F = 1. ΠM(…) lists the rows where F = 0. Mᵢ complements a variable wherever bit i is 1 — the opposite way round from mᵢ.
Symbol standards
IEEE means ANSI/IEEE Std 91-1984 with its 91a-1991 supplement — the distinctive shapes. IEC means IEC 60617-12 — the rectangular shapes with a qualifying symbol. The header toggle switches every figure on the page between them.
Symbol-set toggle
Both symbol standards are in this page’s HTML. The toggle in the header chooses which one is drawn, before the first frame is painted, and it changes nothing else on the page — not a truth table, not a gate count, not an answer.

Run your own stimulus

The same six devices, with the stimulus editable. It opens on the JK run above, so change one bit and watch where the sequence stops agreeing with it. Every next state here is read out of the characteristic table the engine derived — the trace and the table cannot come apart.

Initial Q
Set the inputs for each edge. Every button is a value, not a submission — the trace below is recomputed on the click.
Input12345678
J
K
JK flip-flop (positive-edge): J, K and Q over 8 edges, starting at Q = 0.J: 01010101. K: 00011100. Q: 01100111. Every value is also in the trace table beside this diagram.CLKJKQ

One clock cycle per column. The dashed line is the rising edge, where the inputs are sampled.

One line per edge: the inputs, the state before, the mode the characteristic table names, and the state after.
EdgeJKQModeQ⁺
1000Hold0
2100Set1
3001Hold1
4111Toggle0
5010Reset0
6110Toggle1
7001Hold1
8101Set1

Q after each edge: 0, 1, 1, 0, 0, 1, 1, 1.

Q⁺ = J·Q′ + K′·Q

Latch or flip-flop? The one distinction that matters

A latch is level-sensitive. While its enable is asserted it is transparent: the output follows the input continuously, glitches and all, and it stops following only when the enable is removed. A flip-flop is edge-triggered. It looks at its inputs at one instant — here, the rising edge of the clock — and ignores them the rest of the time.

Run the same input through both and the difference is visible rather than verbal. Select the D latch above and set EN high for several consecutive columns: Q copies D in every one of them. Select the D flip-flop and Q changes once per column, at the edge, and holds in between. That single clock of delay is the reason a flip-flop is drawn as z⁻¹ in signal-processing diagrams, and the reason a register built from latches on one clock phase is not a register at all.

The vocabulary is not universal: some texts call an edge-triggered device a “clocked latch”, and older parts labelled “latch” are pulse-triggered. On this page latch means level-sensitive and flip-flop means edge-triggered, without exception.

The SR latch

The NOR version — inputs asserted HIGH

Two NOR gates, each one’s output feeding the other’s input. S = 1 sets Q to 1, R = 1 resets it to 0, and S = R = 0 holds whatever was there. The characteristic equation is Q⁺ = S + R′·Q, and it is only valid under the constraint S·R = 0 — which is printed beside the equation everywhere it appears on this page, because an equation quoted without its constraint is the thing that produces the wrong answer.

The NAND version — inputs asserted LOW

Two NAND gates in the same cross-coupled arrangement. The inputs idle at 1 and are asserted by pulling them low, which is why they are written and — on this page S_n and R_n. The characteristic equation is Q⁺ = S_n′ + R_n·Q under the constraint S_n + R_n = 1.

The forbidden state, and the release race

For the NOR latch the forbidden combination is S = R = 1, and it drives both Q and Q_n to 0. That is not “undefined”: it is a concrete, observable state, and it is illegal because the two outputs are supposed to be complements and here they are equal, so the circuit is not storing a bit at all.

The real failure arrives on release. If S and R return to 0 at the same instant, both NOR gates begin to go high together; each gate’s output is the other’s input, so the pair enters a race that resolves to 0 or to 1 according to gate delays and noise rather than to anything in your design. It can also sit metastable at an intermediate voltage for an unbounded time before resolving — unbounded in the strict sense that no fixed waiting period makes the probability zero, only smaller.

For the NAND latch the forbidden combination is the mirror image: S_n = R_n = 0, and it drives both outputs to 1. Same circuit idea, opposite assertion level, opposite illegal state — and this sign flip is the single most common exam error on the topic. Both variants have their own table above, and both are marked.

Contact debouncing — where a bare SR latch is still used

A mechanical switch does not close once; it bounces for a few milliseconds. Wire a single-pole double-throw switch to the two inputs of a NAND latch and the first contact sets the latch — every subsequent bounce on the same input finds the latch already in that state and changes nothing. The output is one clean transition. This is the one place a bare SR latch remains the right component rather than a teaching step.

The gated SR latch and the D latch

Add an enable: S_int = EN·S and R_int = EN·R. Now the latch only listens while EN is asserted. The forbidden state has not gone anywhere — it is simply unreachable while EN is low.

Remove it properly by tying the two inputs together through an inverter: S = EN·D and R = EN·D′. S and R can now never both be 1, because D and D′ can never both be 1. That is precisely why the D latch exists, and its characteristic equation Q⁺ = EN·D + EN′·Q carries no constraint at all — the one device on this page whose equation is unconditional apart from the two flip-flops with a single input.

Edge triggering

The dynamic-input indicator — a wedge drawn inside the symbol on the clock pin — is what marks an edge-triggered input. A wedge alone means the active edge is the rising one; a wedge with a bubble outside the symbol means the falling one. Every flip-flop on this page is positive-edge-triggered.

Master–slave is not the same thing. A master–slave pair is two latches on opposite clock phases: the master is transparent while the clock is high and the slave copies it when the clock falls. The output changes on one edge, which looks like edge triggering from outside, but the master was listening for a whole half cycle. A true edge-triggered flip-flop — the six-NAND structure, or a master–slave built from edge-triggered stages — samples in a narrow window around the edge only.

Setup and hold. The inputs must be stable for tsu before the active edge and th after it. A transition inside that window is a violation, not a coin toss: the part’s datasheet makes no guarantee at all, and the output may go metastable. Outputs change tco after the edge, never on it, which is what makes it possible to chain flip-flops back to back without the second one seeing the first one’s new value on the same edge.

Asynchronous inputs. Where a part has them, PREn (preset) and CLRn (clear) are active-LOW and override the clock entirely — the flip-flop sets or clears the moment they are asserted, whatever the clock is doing. Asserting both at once is illegal for the same reason S = R = 1 is.

The D flip-flop

Q⁺ = D, and nothing else. Its excitation table above reads D = Q⁺ in every row with no don’t-cares, which is exactly why sequential design with D flip-flops is the easy case: whatever next-state expression the state table gives you is the D input expression, with no further work.

Internally it is either a master–slave pair of D latches on opposite clock phases, or the classic six-NAND edge-triggered structure. Both appear on real parts and both behave identically at the pins for the purpose of this page.

The JK flip-flop

The JK is the SR flip-flop with the forbidden state given a job. Tie S = J·Q′ and R = K·Q: S and R can never both be 1, because Q and Q′ cannot both be 1. The combination that used to be illegal, J = K = 1, now means toggle, and the characteristic equation Q⁺ = J·Q′ + K′·Q covers all four rows with no constraint attached.

1s catching

In the older master–slave (pulse-triggered) JK, the master is transparent for the whole high half of the clock. A momentary 1 on J or K anywhere in that window is captured by the master and appears at the output on the falling edge — even if the input returned to 0 long before. That is 1s catching, and it makes a master–slave JK unsafe with any input that can glitch. Edge-triggered JKs do not do it. Everything on this page simulates the edge-triggered behaviour.

Where the letters come from

The origin of J and K is not settled in the published literature. The attribution to Jack Kilby is repeated widely but is not supported by a primary source, and other accounts — “jump” and “kill”, or simply the next free letters — are equally undocumented. The honest answer is that nobody has produced the evidence, and this page says that rather than passing on the story.

The T flip-flop

Q⁺ = T ⊕ Q: hold when T is 0, toggle when T is 1. Its excitation table reads T = Q ⊕ Q⁺ — apply a 1 exactly when the state has to change — which makes it the natural element for counters, where every bit’s job is to change on a schedule.

There is no standard 74-series T flip-flop. You make one from a JK by tying J = K = T, or from a D flip-flop with D = T ⊕ Q, which costs one XOR gate.

Characteristic and excitation tables — which one to use when

They are the same information read in opposite directions, and using the wrong one is the commonest way to get stuck on a sequential-design question.

A characteristic table answers analysis: given the inputs and the present state, what does the state become? It is a truth table for Q⁺. An excitation table answers synthesis: I need this transition — what must I apply to get it? It is that same relation inverted, which is why don’t-cares appear in it and never in the characteristic table. Every excitation entry marked X above was produced by finding more than one legal input vector that causes the transition and observing that they disagree about that input, not by copying a book.

Converting between flip-flop types

Every conversion, as the input equation for the flip-flop you have in terms of the one you want. Q is the present state.
From ↓ / To →DTSRJK
DD = T ⊕ QD = S + R′QD = JQ′ + K′Q
TT = D ⊕ QT = SQ′ + RQT = JQ′ + KQ
SRS = D, R = D′S = TQ′, R = TQS = JQ′, R = KQ
JKJ = D, K = D′J = T, K = TJ = S, K = R

Every cell is derived the same way, and it is worth doing once by hand. Take the flip-flop you want, write down the transition it demands for each combination of present state and its inputs, then look that transition up in the excitation table of the flip-flop you have. That gives one column per input of the device you have, over the variables (Q, inputs-you-want), usually with don’t-cares in it. K-map each column and read off the expression.

JK → D, worked: the requirement is Q⁺ = D. Q = 0, D = 0 needs 0 → 0, which the JK excitation table satisfies with J = 0, K = X. Q = 0, D = 1 needs 0 → 1: J = 1, K = X. Q = 1, D = 0 needs 1 → 0: J = X, K = 1. Q = 1, D = 1 needs 1 → 1: J = X, K = 0. Mapping J over (Q, D) with its two don’t-cares gives J = D; mapping K gives K = D′. One inverter converts a JK into a D, and substituting back into Q⁺ = J·Q′ + K′·Q gives D·Q′ + D·Q = D, which is the requirement.

Counters and dividers

A T flip-flop with T tied to 1 — or a JK with both inputs tied high — toggles on every active edge, so its output is the clock divided by two. Chain n of them, each clocked by the previous stage’s output, and you have an n-bit ripple (asynchronous) counter running through all 2ⁿ states: Q₀ at f/2, Q₁ at f/4, Q₂ at f/8.

Clocking each stage from the previous stage’s Q with positive-edge parts makes the count run down; clocking from Q_n, or using negative-edge parts, makes it run up. Either way the stages do not change together: stage k changes k propagation delays after the clock edge, so the outputs pass through wrong intermediate values on every carry — 011 → 010 → 000 → 100 on the 3 → 4 transition of a three-bit counter. Decode those outputs combinationally and you decode the glitches too. Synchronous counters, where every flip-flop takes the same clock and the inputs carry the enable logic, exist to remove exactly that.

Real parts

74HC74 — dual D, positive-edge, with active-low preset and clear. 74HC76 and 74LS73 — dual JK. 74HC75 — quad transparent D latch. 74HC373 — octal transparent latch. 74HC374 — octal positive-edge D flip-flop.

Warning:

’373 and ’374 are not interchangeable

The ’373 is a latch and the ’374 is a flip-flop. They share a pinout, a package and almost a part number, and substituting one for the other produces a board that works until the input happens to move while the enable is asserted. Read the second digit.

Start from a worked example

Worked examples

Sources

  1. W. H. Eccles and F. W. Jordan, “A Trigger Relay Utilising Three-Electrode Thermionic Vacuum Tubes,” The Electrician, vol. 83, p. 298, 19 September 1919; and UK patent GB 148,582, “Improvements in Ionic Relays,” filed 21 June 1918 — the original bistable.
  2. D. A. Huffman, “The Synthesis of Sequential Switching Circuits,” Journal of the Franklin Institute, vol. 257, no. 3, pp. 161–190 and no. 4, pp. 275–303, 1954.
  3. G. H. Mealy, “A Method for Synthesizing Sequential Circuits,” Bell System Technical Journal, vol. 34, no. 5, pp. 1045–1079, 1955.
  4. E. F. Moore, “Gedanken-Experiments on Sequential Machines,” in Automata Studies, Annals of Mathematics Studies no. 34, Princeton University Press, pp. 129–153, 1956.
  5. C. E. Shannon, “A Symbolic Analysis of Relay and Switching Circuits,” Transactions of the AIEE, vol. 57, pp. 713–723, 1938.
  6. ANSI/IEEE Std 91-1984 with IEEE Std 91a-1991, IEEE Standard Graphic Symbols for Logic Functions.
  7. IEC 60617-12:1997, Graphical symbols for diagrams — Part 12: Binary logic elements. (Paid standard; see the construction note beside every rectangular symbol.)