Download - Moore and mealy machines
![Page 1: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/1.jpg)
1
Moore and Mealy machines
Finite state Machines with output
![Page 2: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/2.jpg)
2
Moore Machine output is associated with states
A Moore machine is a six tuple (Q , , , , , q0) : Is the output alphabet : I s a mapping from Q to giving output
associated with each state.Output in response to input a1 a2 …an is(q0) (q1) (q2)… (qn)
Where q0, q1,…qn is the sequence of states such that (qi-1,ai) = qi
STRING LENGTH N+1
![Page 3: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/3.jpg)
3
Note
Any Moore machine gives output
(q0) in response to input - empty string
![Page 4: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/4.jpg)
4
DFA may be viewed as a special case of Moore machine where
output for accepting state is 1
output for nonaccepting state is 0
![Page 5: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/5.jpg)
5
Example
To find the residue mod 3 for binary string treated as a binary integer
if a number i written in binary is followed by 0, resulting string has value 2i
If I is followed by 1 the resulting string has value 2i +1
If a string x(when treated as binary integer) has remainder p(when divided by 3) then string ‘x0’ will have remainder 2p mod 3
And string ‘X1’ will have remainder 2p+1 mod 3
![Page 6: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/6.jpg)
6
q0 q1 q2
0
input 1010 value 10 so 10 mod 3 = 1
q0 1 q1 0 q2 1 q2 0 q1
output 0 1 2 2 1
1 20
1
1
1
0
0
![Page 7: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/7.jpg)
7
• 25 = 1 1 0 0 1• Q0- 1 q1 – 1- q0 0- q0- 0 - q0 – 1 – q1• 0 1 0 0 0 1
![Page 8: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/8.jpg)
8
Mealy Machine out put is associated with transition
A Mealy machine is a six tuple (Q , , , , , q0) : Is the output alphabet : I s a mapping from QX to giving
output (q,a) associated with the transitions from state q and input each state.
![Page 9: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/9.jpg)
9
Output in response to input a1 a2 …an is
(q0, a1) (q1,a2) (q2,a3)… (qn-1,an)
Where q0, q1,…qn is the sequence of states such that (qi-1,ai) = qi
Note that this sequence has length n rather that n+1 as in Moore machine
![Page 10: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/10.jpg)
10
Mealy machine to add two integers using their binary expansions
Inputs xn xn-1 …x0
yn yn-1…y0
We assume that both xn and yn are zero. a state q0 represents that previous carry is
zeroA state q1 represents that previous carry was
1Inputs to the machine are pairs of bits: there
are four possible inputs(00,01,10,11)
![Page 11: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/11.jpg)
11
Input 0 1 0 0 1 0 18
0 1 1 1 0 1 29
47
q0 q1
11, 0
01, 1 01, 0
00, 100, 0
10, 1
11, 1
10, 0
q0 - 01- q0 - 10 - q0 - 01 - q0- 01 - q0- 11 - q1 - 00- q0
1 1 1 1 0 1
out put is : 1 0 1 1 1 1 value 47
![Page 12: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/12.jpg)
12
Equivalence of Moore and Mealy Machines
A Moore machine M can never be correctly equivalent to a Mealy machine M’ because the length of output string from a Moore machine M is one greater than that from the Mealy machine M’ on the same input.
However we may neglect the response of Moore machine to input and say
![Page 13: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/13.jpg)
13
Moore machine M and a Mealy machine M’ are equivalent if for all inputs w
b TM’ (w) = TM(w)
where b is the output of Moore machine M for its initial state
![Page 14: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/14.jpg)
14
• Theorem: I If M1= (Q , , , , , q0)is a Moore machine then there is a Mealy machineM2 equivalent to M1
• Proof: Construct Mealy machine M2 as
(Q , , , , ’, q0) ’ is defined as:
’(q,a) = ((q,a)) for all states q and input symbols a
![Page 15: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/15.jpg)
15
q0 q1 q2
0
input 1010 value 10 so 10 mod 3 = 1
q0 1 q1 0 q2 1 q2 0 q1
output of Moore 0 1 2 2 1
1 20/2
1/2
1/1
1/0
0/0
0/1
Out put for Mealy machine on the same input
q0 - 1 (1) q1 - 0 (2) q2- 1 (2) q2 - 0 (1) q1
![Page 16: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/16.jpg)
16
• on input 1010 out by Moore machine is 0 1 2 2 1
While output from the constructed Mealy machine is
1 2 2 1By the condition of equivalence we should add out put of q0 0 of Moore
machine in the beginning of out put of Mealy machine
Hence the machine made is equivalent to the give Moore machine.
![Page 17: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/17.jpg)
17
• Theorem: If M1= (Q , , , , , q0)is a Mealy machine then there is a Moore machine M2 equivalent to M1.
• Proof:We can do the reverse of what we did in the construction of Mealy machine.
As the different edges terminating to a node may have different outputs.
![Page 18: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/18.jpg)
18
We look into each state and see the edges with different outputs are terminating to it.
Say state qi is having all the terminating edges with 0,1, 2 as outs on them.
State qi is split into
Qi0, qi1, qi2 ie. In the Moore machine in place of qi state we take three state
qi0, qi1, qi2.
With these states we associate outputs as 0,1,2 respectively in the Moore machine
![Page 19: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/19.jpg)
19
In q0 four edges are terminating and in different outputs on them are only two 0 and 1
So q0 is split into two states q00 and q01
q0 q1
11, 0
01, 1 01, 0
00, 100, 0
10, 1
11, 1
10, 0
Similarly on state q1 four edges are terminating with two different output vales 0 and 1 so it is also split into two new states as q10 and q11.
![Page 20: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/20.jpg)
20
q00
q01
q10
q11
00
01
10
11
01,10
1111
10, 01
01,10
00
11
0 1 0 0 1 0 18 q00 -01-q01-10-q01-01-q01-01-q01-11-q10-00-q01
0 1 1 1 0 1 29 0 1 1 1 1 0 1 ie 101111 = 47
0
1
0
1
00
00
![Page 21: Moore and mealy machines](https://reader033.vdocuments.pub/reader033/viewer/2022061222/54c303aa4a7959260b8b459c/html5/thumbnails/21.jpg)
21
• 0 1 0 0 1 0 18
• 0 1 1 1 0 1 29 47
q00 - 01- q01 -10 - q01 - 01- q01 - 01- q01-11- q10 – 00 - q01
• 0 1 1 1 1 0 1 ie
• 101111 = 47