C738 of 57
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

C7 · Lesson 38 · Analyzing sequential circuits

From a schematic of flip-flops and gates to a state table, a diagram, and what the circuit is for

Lesson 37 went from a description to a state machine; lesson 39 will turn a design into flip-flops and gates. This lesson runs the other way, which is what you do when you inherit a schematic, debug someone else's board, or check that a synthesized netlist does what the description said. The method is mechanical: the flip-flops' outputs are the state, their inputs are the next state, and a table of every state, including the ones that should never happen, tells you what the circuit does. Those "impossible" states matter. A circuit that powers up in one of them may never leave, and finding that on paper is much cheaper than finding it in the field.

  • Two D flip-flops wired as D1=Q0 and D0=Q¯1. Run the clock and read the state Q1Q0 off the waveforms.
  • It steps 00 → 01 → 11 → 10 → 00: a four-state counter in which only one bit changes per step, a two-bit Johnson counter.

Predict

A 3-bit ring counter has D2=Q1, D1=Q0, D0=Q2 and is meant to circulate a single 1: 001 → 010 → 100. It powers up in state 000. What happens?

Name it

The procedure

  1. State variables: each flip-flop's output. n flip-flops give up to 2n states.
  2. Next-state equations: for D flip-flops, Q+=D. For T flip-flops, Q+=T⊕Q. For JK flip-flops, Q+=JQ¯+K¯Q.
  3. Output equations: if the outputs depend only on the state, it's a Moore machine; if they also depend directly on the inputs, Mealy.
  4. State table: for every present state and input, the next state and output. Include every state, not just the expected ones.
  5. State diagram: draw it, and describe the behavior: a counter, a detector, a controller.
  6. Unused states: check where each one leads. If any can't reach the main cycle, the circuit can lock out.

Timing

The analysis also gives the fastest clock: the longest path from a flip-flop's output through logic to a flip-flop's input must fit in one period (lesson 27):

fmax=1tcq+tlogic,max+tsu

Self-correcting designs

A circuit is self-correcting when every unused state leads, in some number of clocks, into the intended cycle. The cheapest fix is often to change one next-state equation so the unused states fall through. For the ring counter, D0=Q¯1Q¯0 instead of Q2 keeps the three-state cycle and sends every other state into it.

Worked example

Analyze three T flip-flops with T0=1, T1=Q0, T2=Q1Q0. What does the circuit do, and how fast can it run with 80 ps clock-to-Q, 40 ps AND gates and 30 ps setup?

Show the solution
  1. What each flip-flop does. Q0 toggles every clock, Q1 toggles when Q0 = 1, and Q2 toggles when Q1=Q0=1.
  2. Trace it. From 000: 001, 010, 011, 100, 101, 110, 111, 000: a 3-bit binary up counter, using all eight states, so no lockout is possible.
  3. Find the longest path. It runs from Q0 or Q1 through the AND gate to T2: 80+40+30=150ps
  4. Maximum frequency. fmax=1150ps=6.67GHz Wider counters chain more ANDs, or use lookahead, as adders do.

Answer a 3-bit binary up counter, which can run at up to 6.67 GHz.

Worked example

A circuit has one input x, two D flip-flops with D1=xQ0 and D0=x, and output z=Q1. Build its state table and describe it.

Show the solution
  1. Read the equations. Q0+=x remembers the last input; Q1+=xQ0 is 1 when the current and previous inputs were both 1.
  2. Build the state table.
Q1Q0x = 0x = 1z
0000010
0100110
1000011
1100111
  1. Describe it. The output is 1 one clock after two consecutive 1s have arrived: a "11" detector.
  2. Classify it. z depends only on the state, so it's a Moore machine.
  3. Check for lockout. All four states are reachable and every one goes to 00 on a 0, so there's no lockout.

Answer a Moore machine that detects "11": z is 1 one clock after two consecutive 1s.

Worked example

Check the ring counter of the predict question with D0 changed to Q¯1Q¯0. Is it self-correcting?

Show the solution
  1. Tabulate. Each state goes Q2Q1Q0→Q1,Q0,Q¯1Q¯0.
  2. The intended cycle. 001 → 010 → 100 → 001.
  3. The unused states. 000 → 001; 011 → 110 → 100; 101 → 010; 111 → 110 → 100.
  4. Check. Every unused state reaches the cycle within two clocks: self-correcting, with one 2-input NOR gate in place of a wire.

Answer yes: every unused state reaches the cycle within two clocks.

Check

Two D flip-flops have D1=Q1⊕Q0 and D0=Q¯0. The present state Q1Q0 is 01. What is the next state?

Check

A ring counter has D2=Q1, D1=Q0, D0=Q2. From state Q2Q1Q0 = 010, what's the next state?

Check

Write the next state Q+ of a JK flip-flop.

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

A 3-bit binary up counter built from T flip-flops: write T2.

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

A sequential circuit's flip-flops have 80 ps clock-to-Q and 40 ps setup, and its longest logic path is 100 ps. What's its maximum clock frequency?

Write units the way you normally would: 1.5 GHz, 1500 MHz and 0.0015 THz are the same answer.

Check

A 4-bit Johnson counter has Dn−1=Qn−2,…,D1=Q0 and D0=Q¯n−1. How many states are in its main cycle?

Check

A circuit's output is z=xQ1, where x is an input and Q1 a flip-flop. What kind of machine is it, and what does that mean for timing?

Check

Write analyze(next_state, n) for a circuit with no inputs, where next_state(s) gives the next state of an n-bit state s. Return (cycles, lockout): cycles is a sorted list of the cycles' lengths (each cycle counted once), and lockout is True if more than one cycle exists. Test it on a ring counter and a Johnson counter of 5 bits, setting ring and johnson to the results.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

A board's 4-bit Johnson counter works perfectly after power-up on the bench but sometimes produces a wrong sequence after an electrostatic discharge. Explain how analyzing its unused states explains the failure, and how to fix it.

Practice

Keep practicing

7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.