0% found this document useful (0 votes)
334 views44 pages

Mealy and Moore Machine

Uploaded by

kumarashish91100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
334 views44 pages

Mealy and Moore Machine

Uploaded by

kumarashish91100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 44

Finite State Machines With

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”

– Basically close the feedback loop in this


picture:

2
Synchronous Sequential Logic

• Flip-flops/registers contain the system’s state


– state changes only at clock edge
• so system is synchronized to the clock
– all flip-flops receive the same clock signal
(important!)
– every cyclic path must contain a flip-flop
Two common types
 Two common synchronous sequential
circuits:

Finite State Machines (FSMs)

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

• computes the outputs CL Outputs


– using current state (and
maybe inputs)
More and Mealy FSMs
 Two types of finite state machines differ
in the output logic:
Moore FSM:
outputs depend only on the current state
Mealy FSM:
outputs depend on the current state and the
inputs
can convert from one form to the other
Mealy is more general

 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

Moore machines are finite state machines with outp


ut value and its output depends only on
present state. It can be defined as (Q, q0, ∑, O, δ, λ
) where:
Q is finite set of states.
q0 is the initial state.
∑ is the input alphabet.
O is the output alphabet.
δ is transition function which maps Q×∑ → Q.
λ is the output function which maps Q → O.

8
Representation method of Moore
Machine

9
The state table of a Moore Machine is
shown below −
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

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

Present input = 0 input = 1


state
State Output State Output

→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

Ex # 1 :Design a Mealy Machine that prints “a”


whenever the sequence “01” is encountered in any
input binary string.

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

1. Conversion from Mealy to Moore


2. Conversion from Moore to Mealy

26
1. Conversion from mealy to moore
Mealy Machine to Moore Machine

Algorithm

Input: Mealy Machine


Output: Moore 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.......
27
Example Let us consider the following Mealy Machine

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.

2. We cannot directly convert Moore machine to its


equivalent Mealy machine because the length of the
Moore machine is one longer than the Mealy machine for
the given input. To convert Moore machine to Mealy
machine, state output symbols are distributed into input
symbol paths. We are going to use the following method to
convert the Moore machine to Mealy machine.

36
37
The equivalent Mealy machine can be obtained as follows:
λ' (q0, a) = λ(δ(q0, a))
= λ(q1)
=0

λ' (q0, b) = λ(δ(q0, b))


= λ(q0)
=0
The λ for state q1 is as follows:
λ' (q1, a) = λ(δ(q1, a))
= λ(q1)
=0

λ' (q1, b) = λ(δ(q1, b))


= λ(q2)
=1
The λ for state q2 is as follows:
λ' (q2, a) = λ(δ(q2, a))
= λ(q1)
=0

λ' (q2, b) = λ(δ(q2, b))


= λ(q0)
=0 38
39
Ex#2:

40
Solution of Ex#2

41
Ex#3:

42
Solution of Ex#3

43
END of TOPIC

Thanks to All

Any Query ????

44

You might also like