You are on page 1of 17

Lecture 18

More Moore/Mealy machines

Example: Parity checker

Serial input string

OUT=1 if odd # of 1s in input


OUT=0 if even # of 1s in input

Lets do this for Moore and Mealy

1. State diagram
Moore

Mealy

0/00

Even
[0]
1

Even
[0]
1

11/0

1/11

Odd
[1]

Odd
[1]

0/1
3

2. State transition table


Present
State

Input

Even
Even
Odd
Odd

0
1
0
1

Next
State
Even
Odd
Odd
Even

Mealy

Present
Output
0
0
1
1

Moore

Present
State

Input

Even
Even
Odd
Odd

0
1
0
1

Next
State
Even
Odd
Odd
Even

Present
Output
0
1
1
0

3. State minimization

Already minimized

Need both states (even and odd)


Use one flip-flop

4. State encoding
Present
State
0
0
1
1

Input
0
1
0
1

Next
State

Present
Output

0
1
1
0

0
0
1
1

Mealy

Present
State
0
0
1
1

Assignment
Even 0
Odd 1

Moore

Input

Next
State

Present
Output

0
1
0
1

0
1
1
0

0
1
1
0

5. Next-state logic minimization

Assume D flip-flops
Next state = (present state) XOR
(present input)

6. Implement the design


Moore

Mealy
Output

Input

Output

Input

CLK

Q
Q

Current
State

CLK
8

Example: Vending machine


Reset

N
Coin
Sensor

Vending
Machine
FSM

Open

Release
Mechanism

Clock

Moore machine
present
state
0

Reset

0
N
5
N
D

5
D
10

10
N+D
15
[open]

15

inputs
D
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1

next
N
0
5
10

5
10
15

10
15
15

15

present
state
0
0
0

0
0
0

0
0
0

outp

symbolic state table

10

Mealy machine
present
state
0

Reset

0
N/0
5

5
D/0

N/0
D/1

10

10
N + D/1
15

15

inputs
D
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1

next
N
0
5
10

5
10
15

10
15
15

15

present
state
0
0
0

0
0
1

0
1
1

outp

symbolic state table

11

Moore machine: State encoding


present
state
0

10

15

inputs
D
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1

next
N
0
5
10

5
10
15

10
15
15

15

present
state
0
0
0

0
0
0

0
0
0

present state inputs


output
Q1 Q0
D N
0 0
0
0
0
1
1
0
1
1
0 1
0
0
0
1
1
0
1
1
1 0
0
0
0
1
1
0
1
1
1 1

next state
D1 D0
0 0
0 1
1 0

0 1
1 0
1 1

1 0
1 1
1 1

1 1

present
output
0
0
0

0
0
0

0
0
0

symbolic state table

12

Mealy machine: State encoding


present
state
0

10

15

inputs
D
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1

next
N
0
5
10

5
10
15

10
15
15

15

present
state
0
0
0

0
0
1

0
1
1

present state inputs


output
Q1 Q0
D N
0 0
0
0
0
1
1
0
1
1
0 1
0
0
0
1
1
0
1
1
1 0
0
0
0
1
1
0
1
1
1 1

next state
D1 D0
0 0
0 1
1 0

0 1
1 0
1 1

1 0
1 1
1 1

1 1

present
output
0
0
0

0
0
1

0
1
1

symbolic state table

13

Logic minimization
Q1

D1 Moore

D0

X X

N
D

Q1

D1

X X

Q0

1 1

X X
1

1
Q0

N
D

0 1
Q0

Q1

Open

0 1

1 1

X X
0

N
D

X X

1
Q0

Q1

Open

X X

D0

0 1

Q0

Mealy

Q1

N
D

Q1

1 1
Q0

14

Implementation
Moore

Mealy

15

7.24

A Moore machine has two inputs (X1, X2)


and one output (Z). The output remains a
constant value unless one of the following
input sequence occurs:

The input sequence 00,11 causes the output to


become 0.
The input sequence 01,11 causes the output to
become 1.
The input sequence 10,11 causes the output to
toggle value.
16

7.23

A Mealy machine has one input (X)


and two outputs (Z1 and Z2). An
output Z1 = 1 occurs every time the
input sequence 101 is observed,
provided the sequence 011 has never
been seen. An output Z2 = 1 occurs
every time the input 011 is observed.
17

You might also like