State Reduction

Some state machines contain more states than they really need. Two states that cannot be told apart from the outside are equivalent, and merging them gives a smaller machine that behaves in exactly the same way. Fewer states can mean fewer flip-flops and simpler logic, so state reduction is a worthwhile step before you choose a state assignment. You should know state tables and how to count flip-flops from the number of states.

Learning objectives

After this lesson you will be able to:

  • Define equivalent states.
  • Find equivalent states with the row-matching method.
  • Repeat the matching until no more states can be merged.
  • Explain why states with equal outputs may still be different.
  • Calculate the flip-flop saving from a reduction.

What makes two states equivalent

Two states are equivalent if, for every possible input sequence, the machine produces the same output sequence whichever of the two states it starts in. From the outside there is no way to tell them apart, so one of them is redundant. In practice we use two conditions for states in a Moore-style table, where each state has an output:

  1. Both states have the same output.
  2. For each input value, they go to the same state, or to states that are themselves equivalent.

The row-matching method

  1. Look for two states with identical rows in the state table: same output and the same next state for every input.
  2. Merge them: delete one state and replace its name by the other everywhere in the table.
  3. Check the table again. The merge may have made two other rows identical.
  4. Repeat until no two rows match.

Example 1: reducing a 5-state machine

Here is the original state table.

State x = 0 x = 1 Output z
A B C 0
B D E 0
C D E 0
D A B 1
E A C 1

Pass 1. States B and C have the same output (0) and the same next states (D and E), so they are equivalent. Replace every C by B. State E now goes to A and B for the inputs 0 and 1, which is exactly what D does.

Pass 2. States D and E now have the same output (1) and the same next states (A and B), so they are equivalent. Replace every E by D. No more rows match.

The reduced machine has three states.

State x = 0 x = 1 Output z
A B B 0
B D D 0
D A B 1

Result: the five states A, B, C, D and E become the three classes {A}, {B, C} and {D, E}. A script that fed all 256 input sequences of length eight to both machines found identical outputs every time. The number of flip-flops falls from 3 to 2, because 3 states need only 2 flip-flops.

Example 2: states with equal outputs that are not equivalent

Equal outputs are not enough. Take a machine where the output is 0 in states P and Q and 1 in state R. From P an input of 1 goes to Q, and from Q an input of 1 goes to R.

If the machine starts in P and receives a 1, the outputs are 0 and then 0. If it starts in Q and receives the same 1, the outputs are 0 and then 1. An observer can tell the two apart with a single input, so P and Q are not equivalent, even though their outputs match.

Result: always compare the next states as well as the outputs. A pair of states is only equivalent if every successor pair is equivalent too.

Example 3: equivalent states with different rows

Sometimes two states are equivalent even though their rows are different. In this 6-state table, state 1 is the start state.

State x = 0 x = 1 Output z
1 5 3 1
2 6 2 0
3 5 4 1
4 6 2 1
5 2 2 1
6 2 2 0

States 2 and 6 have the same output 0, but their next states are different: state 2 goes to 6 and 2, while state 6 goes to 2 and 2. Assume that 2 and 6 are equivalent. Then the successors of 2 (6 and 2) and of 6 (2 and 2) are all in the same class, so the assumption is consistent and the two states can be merged. In the same way, states 4 and 5 have output 1, and their successors (6 and 2, or 2 and 2) belong to the class {2, 6}, so 4 and 5 are equivalent too.

Result: the classes are {1}, {2, 6}, {3} and {4, 5}, so the machine reduces to 4 states. A script confirmed that the reduced machine matches the original on all 512 input sequences of length nine. The method of assuming equivalence and checking is the idea behind the implication table, a systematic way of checking every pair of states, which is useful for larger machines.

Common mistakes

  • Merging states with the same output only. The next states must match as well.
  • Stopping after one pass. A merge can make new rows identical, as in Example 1.
  • Forgetting to rename states after a merge. Every reference to the deleted state must be changed.
  • Missing equivalent states with different rows. Rows can differ only because of states that are themselves equivalent.
  • Merging unreachable states by mistake. First delete states that can never be reached from the start state.

Practice problems

Use the table of Example 3 for the first two problems.

  1. Which pairs of states are equivalent in the table of Example 3?

    Answer: 2 and 6, and 4 and 5.

  2. How many flip-flops does the machine need before and after reduction?

    Answer: 3 flip-flops for 6 states, and 2 flip-flops for 4 states.

  3. A machine has 9 states, and state reduction brings it down to 5. How many flip-flops are saved?

    Answer: 4 flip-flops are needed for 9 states and 3 for 5 states, so one flip-flop is saved.

  4. Two states have the same output, and their next states are different states with different outputs. Are the two states equivalent?

    Answer: No. A single input sequence can tell them apart, because their successors behave differently.

Frequently asked questions

Why reduce the number of states? Fewer states can mean fewer flip-flops and simpler next-state logic, which saves area, power and cost. The behaviour seen from outside stays the same.

Does state reduction always remove a flip-flop? No. The number of flip-flops depends on the next power of two. A machine with 7 states needs 3 flip-flops, and so does a machine with 5, so reducing from 7 to 5 saves no flip-flops, though it may still simplify the logic.

What is an implication table? It is a triangular chart with one cell for every pair of states. Each cell records the pairs of next states that must be equivalent for the two states to be equivalent. Pairs are crossed out when a requirement fails, and the remaining pairs are equivalent.

To simplify the next-state equations of the reduced machine, use the K-map tool or the Boolean calculator.

Next: you have now covered the main sequential building blocks. Continue with Digital System Design, where these blocks are combined into complete systems.