Download as ppsx, pdf, or txt
Download as ppsx, pdf, or txt
You are on page 1of 38

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa

AUTOMATA

OUTPUT
WITH
Theory of Computation
Theory of Computation 2

TYPES

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


 Moore Machine
 Mealy Machine
BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa
3

Moore Machine
Theory of Computation
Theory of Computation 4

Moore machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


 A Moore machine is defined by the 6 tuple (Q,Σ,δ,q0,Δ,λ)
Q : finite set of states
Σ : input alphabet
δ : transition function (Q×ΣQ)
q0 : initial state (q0∊Q)
Δ : output alphabet
λ : output function (QΔ)
Theory of Computation 5

Moore machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Q : {A,B,C}
Input
Output Σ : {a,b}
symbol a
symbol Δ : {0,1}
q0 : A
a
A/0 B/0

a
b Input = a Input = b
Present
b Next Next Output
state
C/1 State State
A B C 0
B B C 0
b
C B C 1
Theory of Computation 6

Moore machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


a Outputs are associated with states

Input : a a b
a
A/0 B/0
Output : 0 0 0 1
a
b
b
| output | = | input | + 1
C/1

b
Theory of Computation 7

Moore machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Construct a moore machine that takes set of all strings over {a,b} as input
and print 1 as output for every occurrence of “ab”

a b

a b
A/0 B/0 C/1

b
Theory of Computation 8

Moore machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Construct a moore machine that takes set of all strings over {a,b} and count
no. of occurances of string “baa”

a b

b a a
A/0 B/0 C/0 D/1

a
Theory of Computation 9

Moore machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Construct a moore machine that takes set of all strings over {0,1} and
produce ‘A’ as output if input ends with “10” or produce ‘B’ as output if input
ends with “11” otherwise produce ‘C’
1
0

1 0
X/C Y/C Z/A

1
1 1 0

P/B
Theory of Computation 10

Moore machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Construct a moore machine that takes binary number as input and produce
residue modulo ‘3’ as output

0 1

1 0
X/0 Y/1 Z/2

1 0
BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa
11

Mealy machine
Theory of Computation
Theory of Computation 12

Mealy machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


 A Mealy machine is defined by the 6 tuple (Q,Σ,δ,q0,Δ,λ)
Q : finite set of states
Σ : input alphabet
δ : transition function (Q×ΣQ)
q0 : initial state (q0∊Q)
Δ : output alphabet
λ : output function (Q×ΣΔ)
Theory of Computation 13

Mealy machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Q : {A,B,C}
Output
Input Σ : {a,b}
symbol a/0
symbol Δ : {0,1}
q0 : A
a/0
A B

a/1
b/0 Input = a Input = b
Present
b/1 state Next Next
Output Output
C State State
A B 0 C 0
B B 0 C 1
b/0
C B 1 C 0
Theory of Computation 14

Mealy machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


a/0 Outputs are associated with inputs

Input : a a b
a/0
A B
Output : 0 0 1
a/1
b/0
b/1
| output | = | input |
C

b/0
Theory of Computation 15

Mealy machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Construct mealy machine that takes binary number as input and produce 1’s
complement of that number as output

0/1

1/0
Theory of Computation 16

Mealy machine

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Construct mealy machine that takes binary number as input and produce 2’s
complement of that number as output . Assume the string is read LSB to
MSB and end carry is discarded

0/0
0/1

1/1
X Y

1/0
Theory of Computation 17

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Conversion
MOORE TO MEALY CONVERSION
Theory of Computation 18

Moore to Mealy conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


b /0 b/1 b/ 2

a /1 a /2
X/0 Y/1 Z/2

a/0

Moore with ‘n’ states  Mealy with ‘n’ states


Theory of Computation 19

Moore to Mealy conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
Next Next Output
state
State State
X Y X 0 Moore
Y Z Y 1
Z X Z 2
Theory of Computation 20

Moore to Mealy conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
Next Next Output
state
State State
X Y X 0 Moore
Y Z Y 1
Z X Z 2

Input = a Input = b
Present
state Next Output Next Output
State State
Mealy
X
Y
Z
Theory of Computation 21

Moore to Mealy conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
Next Next Output
state
State State
X Y X 0 Moore
Y Z Y 1
Z X Z 2

Input = a Input = b
Present
state Next Output Next Output
State State
Mealy
X Y X
Y Z Y
Z X Z
Theory of Computation 22

Moore to Mealy conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
Next Next Output
state
State State
X Y X 0 Moore
Y Z Y 1
Z X Z 2

Input = a Input = b
Present
state Next Output Next Output
State State
Mealy
X Y X 0
Y Z Y
Z X 0 Z
Theory of Computation 23

Moore to Mealy conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
Next Next Output
state
State State
X Y X 0 Moore
Y Z Y 1
Z X Z 2

Input = a Input = b
Present
state Next Output Next Output
State State
Mealy
X Y 1 X 0
Y Z Y 1
Z X 0 Z
Theory of Computation 24

Moore to Mealy conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
Next Next Output
state
State State
X Y X 0 Moore
Y Z Y 1
Z X Z 2

Input = a Input = b
Present
state Next Output Next Output
State State
Mealy
X Y 1 X 0
Y Z 2 Y 1
Z X 0 Z 2
Theory of Computation 25

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Conversion
MEALY TO MOORE CONVERSION
Theory of Computation 26

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Mealy Moore
0/z2

0/z1
A B

0/z1 0 B/
1/z1 A
z1
1/z1
C
1

C/
1/z2 z1
Theory of Computation 27

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Mealy Moore
0/z2

0/z1
A B

0/z1 0 B/
1/z1 A
z1
1/z1
C 0
1

C/
1/z2 z1

C/
z2
Theory of Computation 28

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Mealy Moore
0/z2

0/z1
A B

0/z1 0 B/
1/z1 A
z1
1/z1
C 0
1

C/
1/z2 z1

1 C/ 0
z2
Theory of Computation 29

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Mealy Moore
0/z2

B/
0/z1 z2
A B
0
0/z1 0 B/
1/z1 A
z1
1/z1
C 0
1
1
C/
1/z2 z1

1 C/ 0
z2
Theory of Computation 30

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Mealy 0 Moore
0/z2

1 B/
0/z1 z2
A B
0
0/z1 0 B/
1/z1 A
z1
1/z1
C 0
1
1
C/
1/z2 z1

1
No incoming transition for A so it has no output C/ 0
Can assume any z1 or z2 1
z2
Theory of Computation 31

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Mealy 0 Moore
0/z2

1 B/
0/z1 z2
A B
0
0/z1 A/ 0 B/
1/z1
z1 z1
1/z1
C 0
1
1
C/
1/z2 z1

Moore may have more states then mealy 1

Mealy with ‘n’ states and ‘m’ outputs  1 C/ 0


Moore may have max ‘m×n’ states z2
Theory of Computation 32

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
state Next Next
Output Output
State State
A B Z1 C Z1
Mealy
B B Z2 C Z1
C B Z1 C Z2

Input = a Input = b
Present
state Output
Next State Next State

Moore
Theory of Computation 33

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
state Next Next
Output Output
State State
A B Z1 C Z1
Mealy
B B Z2 C Z1
C B Z1 C Z2

Input = a Input = b
Present
state Output
Next State Next State

A Z1 or Z2
Moore
Theory of Computation 34

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
state Next Next
Output Output
State State
A B Z1 C Z1
Mealy
B B Z2 C Z1
C B Z1 C Z2

Input = a Input = b
Present
state Output
Next State Next State

A Z1 or Z2
Moore
B1 Z1
B2 Z2
Theory of Computation 35

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
state Next Next
Output Output
State State
A B Z1 C Z1
Mealy
B B Z2 C Z1
C B Z1 C Z2

Input = a Input = b
Present
state Output
Next State Next State

A Z1 or Z2
Moore
B1 Z1
B2 Z2
C1 Z1
C2 Z2
Theory of Computation 36

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
state Next Next
Output Output
State State
A B Z1 C Z1
Mealy
B B Z2 C Z1
C B Z1 C Z2

Input = a Input = b
Present
state Output
Next State Next State

A B1 C1 Z1 or Z2
Moore
B1 Z1
B2 Z2
C1 Z1
C2 Z2
Theory of Computation 37

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
state Next Next
Output Output
State State
A B Z1 C Z1
Mealy
B B Z2 C Z1
C B Z1 C Z2

Input = a Input = b
Present
state Output
Next State Next State

A B1 C1 Z1 or Z2
Moore
B1 B2 C1 Z1
B2 B2 C1 Z2
C1 Z1
C2 Z2
Theory of Computation 38

Mealy to Moore conversion

BY : Trusha Patel, CD Dept, CSPIT, CHARUSAT, Changa


Input = a Input = b
Present
state Next Next
Output Output
State State
A B Z1 C Z1
Mealy
B B Z2 C Z1
C B Z1 C Z2

Input = a Input = b
Present
state Output
Next State Next State

A B1 C1 Z1 or Z2
Moore
B1 B2 C1 Z1
B2 B2 C1 Z2
C1 B1 C2 Z1
C2 B1 C2 Z2

You might also like