Professional Documents
Culture Documents
moore and mealy machine
moore and mealy machine
Moore Machines:
A Moore machine can be described by a 6 tuple (Q, ∑, O, δ, X, q0)
where −
An output table that shows what character from Г is printed by each state
that is entered.
A Moore machine does not define a language of accepted words, since
every input string creates an output string and there is no such thing as a
final state. The processing is terminated when the last input letter is read
and the last output character is printed.
Example 1:
Input alphabet: Σ = {a, b}
Output alphabet: Г = {0, 1}
Names of states: q0, q1, q2, q3. (q0 = start state)
Sol:
The Moore machine is:
|Page1
Note1:
The two symbols inside the circle are separated by a slash "/", on the
left side is the name of the state and on the right is the output from
that state.
If the input string is abab to the Moore machine then the output will
be 10010.
Note 2:
A Moore machine is very similar to a Finite Automaton (FA), with a few
key differences:
• It has no final states.
• It does not accept or reject input; instead, it generates output from
input.
• Moore machines cannot have nondeterministic states.
Every input gives output not if word belongs to the machine or language
like FA
In each state we stop we have to print out what inside that state (it's
content) so the output will be more than input by one because we start with
start state and print out its content before we trace the input string
Example 2: construct a Moore machine that take set of all strings over
Alphabet {a, b} as input and print 1 as output for every occurrence of 'aab'
as substring.
Sol:
Input alphabet: Σ = {a, b}
Output alphabet: Г = {0, 1}
|Page2
Example 3: Construct a Moore machine that take set of all strings over
Alphabet {0, 1} as input and produce 'A' as output if input end with (10) or
produce 'B' as output if input end with (11) otherwise produce 'C' .
Sol:
Input alphabet: Σ = {0, 1}
Output alphabet: Г = {A, B, C}
|Page3
Example 4: Construct a Moore machine that take set of all strings over
alphabet {a, b} as input and produce '1' as output if number of a's in string
mod 3=0 otherwise produce '0'.
Sol:
Input alphabet: Σ = {a, b}
Output alphabet: Г = {0, 1}
|Page4
Mealy Machines:
A Mealy Machine is an FSM whose output depends on the present
state as well as the present input.
Note: There are no accept states in Moore and Mealy machine because
they are not a language recognizer, they are an output producer. Its output
will be the same length as its input.
Example 1:
Input alphabet: Σ = {a, b}
Output alphabet: Г = {0, 1}
Names of states: q0, q1, q2, q3. (q0 = start state)
Sol:
The Mealy machine is:
|Page5
As the binary system has base r = 2. So the two types of complements for
the binary system are 2's complement and 1's complement.
1's complement
The 1's complement of a number is found by changing all 1's to 0's and all
0's to 1's. This is called as taking complement or 1's complement. Example
of 1's Complement is as follows.
2's complement
The 2's complement of binary number is obtained by adding 1 to the Least
Significant Bit (LSB) of 1's complement of the number.
|Page6
Note:
Two’s complement is especially important because it allows us to represent signed
numbers in binary.
Two’s complement also provides an easier way to subtract numbers using addition
instead of using the longer.
Example 2:
The following Mealy machine prints out the 1's complement of an input bit
string.in other words it flips each digit from a 0 to a 1 or from a 1 to a 0.
Note: If the input is 001010, the output is 110101. This is a case where
the input alphabet and output alphabet are both {0, 1}.
Example 3:
Construct a Mealy machine that take set of all strings over alphabet {0, 1}
as input and produce 'E' as output if number of 1's in string mod 2=0
produce 'O' as output if number of 1's in string mod 2=0.
Sol:
Input alphabet: Σ = {0, 1}
Output alphabet: Г = {E, O}
|Page7
|Page8
Mealy model might require less states to model but might be more
complex to understand
Output depends both upon the present Output depends only upon the present
state and the present input state.
Generally, it has fewer states than Generally, it has more states than Mealy
Moore Machine. Machine.
The value of the output function is a The value of the output function is a
function of the transitions and the function of the current state and the
changes, when the input logic on the changes at the clock edges, whenever
present state is done. state changes occur.
Note: All examples in Moore machine can be solve in mealy Machine and
vris versa because Mealy and Moore machines are equivalent, you have
to try solving them as Homework.
|Page9