Moore and mealy machines

download Moore and mealy machines

If you can't read please download the document

  • date post

    24-Jan-2015
  • Category

    Technology

  • view

    16.628
  • download

    6

Embed Size (px)

description

 

Transcript of Moore and mealy machines

  • 1. Finite state Machines withoutputMoore and Mealy machines1

2. Moore Machine output is associated with statesA 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) = qiSTRING LENGTH 2N+1 3. NoteAny Moore machine gives output(q0) in response to input - empty string3 4. DFA may be viewed as a special case of Moore machine whereoutput for accepting state is 1output for nonaccepting state is 0 4 5. ExampleTo find the residue mod 3 for binary string treatedas a binary integer if a number i written in binary is followed by 0,resulting string has value 2iIf I is followed by 1 the resulting string has value 2i+1If a string x(when treated as binary integer) hasremainder p(when divided by 3) then string x0will have remainder 2p mod 3And string X1 will have remainder 2p+1 mod 35 6. input 1010 value 10 so 10 mod 3 = 1q0 1 q1 0 q2 1 q2 0 q1output0 12 2 1 01210 q0 q1 q210 106 7. 25 = 1 1 0 0 1 Q0- 1 q1 1- q0 0- q0- 0 - q0 1 q101 000 17 8. Mealy Machine out put is associated withtransitionA Mealy machine is a six tuple(Q , , , , , q0) : Is the output alphabet : I s a mapping from QX to givingoutput (q,a)associated with thetransitions from state q and input eachstate. 8 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) = qiNote that this sequence has length n rather that n+1 as in Moore machine 9 10. Mealy machine to add two integersusing their binary expansionsInputs xn xn-1 x0 yn yn-1y0We assume that both xn and yn are zero. a state q0 represents that previous carry iszeroA state q1 represents that previous carrywas 1Inputs to the machine are pairs of bits:there are four possible inputs(00,01,10,11)10 11. Input010010180111012901, 1 01, 0 47 11, 0q0 q100, 000, 1 11, 110, 110, 0 0 - 01- q0 - 10 - q0 - 01 - q0- 01 - q0- 11 - q1 - 00- q01 1 1101 11out put is : 1 0 1 1 1 1 value 47 12. Equivalence of Moore and Mealy MachinesA 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 say12 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 13 14. Theorem: I If M1= (Q , , , , , q0)is a Moore machine then there is aMealy machineM2 equivalent to M1 Proof: Construct Mealy machine M2 as(Q , , , , , q0) is defined as:(q,a) = ((q,a)) for all states q andinput symbols a 14 15. input 1010 value 10 so 10 mod 3 = 1q0 1 q1 0 q2 1 q2 0 q1 output of Moore 01 2 210 1 2 1/10/2 q0q1 q2 1/00/11/2 0/0Out put for Mealy machine on the same input15q0 - 1 (1)q1 - 0 (2) q2- 1 (2) q2 - 0 (1) q1 16. on input 1010 out by Moore machine is0 12 21While output from the constructed Mealymachine is 12 21By the condition of equivalence we should add out put of q0 0 of Mooremachine in the beginning of out put ofMealy machineHence the machine made is equivalent tothe give Moore machine.16 17. Theorem: If M1= (Q , , , , , q0)is a Mealy machine then there is aMoore machine M2 equivalent to M1. Proof:We can do the reverse of what wedid in the construction of Mealymachine.As the different edges terminating to anode may have different outputs. 17 18. We look into each state and see the edges withdifferent outputs are terminating to it.Say state qi is having all the terminating edgeswith 0,1, 2 as outs on them.State qi is split intoQi0, qi1, qi2 ie. In the Moore machine in placeof qi state we take three stateqi0, qi1, qi2.With these states we associate outputs as 0,1,2 respectively in the Moore machine 18 19. In q0 four edges are terminating and in different outputs on them are only two 0 and 1So q0 is split into two states q00 and q01 01, 1 01, 0 11, 0 q0 q1 00, 0 00, 111, 1 10, 1 10, 0Similarly on state q1 four edges are terminating with twodifferent output vales 0 and 1 so it is also split into twonew states as q10 and q11.19 20. 01,10 0000 00 q01 11 01 1110, 01q11q0010000 11 1111 q10 001,10010010 18 q00 -01-q01-10-q01-01-q01-01-q01-11-q10-00-q0120011101 290 1 1 1 1 0 1 ie 101111 = 47 21. 0 1 0 0 1 0 18 0 1 1 1 0 1 29 47q00 - 01- q01 -10 - q01 - 01- q01 - 01-q01-11- q10 00 -q010 1 1 1 1 0 1 ie101111 = 4721