ECE221 Fall, 1999

On Mealy and Moore Finite State Machines.
Both kinds of machines consist of flip-flop whose inputs are logical combinations of the input signals and the values of the flip-flop Q and Q' outputs.They differ in how the outputs of the machine are determined. For a Moore machine the outputs depend only on the Q and Q' flip-flop outputs. For a Mealy machine the outputs may depend on both the Q and Q' flip-flop outputs and the current inputs. Thus the outputs of a Mealy machine can change whenever the inputs change, even if this occurs "between clock pulses". In the figure, we see that the output of a Moore machine is associated with the state itself, whereas with a Mealy machine the output is associated with both the state the machine is now in and the current values of the inputs.


In general if a machine has N states, it will require M flip-flops, where M is the smallest number such that  N is less than or equal to 2M. If the system has D inputs, there are 2D paths flowing out of each state. If there are K outputs, for a Moore machine each state is labeled with K output values; for a Mealy machine each path is labeled with K outputs.

An Example of Designing a Moore Finite State Machine

Problem:
 Design a Moore finite State Machine that accepts an input binary sequence such as 001010011101.... Its output is zero except when the number of 1's that have been input is a multiple of three. Implement the machine using as few flip-flops as possible, and using only JK-flip-flops.

In the example below, the output that is observed after each input bit is received is shown directly below the input bit received:

input :     -    0 1 0 0 1 1 0 0 1 0 1 0 0 1 0 1 0 1 1 0 1 1 0 1 1 0 1 1 ...
output:    1   1 0 0 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 1 0 0 0 1 ...

(Note: before any bits have been received the output is 1, since zero 1's is also a multiple of three.)

Solution:
Step 1: Find/invent the states for this machine.
Three things can be true for this machine:
1). It has seen a multiple of three 1's in the input sequence; (e.g. it has seen 3, or 12, or 69, or 3333 1's, etc.)
2). It has seen one in excess of a multiple of 3 1's; (e.g. it has seen 4, or 1, or 7 1's, etc.)
3). It has seen two in excess of a multiple of 3 1's; (e.g. it has seen 5, or 14, or 23 1's, etc.)

There are three states to the machine. The figure shows the resulting state transition diagram. An input of 1 carries you to the next state cyclically; an input of 0 leaves you in the same state. The output is 1 only in the "got a multiple of 3" state. Because this is a Moore machine the output is noted inside the state itself.

Step 2: Determine how many flip flops are required. For a machine with three states, count up to the next power of 2, which is 4, which is 2 raised to the second power, so two flip-flops are needed.

Step 3: Assign flip-flop states to the three machine states. Call the flip-flops A and B, so the value 01 means A is in state 0 and B is in state 1. Choose any assignment, as long as different states receive different assignments. I'll use:

got a mult. of 3:  10
got one extra:  11
got two extra: 01

Now it's possible the machine will go into state 00 when it is powered on, so we must decide what the output for that state is, and its transitions to the "real" machine states.

One approach is to say that if the machine starts in state 00 then no 1's have been input, which is a multiple of 3, so the output should be 1. And if a 0 is now input the transition goes to the real "got a mult. of 3 state, represented by 10; If a 1 is input it goes to "got one extra", represented by 11.

The next figure shows the final state transition diagram for the machine.

Step 4: Write down the state transition table, which lists for every possible state and input combination what the next state will be, and what the current output is.

Step 5: Choose what type of flip-flop to use for each flip-flop in the system, and add columns to the state transition table for each input of each flip-flop. Here we use JK-flip-flops for the two flip-flops.  Add in the required excitations for each input, using the usual excitation table for a JK-flip-flop.

Step 6: Set up a Karnaugh map for each flip-flop input, and for each output. Find the minimal combinational circuit that accurately represents each quantity.
Here this results in:
JA = B' + in
KA = B . in
JB = in
KB = A'. in
out = B'

Step 7: Draw the circuit.        (Left as an exercise.)