Mealy & Moore Machine: Rao Wakeel Ahmad

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Mealy & Moore Machine

Rao Wakeel Ahmad


Adv Theory of Computing
Moore Machine
• Moore machine is a finite state machine in which the
next state is decided by the current state and current
input symbol.

• The output symbol at a given time depends only on the


present state of the machine.

• Moore machine can be described by 6 tuples (Q, q0, ∑,


O, δ, λ) where,
Moore Machine

1.Q: finite set of states

2.q0: initial state of machine

3.∑: finite set of input symbols

4.O: output alphabet

5.δ: transition function where Q × ∑ → Q

6.λ: output function where Q → O


Moore Machine: Example 1

• The state diagram Transition table


Moore Machine: Example 1
• Input: 010
• Transition: δ (q0,0) => δ(q1,1) => δ(q1,0) => q2
• Output: 1110(1 for q0, 1 for q1, again 1 for q1, 0 for q2)
Design a Moore machine to generate 1's
complement of a given binary number.
• Solution: To generate 1's complement of a given binary
number the simple logic is that if the input is 0 then the
output will be 1 and if the input is 1 then the output will be
0. That means there are three states.
• One state is start state.

• The second state is for taking 0's as input and produces output as 1.

• The third state is for taking 1's as input and producing output as 0.
Moore Machine: Example 2
• Design a Moore machine to generate 1's complement of a given
binary number.
Moore Machine: Example 2

Input 1 0 1 1

State q0 q2 q1 q2 q2

Output 0 0 1 0 0

• Thus Moore machine M = (Q, q0, ∑, O, δ, λ); where Q = {q0, q1, q2},

• ∑ = {0, 1}, O = {0, 1}. the transition table shows the δ and λ functions.
Moore Machine: home practice
1. Design a Moore 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.
2. Construct a Moore machine that determines whether an input
string contains an even or odd number of 1's. The machine should
give 1 as output if an even number of 1's are in the string and 0
otherwise.
3. Design a Moore machine with the input alphabet {0, 1} and output
alphabet {Y, N} which produces Y as output if input sequence
contains 1010 as a substring otherwise, it produces N as output.
Mealy Machine
• A Mealy machine is a machine in which output symbol
depends upon the present input symbol and present state of
the machine.

• In the Mealy machine, the output is represented with each


input symbol for each state separated by /.

• The Mealy machine can be described by 6 tuples (Q, q0, ∑,


O, δ, λ') where
Mealy Machine
• The Mealy machine can be described by 6 tuples
1. Q: finite set of states

2. q0: initial state of machine

3. ∑: finite set of input alphabet

4. O: output alphabet

5. δ: transition function where Q × ∑ → Q

6. λ': output function where Q × ∑ →O


Mealy Machine: Example 1
• 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.
Home practice Mealy
Machine

• Design a mealy machine that


• Design a Mealy machine
for a binary input
scans sequence of input of 0
sequence such that if it and 1 and generates output
has a substring 101, the 'A' if the input string
machine output A, if the terminates in 00, output 'B' if
input has substring 110, the string terminates in 11,
it outputs B otherwise it and output 'C' otherwise.
outputs C.

You might also like