JK flip-flop
The flip-flop with no illegal input
A JK flip-flop is an edge-triggered one-bit memory cell whose two inputs J and K choose the next state with no illegal combination: J = K = 0 holds, J = 1 K = 0 sets to 1, J = 0 K = 1 resets to 0, and J = K = 1 toggles, giving the characteristic equation Q+ = J·Q' + K'·Q.
The D flip-flop captures one value on the clock edge and holds it, and the SR latch before it stored a bit through two control lines:
S to set it to 1, R to reset it to 0. The SR cell had one flaw, though: raising S and R together is forbidden, because it forces both outputs the same and then races to an unpredictable value when you release them. The JK flip-flop is the fix. It keeps set-and-reset, renames the two inputs J (set) and K (reset), and gives the one banned combination a job to do.Four operations, all legal
A JK flip-flop is edge-triggered like the D flip-flop: it looks at
J and K only at the clock edge and holds Q steady the rest of the cycle. What the two inputs select at that edge is:| J | K | Q+ (next state) |
|---|---|---|
| 0 | 0 | Q (hold) |
| 0 | 1 | 0 (reset) |
| 1 | 0 | 1 (set) |
| 1 | 1 | Q' (toggle) |
00 holds the current value, 01 resets to 0, 10 sets to 1, and 11 toggles (flips to the opposite of whatever it was). Compare the top three rows to the SR latch: they are identical. Only the fourth row differs, and that is the whole point of JK.Where an SR latch says 'S = R = 1 is forbidden', the JK says 'J = K = 1 means toggle'. Toggle is well defined: if
Q was 0 it becomes 1, if it was 1 it becomes 0. Nothing is left unspecified, so a JK flip-flop can be driven with any input pattern you like and it always has a clean, predictable next state.The characteristic equation
Writing
Q+ for the next state and Q' for NOT Q, the four rows collapse into one Boolean formula, the flip-flop's characteristic equation:Q+ = J · Q' + K' · Q
Read it as two terms added together. The first term,
J·Q', sets the bit: it can only push Q+ to 1, and only when J = 1 and Q is currently 0. The second term, K'·Q, keeps the bit: it holds Q+ at 1 as long as Q is already 1 and you are not resetting (K = 0). Check it against each row:J = 0, K = 0:Q+ = 0·Q' + 1·Q = Q. The bit holds.J = 0, K = 1:Q+ = 0·Q' + 0·Q = 0. Reset to 0.J = 1, K = 0:Q+ = 1·Q' + 1·Q = Q' + Q = 1. Set to 1.J = 1, K = 1:Q+ = 1·Q' + 0·Q = Q'. Toggle to the opposite value.
A concrete picture: a JK flip-flop is a light with the SR latch's two buttons,
J = ON and K = OFF, plus one new rule. Press neither and it stays as it is; press ON and it lights; press OFF and it goes dark. But press both at once and, instead of jamming like the old SR panel did, it simply flips to whatever it was not. The move that used to break the circuit is now the single most useful one, because a bit that flips on command is how you count.Worked example: a sequence of edges
Start with
Q = 0 and walk the flip-flop through five rising clock edges, changing J and K between edges. Remember that Q only moves at an edge; the inputs just decide what that move will be.| edge # | J | K | Q before | Q after |
|---|---|---|---|---|
| 1 | 1 | 0 | 0 | 1 |
| 2 | 0 | 0 | 1 | 1 |
| 3 | 1 | 1 | 1 | 0 |
| 4 | 1 | 1 | 0 | 1 |
| 5 | 0 | 1 | 1 | 0 |
How it is built
The cleanest modern way to build a JK flip-flop is to take a D flip-flop, the edge-triggered cell you already have, and put a little combinational logic in front of it that computes the right
D from J, K, and the current Q. That front-end logic is just the characteristic equation, because a D flip-flop makes Q+ = D:D = J · Q' + K' · Q
So an inverter makes
Q', an inverter makes K', two AND gates form the two product terms J·Q' and K'·Q, an OR gate adds them, and the result drives the flip-flop's D. The flip-flop's Q feeds back into those gates. Because the D flip-flop only samples on the edge, that feedback loop is safe: between edges D is a stable function of the held Q, and the edge just rewrites Q with the next value.D = J·Q' + K'·Q. The gates read J, K, and the fed-back Q; the flip-flop captures the result on each rising edge of CLK. Before the first edge Q reads Z; open it in the lab, pulse the clock, and drive J/K to watch it hold, set, reset, and toggle.Common mistakes. The
J = K = 1 case is toggle, not 'forbidden', that forbidden combination belongs to the SR latch's S = R = 1, and turning it into a toggle is precisely what JK fixes. A JK flip-flop must be edge-triggered (or built master-slave) for the toggle to be well behaved: a bare level-sensitive JK held with J = K = 1 would toggle over and over for as long as the clock stayed high (the classic 'race-around' problem), so real JK cells sample at one instant per cycle. Finally, do not read J as data: J and K are separate set and reset lines, so loading a value takes thought (J = value, K = NOT value), which is exactly why the D flip-flop is easier when you just want to store a bit.The JK flip-flop is the universal flip-flop: with the right wiring in front it behaves as any of the others. Tie
J and K together into a single input and you get a T (toggle) flip-flop; wire K to NOT J and you get a D flip-flop. Its no-illegal-input design and its handy toggle made it the workhorse of the TTL era, and its toggle mode is the direct seed of every binary counter.Try it
A JK flip-flop currently holds
Q = 1. You want the very next rising edge to leave Q = 0. Give two different J, K settings that both achieve it, and say what each one is 'doing'.Answer
Two work.
J = 0, K = 1 resets: Q+ = 0·Q' + 0·Q = 0. And J = 1, K = 1 toggles: Q+ = 1·Q' + 0·Q = Q' = 0 because Q was 1. Both land on 0. This is why the JK excitation entry for the 1 -> 0 transition is K = 1 with J a don't-care: any J with K = 1 drives a held 1 down to 0.Frequently asked
What is a JK flip-flop?
A JK flip-flop is an edge-triggered one-bit memory cell with two inputs,
J (set) and K (reset), and no illegal input combination: J = K = 0 holds the value, J = 1 K = 0 sets it to 1, J = 0 K = 1 resets it to 0, and J = K = 1 toggles it. Its characteristic equation is Q+ = J·Q' + K'·Q.What is the difference between a JK flip-flop and an SR flip-flop?
They agree on three of four input cases (hold, set, reset). The difference is the fourth: an SR latch forbids
S = R = 1 (it forces both outputs the same and resolves unpredictably), while a JK flip-flop defines J = K = 1 as toggle, flipping the bit to its opposite. JK removes SR's one illegal state and turns it into a useful operation.What is the difference between a JK flip-flop and a D flip-flop?
A D flip-flop has one input and the trivial rule
Q+ = D, so it just loads a value. A JK flip-flop has two inputs that separately set, reset, hold, or toggle the bit (Q+ = J·Q' + K'·Q). D is simpler to use for plain storage; JK is more flexible (its built-in toggle builds counters) but takes two inputs to control.Why does J = K = 1 toggle instead of being forbidden?
Because the JK was designed to remove the SR latch's forbidden
S = R = 1 corner. Feeding the current state back into the logic lets that case be defined as Q+ = Q' (flip to the opposite) instead of a contradiction. The result is a flip-flop with a clean, predictable next state for every input, plus a free toggle mode.How do you make a T flip-flop from a JK flip-flop?
Tie
J and K together and call that single line T. Then J = K = 0 is the JK hold (so T = 0 holds) and J = K = 1 is the JK toggle (so T = 1 toggles), which is exactly a T flip-flop's Q+ = T XOR Q.Next, tie
J and K together and you get the simplest useful flip-flop of all, the T (toggle) flip-flop: one input that either holds the bit or flips it, the building block chained into every binary counter.Every lesson here builds toward one thing: a working CPU, from the transistor up.
Open the free lab →Builds towardT flip-flop