A sequence detector is a finite state machine that watches a serial input bit by bit and asserts an output when it sees a target pattern. The design walkthrough below uses one as a worked example for the standard FSM design flow — useful for any FSM, not just sequence detection.

The target: detect two or more consecutive s on input . When the input has been for at least two consecutive cycles, output should be .

The standard FSM design steps

  1. Obtain circuit specification — what should the circuit do?
  2. Derive a State diagram — graphical representation of states and transitions.
  3. Create a State table — tabular form of the diagram.
  4. Minimize states (see State Reduction).
  5. Perform State Assignment — assign binary codes to states.
  6. Choose a flip-flop type (D, T, or JK).
  7. Derive next-state logic — Boolean expressions for the flip-flop inputs.
  8. Derive output logic — Boolean expressions for the outputs.
  9. Implement the circuit — draw the final schematic.

This is the universal flow. Every FSM you build follows the same steps; only the specifics of each step change.

The walkthrough below executes those nine steps for this sequence detector. Step 1 (specification) is the prose paragraph above. Step 4 (state reduction) is skipped — the three states identified are already minimal. The remaining steps map onto the section headers:

9-stepSection heading below
2State diagram
3State table
5State assignment
6, 7, 8Choose flip-flop type and derive logic
9Final implementation

Step 2 — State diagram

Three states are needed: A (no recent 1s, the reset state), B (just saw one 1), and C (have seen two consecutive 1s — output asserted).

Reading: from A on input 0 stay; on input 1 go to B. From B on 0 return to A; on 1 advance to C. From C on 0 return to A; on 1 stay at C.

The output is associated with the state (Moore machine style): , , .

Step 3 — State table

Present stateNext ()Next ()Output
AAB0
BAC0
CAC1

Step 5 — State assignment

Three states need 2 bits. Use as the state variables, encoded as:

State
A00
B01
C10

The fourth pattern is unused (a don’t-care).

Steps 6, 7, 8 — Choose flip-flop type and derive logic

Pick D flip-flops — they make the next-state logic the simplest, since next-state value directly.

State-assigned table:

Present Next ()Next ()
A: 0000010
B: 0100100
C: 1000101
11 (don’t care)ddddd

Now build K-maps for , , and (each as a function of ).

Reading off the K-maps (with don’t-cares used to enlarge groups):

The output happens to collapse to just — the second state bit is the output. That’s a consequence of the lucky state assignment.

The general structure of the FSM:

Two flip-flops hold the state; combinational logic feeds their D inputs from and the current state; another piece of combinational logic produces (here trivially: ).

Step 9 — Final implementation

The completed circuit:

  • — small AND chain.
  • — OR followed by AND.
  • — direct wire.
  • Both flip-flops share a clock and a Resetn (asynchronous reset, active low) input that initializes the FSM to state A on power-up.

Lessons from the example

  • A state diagram is the right place to start. Don’t go to logic until you’ve drawn one.
  • State assignment matters. The choice made — a different assignment would have required gates for .
  • Don’t-cares from unused state codes can simplify the next-state logic substantially. Use them in K-map grouping.
  • D flip-flops + K-map minimization is the simplest path. T or JK can save a gate or two but rarely justify the complexity.

For variations of this problem and other FSM patterns (vending machine, traffic light, parity checker), the same nine-step flow applies — only the state diagram changes.