Analysing a Clocked Sequential Circuit
Turn a schematic of flip-flops and gates into equations, a transition table, a state table and a state diagram.
You Will Be Able To
- Read the excitation equations of each flip-flop from a schematic.
- Turn them into next-state equations with the characteristic equations of D, T and JK flip-flops.
- Build the transition table and the state table, and draw the state diagram.
- Analyse a circuit with JK flip-flops without treating J as D.
- Lesson
- G7.2
- Time
- 30 min
- Runs on
- Your browser
- Check
- 5 questions
A supplier sent a block as a netlist with no specification. Before you can use it, you must say what it does. Analysis turns gates and flip-flops into a state diagram. Step the netlist to see it move.
Step 1: Excitation Equations
- Neutral
- Structure
- Step 1
Read each flip-flop input from the gates in front of it.
- Step 2
Turn each input equation into Q+ with the flip-flop type.
- Step 3
Fill the table, name the states, draw the diagram.
Read the diagram as text
- Schematic: flip-flops and gates
- Excitation equations: D, T or J and K of each flop
- Next-state equations: through Q+ = D, T ⊕ Q, JQ' + K'Q
- Transition table: codes: present, input, next, output
- State table: the same rows with names
- State diagram: circles and arcs
- Schematic → Excitation equations: follow wires back
- Excitation equations → Next-state equations: characteristic equation
- Next-state equations → Transition table: every row and input
- Transition table → State table: name the codes
- State table → State diagram: draw it
The three steps below follow this order on the netlist above.
An excitation equation gives each flip-flop input as a function of the present state and the inputs. Read it by following the wires back from the input pin of each flip-flop.
| Flip-flop input | Gates behind it | Excitation equation |
|---|---|---|
| D of A | g4 = A·x', g5 = B·x, g6 ORs them | DA = A·x' + B·x |
| D of B | g7 = A'·x | DB = A'·x |
| output z | g8 = A·B' | z = A·B' |
From the netlist above. z reads only the state, so this is a Moore output.
Step 2: Next-State Equations
A next-state equation gives Q+ for each flip-flop. Put the excitation equations into the characteristic equation of the flip-flop type, from lesson G5.7.
| Flip-flop | Characteristic equation | For this netlist |
|---|---|---|
| D | Q+ = D | A+ = A·x' + B·x and B+ = A'·x |
| T | Q+ = T ⊕ Q | substitute T, then XOR with Q |
| JK | Q+ = J·Q' + K'·Q | substitute J and K; never Q+ = J |
For D flip-flops this step is free. For T and JK it is where most mistakes happen.
Step 3: Transition Table, State Table, State Diagram
The transition table lists, for each present state code and input, the next code and the output. Give the codes names and it becomes the state table. Draw it and you have the state diagram.
| Present AB | Next AB, x = 0 | Next AB, x = 1 | z |
|---|---|---|---|
| 00 | 00 | 01 | 0 |
| 01 | 00 | 11 | 0 |
| 11 | 10 | 10 | 0 |
| 10 | 10 | 00 | 1 |
The transition table, one row per present state, filled from the next-state equations.
Row 00
A = B = 0. A+ = Ax' + Bx = 0 for both x. B+ = A'x = x. So 00 or 01.
Row 01
A+ = Bx = x and B+ = x: 00 or 11.
Row 11
A+ = x' + x = 1 and B+ = A'x = 0: always 10.
Row 10
A+ = x' and B+ = 0: 10 or 00. z = AB' = 1 only here.
Run It and Compare
The lab bench feeds a stream that takes every pair of state and input at least once. Each line is one row of the table. If a line differs from your table, your equations or your table hold the error.
Asked in interviews
How do you find what an unknown sequential circuit does?
Write the excitation equations from the gates in front of each flip-flop. Turn them into next-state equations with the characteristic equations. Fill the transition table, name the states and draw the diagram.
What is the difference between a transition table and a state table?
The transition table uses the binary state codes. The state table uses symbolic state names. They hold the same arcs.
J = 0 and K = 0 on a JK flip-flop that holds 1. What is the next state?
It stays 1. Q+ = JQ' + K'Q = 0 + 1·1 = 1. Treating J as D would give 0, a common analysis mistake.
Try It
Fill the transition table by hand first. Then run and check each line against it.
Lines 7 and 8 show z = 1. State 10 is the only state with z = 1, whatever x is.
Change g7 to and g7 (db, nb, x); and predict which rows change before you run it.
AB=00 x=0 z=0 -> AB=00 AB=00 x=1 z=0 -> AB=01 AB=01 x=0 z=0 -> AB=00 AB=00 x=1 z=0 -> AB=01 AB=01 x=1 z=0 -> AB=11 AB=11 x=0 z=0 -> AB=10 AB=10 x=0 z=1 -> AB=10 AB=10 x=1 z=1 -> AB=00 AB=00 x=1 z=0 -> AB=01 AB=01 x=1 z=0 -> AB=11 AB=11 x=1 z=0 -> AB=10Read included file: tb.sv
// tb.sv: the bench (read-only). From reset it feeds a stream that takes every (state, x) pair at least once.
module tb;
logic clk = 0, rst = 1, x = 0;
logic A, B;
wire z;
mach dut (.clk(clk), .rst(rst), .x(x), .A(A), .B(B), .z(z));
string stream = "01011001111";
initial begin
#1 clk = 1; #1 clk = 0; rst = 0;
for (int i = 0; i < stream.len(); i++) begin
x = (stream[i] == "1");
#1 $write("AB=%b%b x=%b z=%b", A, B, x, z);
#1 clk = 1; #1 clk = 0;
$display(" -> AB=%b%b", A, B);
end
end
endmodule
Check Yourself
Common Mistakes
Wrong Write the present state in the next-state column.
The table answers "where does the edge take it?" Copying the row label makes every state a self-loop.
Fix Evaluate each D (or J and K) for that row and that input, then apply the characteristic equation.
Wrong Use J as the next state of a JK flip-flop.
Q+ = JQ' + K'Q. With J = 0 and K = 0 the flop holds 1, but "J as D" clears it.
Fix Substitute J and K into JQ' + K'Q. Only a D flip-flop has Q+ = D.
Wrong Read a Moore output from the next state.
The output belongs to the present state, in the cycle before the edge. Reading it from the next state shifts every output one cycle early.
Fix Put the output in the row of the present state; for a Mealy output, in the row and the input column.
Wrong Update one flip-flop and use its new value to compute the other.
Every flop of a synchronous circuit loads at the same edge, from values that settled before it.
Fix Compute every next state from the same present state and input, then update all flops together.
Remember
- Analysis runs: excitation equations, next-state equations, transition table, state table, state diagram.
- Excitation equations read the present state and the inputs, from the gates in front of each flip-flop.
- Q+ = D, Q+ = T ⊕ Q and Q+ = JQ' + K'Q turn them into next-state equations.
- All flip-flops load together at the edge; compute every next state from the same present state.