Moore and Mealy Machines
Moore and Mealy Machines
Advertisements
Finite automata may have outputs corresponding to each transition. There are two types of finite state
machines that generate output −
Mealy Machine
Moore machine
Mealy Machine
A Mealy Machine is an FSM whose output depends on the present state as well as the present input.
q0 is the initial state from where any input is processed (q0 ∈ Q).
Next state
→a b x1 c x1
b b x2 d x3
c d x3 c x1
d d x3 d x2
https://www.tutorialspoint.com/cgi-bin/printpage.cgi 1/6
11/15/2018 Moore and Mealy Machines
Moore Machine
Moore machine is an FSM whose outputs depend on only the present state.
q0 is the initial state from where any input is processed (q0 ∈ Q).
Next State
Present state Output
Input = 0 Input = 1
→a b c x2
b b d x1
c c d x2
d d d x3
https://www.tutorialspoint.com/cgi-bin/printpage.cgi 2/6
11/15/2018 Moore and Mealy Machines
The following table highlights the points that differentiate a Mealy Machine from a Moore Machine.
Output depends both upon the present state and Output depends only upon the present state.
the present input
Generally, it has fewer states than Moore Generally, it has more states than Mealy Machine.
Machine.
The value of the output function is a function of The value of the output function is a function of the
the transitions and the changes, when the input current state and the changes at the clock edges,
logic on the present state is done. whenever state changes occur.
Mealy machines react faster to inputs. They In Moore machines, more logic is required to decode
generally react in the same clock cycle. the outputs resulting in more circuit delays. They
generally react one clock cycle later.
Algorithm 4
Step 2 − Copy all the Moore Machine transition states into this table format.
Step 3 − Check the present states and their corresponding outputs in the Moore Machine state table; if for a
state Qi output is m, copy it into the output columns of the Mealy Machine state table wherever Qi appears in
the next state.
https://www.tutorialspoint.com/cgi-bin/printpage.cgi 3/6
11/15/2018 Moore and Mealy Machines
Example
Next State
Present State Output
a=0 a=1
→a d b 1
b a d 0
c c c 0
d b a 1
Step 1 & 2 −
Next State
→a d b
b a d
c c c
d b a
Step 3 −
Next State
=> a d 1 b 0
b a 1 d 1
c c 0 c 0
https://www.tutorialspoint.com/cgi-bin/printpage.cgi 4/6
11/15/2018 Moore and Mealy Machines
d b 0 a 1
Algorithm 5
Input − Mealy Machine
Step 1 − Calculate the number of different outputs for each state (Qi) that are available in the state table of
the Mealy machine.
Step 2 − If all the outputs of Qi are same, copy state Qi. If it has n distinct outputs, break Qi into n states as
Qin where n = 0, 1, 2.......
Step 3 − If the output of the initial state is 1, insert a new initial state at the beginning which gives 0 output.
Example
Next State
→a d 0 b 1
b a 1 d 0
c c 1 c 0
d b 0 a 1
Here, states ‘a’ and ‘d’ give only 1 and 0 outputs respectively, so we retain states ‘a’ and ‘d’. But states ‘b’ and ‘c’
produce different outputs 1and0 . So, we divide b into b0, b1 and c into c0, c1.
Next State
Present State Output
a=0 a=1
→a d b1 1
b0 a d 0
b1 a d 1
https://www.tutorialspoint.com/cgi-bin/printpage.cgi 5/6
11/15/2018 Moore and Mealy Machines
c0 c1 C0 0
c1 c1 C0 1
d b0 a 0
https://www.tutorialspoint.com/cgi-bin/printpage.cgi 6/6