JK and T Flip-Flops, Characteristic and Excitation Tables

Describe D, T and JK flip-flops by equations, build T and JK from a D flip-flop, and run the tables backwards.

You Will Be Able To

  • Write the characteristic equations of D, T and JK flip-flops.
  • Build a T or JK flip-flop from a D flip-flop and a few gates.
  • Derive an excitation table with its don't-cares.
  • Explain the ones-catching problem of the master-slave JK flip-flop.
Lesson
G5.7
Time
25 min
Runs on
Your browser
Check
5 questions

Old counter designs are drawn with JK and T flip-flops, while a modern cell library offers D flip-flops. Each type is a D flip-flop with its own next-state logic in front. Its characteristic equation says what that logic is.

A JK Flip-Flop: Set, Reset, Toggle, Toggle, HoldSampled from the jk-ff circuit model, before and after each clock edge.
0123456789jkclkq
Scroll horizontally ↔
  1. Cycle 1

    jk = 10: the edge sets q.

  2. Cycle 3

    jk = 01: the next edge resets it.

  3. Cycle 5

    jk = 11: the edge inverts q to 1.

  4. Cycle 7

    Still 11: it inverts again, to 0.

  5. Cycle 9

    jk = 00: hold.

Measured on the jk-ff circuit model below.

Characteristic Tables and Equations

A characteristic table gives the next state Q+ from the inputs and the present state Q. Written as Boolean algebra, it is the characteristic equation.

Flip-flopInputs → Q+Characteristic equation
DD = 0 → 0, D = 1 → 1Q+ = D
TT = 0 → Q (hold), T = 1 → Q' (toggle)Q+ = T ⊕ Q
JK00 hold, 01 reset, 10 set, 11 toggleQ+ = JQ' + K'Q
SR00 hold, 01 reset, 10 set, 11 not allowedQ+ = S + R'Q

The JK flip-flop is an SR flip-flop whose forbidden input was turned into "toggle".

Building T and JK from a D Flip-Flop

Since a D flip-flop stores D, feed it the equation you want. That is how every flip-flop type is built on a library of D flip-flops.

One D Flip-Flop, Three Kinds of Next-State LogicArrows show signals. Q is fed back into the logic in front of D.
  • I/O
  • Control / FSM
  • Storage
  • Control
One D flip-flop, three kinds of next-state logicArrows show signals. Q is fed back into the logic in front of D. io Inputs T, or J and K control Next-state logic T ⊕ Q or JQ' + K'Q storage D flip-flop stores D at the edge io Q output DQ fed back
  1. io InputsT, or J and K
    • Next-state logic
  2. control Next-state logicT ⊕ Q or JQ' + K'Q
    • D → D flip-flop
  3. storage D flip-flopstores D at the edge
    • Q
    • Q fed back → Next-state logic
  4. io Qoutput
  1. T

    An XOR: T = 0 passes Q (hold), T = 1 inverts it (toggle).

  2. JK

    JQ' + K'Q is a mux on Q: when Q = 0 it picks J, when Q = 1 it picks K'.

Read the diagram as text
  • Inputs: T, or J and K
  • Next-state logic: T ⊕ Q or JQ' + K'Q
  • D flip-flop: stores D at the edge
  • Q: output
  • Inputs → Next-state logic
  • Next-state logic → D flip-flop: D
  • D flip-flop → Q
  • D flip-flop → Next-state logic: Q fed back

Synthesized on this site, the lab's T and JK pair is 5 cells: two flip-flops, an XOR, a NOT and a mux.

A JK Flip-Flop Built on a D Flip-Flop
A JK Flip-Flop Built on a D Flip-Flopg0 · NOTnq=1g1 · NOTnk=1g2 · ANDset_t=0g3 · ANDhold_t=0g4 · ORd=0DQg5 · DFFq=0j=0k=0clk=0
j=0 k=0 clk=0
g0 · NOTq=0 → nq=1
g1 · NOTk=0 → nk=1
g2 · ANDj=0, nq=1 → set_t=0
g3 · ANDnk=1, q=0 → hold_t=0
g4 · ORset_t=0, hold_t=0 → d=0
g5 · DFFd=0, clk=0 → q=0
Read the connections
GateKindInputsOutput
g0NOTqnq
g1NOTknk
g2ANDj, nqset_t
g3ANDnk, qhold_t
g4ORset_t, hold_td
g5DFFd, clkq

Outputs: q. MUX inputs: d0, d1, select. Latch/flip-flop inputs: data, enable/clock. Unknown values are marked x; high impedance is folded into x in this model.

Gate delay 30. Settled after 30 gate delays from t = 0.

Output values at each gate delay0123456789101112131415161718192021222324252627282930q0000111111000000111111000000000
Scroll horizontally ↔
Every computed frame
Timeq
00
10
20
30
41
51
61
71
81
91
100
110
120
130
140
150
161
171
181
191
201
211
220
230
240
250
260
270
280
290
300

  1. Step 4 · Set. j = 1, k = 0. D = JQ' + K'Q = 1, so the edge at 3 makes `q` = 1.
  2. Step 10 · Reset. j = 0, k = 1. Both terms are 0, so the edge at 9 makes `q` = 0.
  3. Step 16 · Toggle. j = k = 1: D = Q', so each edge inverts `q`.
  4. Step 22 · Toggle again. Still j = k = 1: `q` falls back to 0.
  5. Step 30 · Hold. j = k = 0: D = Q, so the edge reloads the same value.

The jk-ff preset: a D flip-flop with D = JQ' + K'Q in front. The clock period is six gate delays.

Excitation Tables: The Tables Run Backwards

To design a counter, you know each change of state you want, Q to Q+. You need the inputs that cause it. That is the excitation table. Where either value of an input works, it is a don't-care, X.

Q → Q+DTJ KS R
0 → 0000 X0 X
0 → 1111 X1 0
1 → 001X 10 1
1 → 110X 0X 0

Read each row from the characteristic equations. With Q = 0, JK gives Q+ = J, so K is free; with Q = 1, Q+ = K', so J is free.

The JK table has the most don't-cares. In G7.3 they shrink the next-state logic of a counter.

The Ones-Catching Problem

Older JK flip-flops were pulse-triggered. In this master-slave pair, the master listens to J and K for the whole high phase. Once the master has set, it cannot clear again in the same pulse.

The edge-triggered JK of the lab does not catch ones: its D input is sampled at the edge only. That is one reason designs now use D flip-flops with logic in front.

Asked in interviews
  1. How do you make a T flip-flop from a D flip-flop?

    Feed D = T xor Q. With T = 0 the flop reloads Q; with T = 1 it loads Q', so it toggles.

  2. Convert a D flip-flop into a JK flip-flop.

    Put D = JQ' + K'Q in front of it. When Q = 0 the next state is J; when Q = 1 it is K'. With J = K = 1 it toggles.

  3. What is an excitation table used for?

    For designing sequential circuits with a given flip-flop type. For each wanted change of state it lists the inputs that cause it. Don't-cares, where either value works, simplify the input logic.

Try It

After the reset edge both flip-flops are 0. With t = 1 the T flop toggles; with jk = 10 the JK flop sets.

jk = 11 toggles the JK flop on both edges: 1, then 0. The T flop with t = 1 toggles too, so the two outputs match on those edges.

Press Synthesize: 5 cells. Then replace t ^ qt with t and run again: the T flop no longer toggles.

RTLIcarus Verilog · in your browser · Lint: Verilator service · Synthesize: Yosys service
Edit the design, then Run, Lint or Synthesize
Expected: t=1 j=1 k=0 toggle / set qt=1 qjk=1 t=0 j=0 k=0 hold / hold qt=1 qjk=1 t=1 j=0 k=1 toggle / reset qt=0 qjk=0 t=1 j=1 k=1 toggle / toggle qt=1 qjk=1 t=1 j=1 k=1 toggle / toggle qt=0 qjk=0 t=0 j=0 k=0 hold / hold qt=0 qjk=0

Original design · 5 cells · 2 flip-flops · 0 latches · 2 logic levels. Synthesis uses Yosys; counts depend on the toolchain.

Read included file: tb.sv
// tb.sv: one rising edge per line; the same t, j, k drive both flip-flops (read-only).
`timescale 1ns/1ns
module tb;
  logic clk = 0, rst = 1, t = 0, j = 0, k = 0;
  logic qt, qjk;
  tjk dut (.clk(clk), .rst(rst), .t(t), .j(j), .k(k), .qt(qt), .qjk(qjk));
  task automatic edge_with(input logic t_in, j_in, k_in, input string what);
    t = t_in; j = j_in; k = k_in;
    #5 clk = 1; #5 clk = 0;
    $display("t=%b j=%b k=%b  %-14s qt=%b qjk=%b", t, j, k, what, qt, qjk);
  endtask
  initial begin
    #5 clk = 1; #5 clk = 0; rst = 0;          // reset edge: both 0
    edge_with(1, 1, 0, "toggle / set");
    edge_with(0, 0, 0, "hold / hold");
    edge_with(1, 0, 1, "toggle / reset");
    edge_with(1, 1, 1, "toggle / toggle");
    edge_with(1, 1, 1, "toggle / toggle");
    edge_with(0, 0, 0, "hold / hold");
  end
endmodule

Check Yourself

ConceptWhat is the next state of a JK flip-flop with J = 1, K = 1 and Q = 1?
ConceptIn the T column of the excitation table, why is the entry for 1 → 0 a 1?
ConceptWhich SR excitation entry for the change 1 → 1 is right?
Read the waveformA T flip-flop starts at q = 0. It is clocked once per cycle, at the end of the cycle. What is q in the last cycle?
A T flip-flop
01234clkt
Scroll horizontally ↔

Each edge samples t of the cycle it ends.

Predict the outputA JK flip-flop built as D = JQ' + K'Q starts at 0. It sees four edges with jk = 10, 11, 01, 11. The program prints q after each. Predict the exact line.
module tb;
  logic clk = 0, j, k, q = 0;
  string s = "";
  always_ff @(posedge clk) q <= (j & ~q) | (~k & q);
  task automatic tick(input logic jj, kk);
    j = jj; k = kk; #1 clk = 1; #1 clk = 0; s = {s, q ? "1" : "0"};
  endtask
  initial begin
    tick(1, 0); tick(1, 1); tick(0, 1); tick(1, 1);
    $display("%s", s);
  end
endmodule

Common Mistakes

Wrong Read the characteristic table when designing a counter.

It answers "what will Q become?" The design question is the reverse: "which inputs give this change?"

Fix Use the excitation table, with its don't-cares, to fill the next-state map.

Wrong Build a T flip-flop by feeding t straight into D.

That is a D flip-flop on t: it copies t, it never toggles.

Fix Feed D = T xor Q, so t = 1 inverts the stored bit.

Wrong Expect JK = 11 to act like SR = 11.

For a JK flip-flop 11 is legal and toggles. In the lab it alternated 1, 0 on two edges.

Fix Q+ = JQ' + K'Q: with both at 1, Q+ = Q'.

Wrong Assume a pulse-triggered master-slave JK flip-flop only looks at J and K at the edge.

Its master is open for the whole high phase. A short 1 on J during that phase was caught and stored.

Fix Keep J and K stable while the clock is high, or use an edge-triggered D flip-flop with logic in front.

Remember

  • Q+ = D, Q+ = T ⊕ Q and Q+ = JQ' + K'Q describe the D, T and JK flip-flops.
  • A D flip-flop with its characteristic equation in front of D becomes any other type.
  • An excitation table lists, for each change of state, the inputs that cause it, with don't-cares.
  • A pulse-triggered master-slave JK catches a 1 on J or K during the high phase; edge-triggered designs do not.

Practice

Report a problem with this page