Suppose your design needs T flip-flops, but the only chip in the lab drawer is a 74HC74 (D flip-flops). Or you are working on an FPGA, where every storage cell is a D flip-flop, yet your textbook design is written with JK flip-flops. You do not need a new chip: you can make any flip-flop behave like any other by putting a little combinational logic in front of it. This is called flip-flop conversion, and it is a favourite question in university exams and GATE.
More importantly, conversion is a small, complete rehearsal of the method used to design every synchronous counter and state machine: "I know what next state I want; what inputs must I give the flip-flop I actually have?" Master it here and Synchronous Counters will feel familiar.
Flip-flop conversion: to make an available flip-flop (say X) behave as a required flip-flop (say Y), design a combinational circuit that takes Y's inputs and the present state Q and produces X's inputs, so that the next state always matches Y's characteristic table.
We use the characteristic tables and excitation tables from Flip-Flops: SR, JK, D & T. All twelve conversions in this chapter were computed with a Python script (K-map minimisation with don't-cares using sympy) and then checked by simulating the converted flip-flop against the required one for every input and state. One conversion was also checked in SystemVerilog over 1000 random clock cycles.
The General Procedure
required inputs (e.g. J, K)
|
v
+------------------+ available inputs +-------------------+
| conversion |---------(e.g. D)-------->| available |----+---> Q
| logic | | flip-flop | |
+------------------+ +-------------------+ |
^ ^ CLK |
| |
+-------------------------- Q (feedback) -----------------------+
Write the characteristic table of the required flip-flop, with its inputs and the present state Q, giving Q+.
For each row, look at the transition Q → Q+ and use the excitation table of the available flip-flop to fill in the inputs it needs.
Draw a K-map for each input of the available flip-flop, with the required inputs and Q as variables. Use the x entries as don't-cares.
Simplify, and draw the logic in front of the available flip-flop. Q (and Q′) are fed back as inputs to the logic.
For reference, the excitation table again:
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 |
Example 1: JK Flip-Flop Using an SR Flip-Flop
Required: JK. Available: SR. The variables of the K-maps are J, K and Q.
Steps 1 and 2: conversion table.
J | K | Q | Q+ (JK) | S | R |
|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | x |
0 | 0 | 1 | 1 | x | 0 |
0 | 1 | 0 | 0 | 0 | x |
0 | 1 | 1 | 0 | 0 | 1 |
1 | 0 | 0 | 1 | 1 | 0 |
1 | 0 | 1 | 1 | x | 0 |
1 | 1 | 0 | 1 | 1 | 0 |
1 | 1 | 1 | 0 | 0 | 1 |
For example, row J K Q = 1 1 1: the JK toggles, so 1 → 0, and the SR excitation for 1 → 0 is S = 0, R = 1.
Step 3: K-maps.
S: KQ R: KQ
00 01 11 10 00 01 11 10
+----+----+----+----+ +----+----+----+----+
J = 0 | 0 | x | 0 | 0 | J = 0 | x | 0 | 1 | x |
+----+----+----+----+ +----+----+----+----+
J = 1 | 1 | x | 0 | 1 | J = 1 | 0 | 0 | 1 | 0 |
+----+----+----+----+ +----+----+----+----+
S = JQ′ (cells 100 and 110) R = KQ (cells 011 and 111)
Step 4: result.
JK from SR: S = JQ′, R = KQ.
A nice check: S and R can never both be 1, because S needs Q = 0 and R needs Q = 1. So the converted circuit never applies the SR flip-flop's invalid input, even when J = K = 1. This is exactly how the classic JK flip-flop is built from an SR: feed Q′ back to the J-side gate and Q back to the K-side gate.
Example 2: SR Flip-Flop Using a JK Flip-Flop
Now the required flip-flop is SR, whose input S = R = 1 is not allowed. Those rows have no defined next state, so every available input is a don't-care there.
S | R | Q | Q+ (SR) | J | K |
|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | x |
0 | 0 | 1 | 1 | x | 0 |
0 | 1 | 0 | 0 | 0 | x |
0 | 1 | 1 | 0 | x | 1 |
1 | 0 | 0 | 1 | 1 | x |
1 | 0 | 1 | 1 | x | 0 |
1 | 1 | 0 | invalid | x | x |
1 | 1 | 1 | invalid | x | x |
J: RQ K: RQ
00 01 11 10 00 01 11 10
+----+----+----+----+ +----+----+----+----+
S = 0 | 0 | x | x | 0 | S = 0 | x | 0 | 1 | x |
+----+----+----+----+ +----+----+----+----+
S = 1 | 1 | x | x | x | S = 1 | x | 0 | x | x |
+----+----+----+----+ +----+----+----+----+
J = S (bottom row) K = R (column R = 1, both rows)
SR from JK: J = S, K = R. No gates at all: a JK flip-flop already is an SR flip-flop whose invalid input has been given a meaning.
Example 3: D and T Using a JK Flip-Flop
D from JK. Only two variables, D and Q:
D | Q | Q+ | J | K |
|---|---|---|---|---|
0 | 0 | 0 | 0 | x |
0 | 1 | 0 | x | 1 |
1 | 0 | 1 | 1 | x |
1 | 1 | 1 | x | 0 |
J is 1 when D = 1 (and x otherwise in the D = 1 half), so J = D. K is 1 when D = 0, so K = D′. One inverter: connect D to J and D′ to K.
T from JK. The same procedure gives J = T, K = T: simply tie J and K together. With T = 0 the JK holds; with T = 1 it toggles.
Example 4: Conversions Using a D Flip-Flop
When the available flip-flop is D, the excitation is trivial: D must equal the desired next state. So the conversion logic is simply the characteristic equation of the required flip-flop.
Required | D input |
|---|---|
JK | D = JQ′ + K′Q |
SR | D = S + R′Q |
T | D = T ⊕ Q |
This is exactly what happens on an FPGA: whatever flip-flop your design describes, the tools build it as a D flip-flop with the characteristic equation in front of it.
Checking JK-from-D in SystemVerilog
We build a JK flip-flop out of a D flip-flop plus the logic D = JQ′ + K′Q, and compare it against a JK flip-flop written directly from its characteristic table, for 1000 random clock cycles:
`timescale 1ns/1ns
// JK flip-flop built from a D flip-flop plus the conversion logic D = JQ' + K'Q
module jk_from_d(input logic CLK, J, K, output logic Q);
logic D;
assign D = (J & ~Q) | (~K & Q);
always_ff @(posedge CLK) Q <= D; // the available D flip-flop
endmodule
// Reference JK flip-flop written directly from its characteristic table
module jk_ref(input logic CLK, J, K, output logic Q);
always_ff @(posedge CLK)
case ({J, K})
2'b00: Q <= Q;
2'b01: Q <= 0;
2'b10: Q <= 1;
2'b11: Q <= ~Q;
endcase
endmodule
module tb;
logic CLK = 0, J, K, Q1, Q2;
int errors = 0;
jk_from_d dut(CLK, J, K, Q1);
jk_ref ref_ff(CLK, J, K, Q2);
always #5 CLK = ~CLK;
initial begin
dut.Q = 0; ref_ff.Q = 0; J = 0; K = 0;
repeat (1000) begin
@(negedge CLK) {J, K} = $urandom_range(0, 3);
@(posedge CLK) #1 if (Q1 !== Q2) errors++;
end
$display("1000 random clock cycles compared, mismatches = %0d", errors);
$finish;
end
endmodule
Output (Icarus Verilog):
1000 random clock cycles compared, mismatches = 0
Example 5: Conversions Using a T Flip-Flop
A T flip-flop must toggle exactly when the state has to change, so the shortcut is T = Q ⊕ Q+, where Q+ is the characteristic equation of the required flip-flop. Let us still do JK-from-T with the full method, because the K-map is a good exercise.
J | K | Q | Q+ | T |
|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 1 | 0 |
0 | 1 | 0 | 0 | 0 |
0 | 1 | 1 | 0 | 1 |
1 | 0 | 0 | 1 | 1 |
1 | 0 | 1 | 1 | 0 |
1 | 1 | 0 | 1 | 1 |
1 | 1 | 1 | 0 | 1 |
T: KQ
00 01 11 10
+----+----+----+----+
J = 0 | 0 | 0 | 1 | 0 |
+----+----+----+----+
J = 1 | 1 | 0 | 1 | 1 |
+----+----+----+----+
Group KQ : cells 011, 111 (column KQ = 11)
Group JQ′ : cells 100, 110 (J = 1, Q = 0)
T = JQ′ + KQ
Intuition: when Q = 0 we must toggle exactly when J = 1 (set or toggle); when Q = 1 we must toggle exactly when K = 1 (reset or toggle).
With the shortcut, the other conversions from T are quick:
D from T: T = D ⊕ Q (toggle when the new value differs from the old one).
SR from T: T = SQ′ + RQ (toggle from 0 when set; toggle from 1 when reset). The S = R = 1 rows are don't-cares.
Example 6: Conversions Using an SR Flip-Flop
With an SR flip-flop as the available device, the result must never make S and R both 1. Using the excitation table guarantees that, because it only ever asks for (0, x), (1, 0), (0, 1) or (x, 0).
D from SR: S = D, R = D′. (The excitation also allows S = DQ′, R = D′Q, which uses more gates; the minimal K-map answer is S = D, R = D′.)
T from SR: S = TQ′, R = TQ. When T = 1 and Q = 0 we set; when T = 1 and Q = 1 we reset.
JK from SR: S = JQ′, R = KQ (Example 1).
All Twelve Conversions at a Glance
Required | Available | Conversion logic |
|---|---|---|
SR | JK | J = S, K = R |
SR | D | D = S + R′Q |
SR | T | T = SQ′ + RQ |
JK | SR | S = JQ′, R = KQ |
JK | D | D = JQ′ + K′Q |
JK | T | T = JQ′ + KQ |
D | SR | S = D, R = D′ |
D | JK | J = D, K = D′ |
D | T | T = D ⊕ Q = DQ′ + D′Q |
T | SR | S = TQ′, R = TQ |
T | JK | J = T, K = T |
T | D | D = T ⊕ Q = TQ′ + T′Q |
Every row was produced by the K-map method in our script and then verified by simulating the available flip-flop with the conversion logic for all combinations of inputs and present state.
Two patterns to remember:
Available = D: D = Q+ of the required flip-flop.
Available = T: T = Q ⊕ Q+ of the required flip-flop.
Common Mistakes
Using the characteristic table of the available flip-flop instead of its excitation table. In step 2 you know the transition and want the inputs: that is the excitation table.
Forgetting Q as a K-map variable. Most conversions need the present state (for example, S = JQ′). A K-map with only J and K cannot express this.
Ignoring don't-cares. Without the x entries, SR-from-JK would come out with extra gates instead of simply J = S, K = R.
Treating the invalid rows of a required SR as 0. When the required flip-flop is SR, the S = R = 1 rows are don't-cares for every available input.
Writing D = T for T-from-D. That gives a D flip-flop that loads T, not one that toggles. The answer is D = T ⊕ Q.
Interview and GATE-Style Questions
How do you convert a JK flip-flop into a T flip-flop? Into a D flip-flop?
T: tie J and K together and call the common input T (J = K = T). D: connect J = D and K = D′ (one inverter).
What logic converts a D flip-flop into a T flip-flop?
An XOR gate: D = T ⊕ Q. When T = 0 the flip-flop reloads Q (hold); when T = 1 it loads Q′ (toggle).
Convert a T flip-flop into a JK flip-flop.
T = JQ′ + KQ. From the K-map of T over J, K, Q: when Q = 0 toggle if J = 1, when Q = 1 toggle if K = 1.
In the conversion of a JK flip-flop to an SR flip-flop (SR available), can the SR inputs ever both be 1?
No. S = JQ′ and R = KQ; S needs Q = 0 and R needs Q = 1, so they are never 1 at the same time.
A D flip-flop has D = A ⊕ Q, where A is an external input. What flip-flop does this behave like?
Q+ = A ⊕ Q, which is the T flip-flop equation with T = A. It is a T flip-flop.
A D flip-flop has D = XQ′ + Y′Q. What is it equivalent to?
Compare with Q+ = JQ′ + K′Q: it is a JK flip-flop with J = X and K = Y.
Summary
Conversion = combinational logic in front of an available flip-flop so that it follows a required flip-flop's characteristic table.
Method: characteristic table of the required flip-flop → excitation table of the available flip-flop → K-maps (with Q as a variable and x as don't-cares) → logic.
Key results: JK from SR: S = JQ′, R = KQ. D from JK: J = D, K = D′. T from JK: J = K = T. Any from D: D = Q+. Any from T: T = Q ⊕ Q+.
The same procedure, applied to many flip-flops at once, is how synchronous counters and state machines are designed.
Next, in Registers & Shift Registers, we put several flip-flops side by side to store and move whole words of data.