Mealy and Moore Machine
Mealy and Moore Machine
Output
CSE 322
Formal Language and
Automata Theory
1
Today’s Topics
• State Machines
– How to design machines that go through a
sequence of events
• “sequential machines”
2
Synchronous Sequential Logic
Pipelines
4
Finite State Machine (FSM)
• Consists of:
– State register that
CLK
• holds the current state
• updates it to the “next S’ S
state” at clock edge Next Current
State State
Next State
– Combinational logic (CL) Logic
that CL Next
State
• computes the next state
– using current state and Output
inputs Logic
In Both:
Next state is determined by current state and
Moore and Mealy FSMs
Moore FSM
CLK
M next
next k state k output N
inputs state
state
outputs
logic
logic
Mealy FSM
CLK
M next
next k state k state output N
inputs state outputs
logic
logic
7
Formal Definition of Moore Machine
8
Representation method of Moore
Machine
9
The state table of a Moore Machine is
shown below −
Next State
→a b c x2
b b d x1
c c d x2
d d d x3
10
Formal Definition of Mealy Machine
A Mealy Machine is an FSM whose output depends on the
present state as well as the present input.
It can be described by a 6 tuple (Q, ∑, O, δ, X, q0) where −
Q is a finite set of states.
∑ is a finite set of symbols called the input alphabet.
O is a finite set of symbols called the output alphabet.
δ is the input transition function where δ: Q × ∑ → Q
X is the output transition function where X: Q × ∑ → O
q0 is the initial state from where any input is processed (q0 ∈
Q).
11
Representation method of Mealy
Machine
12
The state table of a Mealy Machine is
shown below −
Next state
→a b x1 c x1
b b x2 d x3
c d x3 c x1
d d x3 d x2
13
14
Designing of Moore Machine
Ex#1 :Design a Moore machine for a binary input sequence such that if it
has a substring 101, the machine outputs A, if the input has substring 110, it
outputs B otherwise it outputs C
15
Ex#1
16
EX#2: Design a Moore machine to
generate 1's complement of a binary
number.
Explanation
Step 1 − q0 is the start state on input ‘0’ goes to q1 state and
on ‘1’ goes to state q2 generating output 0.
Step 2 − q1 on input ‘0’ goes to q1 itself and on ‘1’ goes to
q2 generating output ‘1’.
Step 3 − q2 on input ‘0’ goes to q1 and on ‘1’ goes to q2
generating output ‘0’.
17
Ex#2:
18
Designing of Mealy Machine
19
Solution of Ex#1
20
For Example : Take one binary number 10111001 then look at thetake
one binary number 10111001 then look at the following table following
table
21
Ex#2: Design a Moore machine to
generate 1’s complement of a any
given binary input.
22
Solution of Ex#2:
23
Ex#3: Design a mealy machine to
determine the residue mod 3 of a
binary number.
24
Solution of EX#3
25
Equivalence in Moore and Mealy
Machine
26
1. Conversion from mealy to moore
Mealy Machine to Moore Machine
Algorithm
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.
28
Now Draw the Transition Diagram of
equivalent Moore Machine
29
Ex#2:
30
31
1. For state q1, there is only one incident edge with output 0.
So, we don't need to split this state in Moore machine.
2. For state q2, there is 2 incident edge with output 0 and 1.
So, we will split this state into two states q20( state with
output 0) and q21(with output 1).
3. For state q3, there is 2 incident edge with output 0 and 1.
So, we will split this state into two states q30( state with
output 0) and q31( state with output 1).
4. For state q4, there is only one incident edge with output 0.
So, we don't need to split this state in Moore machine.
32
33
Ex# 3:
34
Solution
35
2. Conversion from Moore To Mealy
1. In the Moore machine, the output is associated with every
state, and in the mealy machine, the output is given along
the edge with input symbol. The equivalence of the Moore
machine and Mealy machine means both the machines
generate the same output string for same input string.
36
37
The equivalent Mealy machine can be obtained as follows:
λ' (q0, a) = λ(δ(q0, a))
= λ(q1)
=0
40
Solution of Ex#2
41
Ex#3:
42
Solution of Ex#3
43
END of TOPIC
Thanks to All
44