Moore and Mealy
Moore and Mealy
By
Sangeeta Bhanja Chaudhuri
Finite Automata with outputs
• Finite automata may have outputs corresponding to each
transition.
• There are two types of finite state machines that generate
output.
• A Mealy Machine is an FSM whose output depends on the present state as well as
the present input.
• The output is associated with the transition.
Mealy Machine
Mealy Machine
Mealy Machine
q1 q0 1 q1 0
Mealy Machine
Q. Design a Mealy machine for a binary input sequence such that if it has a substring 101, the
machine output A, if the input has substring 110, it outputs B otherwise it outputs C.
Solution: For designing such a machine, we will check two conditions, and those are 101 and 110. If we get
101, the output will be A. If we recognize 110, the output will be B. For other strings the output will be C.
We then insert the possibilities of 0's and 1's for
each state. Thus, the Mealy machine becomes:
Moore Machine
Moore Machine
The state table of a Moore Machine/ state diagram is shown below:
q0 q0 q1 1
q1 q0 q1 0
Use of Mealy and Moore Machine
Class work: Q1. Design a state table for the Mealy
machine and show the transition with input 11 and
output?
Hint: Solve
(δ (q0,11)) .
Output: 00
Class work: Q2. Design a state table for the Moore
machine and show the transition with input 11 and
output?
Hint: Solve
(δ (q0,11)) .
Output: 000
Conversion of Moore Machine to Mealy Machine
1. Transition Table
2. Transition Diagram
Q3. Design a Moore machine takes the binary number {0, 1} as input and produce residue
modulo ‘3’ as output. Convert the Moore Machine to Mealy Machine (Using Transition Table).
Hint: Residue modulo ‘3’ as output means when the equivalent decimal number of
binary input over {0, 1} is divided by 3 then it gives output as it’s remainder.
Let us start with number 1. We can see that remainder 1 is left when 1, 4, 7 .... are divided
When 1 is divided by 3, remainder is 1. by 3.
When 2 is divided by 3, remainder is 2.
When 3 is divided by 3, remainder is 0.
When 4 is divided by 3, remainder is 1.
When 5 is divided by 3, remainder is 2.
When 6 is divided by 3, remainder is 0.
When 7 is divided by 3, remainder is 1.
When 8 is divided by 3, remainder is 2.
When 9 is divided by 3, remainder is 0.
Q3. Design a Moore machine takes the binary number {0, 1} as input and produce residue
modulo ‘3’ as output. Convert the Moore Machine to Mealy Machine (Using Transition Table).
X X Y 0
Y Z X 1
Z Y Z 2
To convert Moore M/c to Mealy M/c
In the above transition table, States ‘X’, ‘Y’ and ‘Z’ are kept in the first
column which on getting ‘0’ as the input it transits to ‘X’, ‘Z’ and ‘Y’
states respectively, kept in the second column and on getting ‘1’ as
the input it transits to ‘Y’, ‘X’ and ‘Z’ states respectively, kept in the
third column and In the fourth column under Δ, there are
corresponding outputs of the first column states. In the table, An
arrow (→) indicates the initial state.
To convert Moore M/c to Mealy M/c
• Step1: Create a State Transition Table for the Mealy machine from the above Moore machine.
• Step 2: Fill the next states first.
• Step 3: Then see the Moore transition table (present state and Output and fill them accordingly in the mealy machine transition table.
• To redraw the original states without the output. The starting state
remains the same.
1. Find the states that have more than one output associated with
them in each column. For such states, divide them into two.
2. Rewrite the transition table, including the new states, and add an
output column. Then, fill in the destination state entries using the
original table.
3. Check for the output of each state in the destination column and fill
in the output column.
4. Remove the output symbols from the destination columns.
Steps to convert Mealy Machine to Moore
Machine (Using Transition table)
• Draw the transition table
q1 q0 a q1 a
Note: We found that next state, the state q1 has two different outputs for the input symbols; hence we will
make them into two states q1a (q1 with output a) and q1b (q1 with output b).
Steps to convert Mealy Machine to Moore Machine (Using
Transition table)
• Now, let’s create the transition table for Moore machine. (the
transition of q0 on 0 is towards q1 in the Mealy machine, but in
this case, we have split q1 in two states. As a result, we see the
corresponding output of that transition. In this case, the
output is b; therefore, the destination will be q1b.)
q0 q1b , b q0, a
q0 q1b , b q0, a a
Solution: Step 1: Take the initial state and draw its first transition. The transition had an output b , that is now
transferred to our destination node q1.
Step 2: Now, for the second transition of state q0:
Step 5: Now add transitions to the new state, we get the following state diagram. we know from the
Mealy machine that q1 at 0 goes to q0 and gives an output a, so we use the same logic to form the
new transition .
Question Bank
Q1. Draw a mealy machine from the given state transition table. Q2. Draw a Moore machine for the given state transition table.
Draw a Moore machine for the same table Draw a mealy machine for the same table.
Question Bank
Q3. Design a state transition table for the mealy machine. Design a moore machine for the same and draw the
state diagram.
Question Bank
Q4. Design a state transition table for the Moore machine.
Q5. Convert the given Moore machine to mealy machine (Using Transition Table and Transition Diagram).
Question Bank
Q6. Convert the given mealy machine to Moore machine (Using Transition Table and Transition Diagram).
Note: Any Moore/ Mealy machine diagram will be given in the question paper. Similarly, any state
transition table will be given. Practice from different examples.