Module 3: Sequential Circuit Design · 3.3 Finite State Machines

State Diagrams and State Tables

A digital designer can specify a finite state machine using a graphical state diagram or a tabular state transition table. Both representations contain identical functional data.

The state diagram visualizes sequential behavior during system architecture. The state table provides the structured format needed to derive next-state Boolean logic.

State Diagram Conventions

A state diagram is a directed graph:

  • Vertices (States): Represented by circles containing the state identifier. In a Moore machine, the associated output value appears inside the circle (e.g., StateName / Output).
  • Directed Edges (Transitions): Represented by arrows connecting states. In a Mealy machine, the transition arrow contains both input condition and output value (e.g., InputCondition / Output).
  • Initial Reset State: Indicated by an incoming arrow originating from a solid dot.
  • Transition Conditions: Written in minimal Boolean form. If multiple input conditions cause the same transition, join them with an OR operator.

For a deterministic state machine, outgoing transition conditions from any single state must be mutually exclusive and exhaustive.

State Transition Tables

A state transition table specifies next-state transitions $\delta(s, i)$ and output assignments $\lambda$.

For $|S|$ states and $|I|$ binary inputs, the complete truth table contains $|S| \times 2^{|I|}$ rows:

Present State Input Vector Next State Output Vector

Once state identifiers receive binary encodings, the table defines the truth tables for next-state flip-flop inputs and combinational outputs.

Worked Example: Overlapping Serial Sequence Detector (1011)

Design a serial sequence detector that asserts output $Z = 1$ when the input bit stream contains the sequence 1011.

The machine must support overlapping sequences. In an overlapping sequence, the final bits of one matched sequence can serve as the prefix for a subsequent match.

State Definitions

Each state tracks how many consecutive prefix bits of 1011 have matched:

State Matched Prefix Output ($Z$)
S0 No prefix matched 0
S1 Pattern 1 matched 0
S2 Pattern 10 matched 0
S3 Pattern 101 matched 0
S4 Pattern 1011 matched 1

Transition Evaluation

For each state, analyze the effect of incoming bit $X$:

  • In state S0:
    • $X = 0$: No matching prefix. Remain in S0.
    • $X = 1$: Pattern 1 detected. Transition to S1.
  • In state S1 (prefix 1):
    • $X = 0$: Sequence forms 10. Transition to S2.
    • $X = 1$: Sequence forms 11. The trailing 1 preserves the prefix. Remain in S1.
  • In state S2 (prefix 10):
    • $X = 0$: Sequence forms 100. No matching prefix. Return to S0.
    • $X = 1$: Sequence forms 101. Transition to S3.
  • In state S3 (prefix 101):
    • $X = 0$: Sequence forms 1010. The suffix 10 matches the two-bit prefix. Transition to S2 (overlapping transition).
    • $X = 1$: Sequence forms 1011. Transition to S4.
  • In state S4 (target 1011 detected, $Z = 1$):
    • $X = 0$: Sequence ends in 10110. The suffix 10 matches a valid prefix. Transition to S2.
    • $X = 1$: Sequence ends in 10111. The suffix 1 matches a valid prefix. Transition to S1.

Figure 1 shows the resulting Moore state diagram.

1011 detector
Figure 1: State diagram for an overlapping 1011 sequence detector

State Transition Table

The five states and two input values produce ten rows:

Present State Input ($X$) Next State Output ($Z$)
S0 0 S0 0
S0 1 S1 0
S1 0 S2 0
S1 1 S1 0
S2 0 S0 0
S2 1 S3 0
S3 0 S2 0
S3 1 S4 0
S4 0 S2 1
S4 1 S1 1

Graphical Comparison: Moore vs. Mealy Notation

Figure 2 illustrates Moore notation with outputs placed inside state vertices. Figure 3 illustrates Mealy notation with outputs placed on directed transition edges.

Moore notation
Figure 2: Moore notation showing output values associated with state vertices

Mealy notation
Figure 3: Mealy notation showing output values associated with transition edges

Common State Machine Design Errors

When creating state diagrams, inspect the design for these four structural errors:

  1. Incomplete Transitions: A state lacks transitions for specific input combinations. Ensure that the logical OR of all outgoing transition conditions from each state equals 1.
  2. Non-Deterministic Transitions: Two outgoing transitions from a single state are true simultaneously. Outgoing transition conditions must be mutually exclusive.
  3. Missing Reset Definition: The state diagram fails to identify an initial state, causing non-deterministic power-on behavior.
  4. Unassigned Outputs: Every Moore state and every Mealy transition must define all output signals explicitly.

Practice Exercises

Problem 1

Construct a Moore state diagram that detects three consecutive 1 bits (111), allowing overlapping sequences.

Solution

Define four states:

  • S0: Zero consecutive ones detected ($Z = 0$).
  • S1: One 1 detected ($Z = 0$).
  • S2: Two consecutive 1s detected ($Z = 0$).
  • S3: Three or more consecutive 1s detected ($Z = 1$).

Transitions:

  • When input $X = 0$, all states transition back to S0.
  • When input $X = 1$:
    • S0 transitions to S1.
    • S1 transitions to S2.
    • S2 transitions to S3.
    • S3 transitions to S3 (self-loop, because receiving another 1 retains three consecutive ones).

Problem 2

Convert this state description into a state transition table:

  • States: A, B (output $Z = 0$), and C (output $Z = 1$).
  • Transitions:
    • From A: Transitions to B on input 0; remains in A on input 1.
    • From B: Transitions to A on input 0; transitions to C on input 1.
    • From C: Transitions to A on input 0; transitions to B on input 1.
Solution
Present State Input ($X$) Next State Output ($Z$)
A 0 B 0
A 1 A 0
B 0 A 0
B 1 C 0
C 0 A 1
C 1 B 1

Because this is a Moore machine, output $Z$ depends only on the present state.

Problem 3

In the 1011 sequence detector, explain why state S3 transitions to S2 instead of S0 when input $X = 0$.

Solution

In state S3, the sequence detector has matched 101.

When input $X = 0$ arrives, the sequence becomes 1010. While 1010 is not a complete match, its trailing two bits (10) match the first two bits of target pattern 1011.

Transitioning to S0 would discard these valid prefix bits, causing the circuit to miss valid patterns in overlapping bit streams such as ...101011.... State S2 represents prefix 10. Therefore, the machine transitions to S2.

The next article explores state assignment techniques, comparing binary, Gray, and one-hot encoding schemes.

← Moore and Mealy Machines State Encoding →