ece2030 introduction to computer engineering lecture 16: finite state machines prof. hsien-hsin sean...
TRANSCRIPT
![Page 1: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/1.jpg)
ECE2030 Introduction to Computer Engineering
Lecture 16: Finite State Machines
Prof. Hsien-Hsin Sean LeeProf. Hsien-Hsin Sean Lee
School of Electrical and Computer EngineeringSchool of Electrical and Computer Engineering
Georgia TechGeorgia Tech
![Page 2: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/2.jpg)
2
Mealy and Moore Machines
Combinationalcircuits
Inputs X(t) Outputs Z(t)
StorageElement
S(t)
MEALY MACHINE
Z(t) = {S(t), X(t)}
Combinationalcircuits
Inputs X(t)
Outputs Z(t)
StorageElement
S(t)
MOORE MACHINE
Z(t) = {S(t)}
![Page 3: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/3.jpg)
3
State and State Diagram
• A state represents the machine snapshot at a given clock period
• A clock is typically used to synchronize the state transition
• A graph consists of a set of– Circles:
• Each represents a state • Use double circle to represent the initial state
– Directed arc: each represents a state transition– Inputs/outputs
• Mealy machine: – Label input/output along each arc
• Moore machine: – Label input along each arc– Label output inside the circle (i.e. state)
![Page 4: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/4.jpg)
4
State Diagrams
Example:State: S(t) {Sk, Sj}
Inputs: X(t) {a, b}Outputs: Z(t) {p, q}Initial state: S(0) = Sk
A Mealy machine example A Moore machine example
Sk Sj
a/p
b/q
b/p a/q
a
b
Sk/p Sj/q
b
a
![Page 5: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/5.jpg)
5
State Diagram Examples (Mealy)
S0 S1
0/0
1/1
1/0 0/0
S0S1
0/0, 1/1
0/0
1/0
![Page 6: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/6.jpg)
6
State Diagram Examples (Moore)
S0/1 S1/0
0
1
1 0
0, 1
0
1
S0/0 S1/1
![Page 7: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/7.jpg)
7
Design Example: Sequence Recognizer
• A sequential circuit that recognizes the occurrence of a particular bit sequence
• Input: X(t) {0, 1}• Output: Z(t) {0, 1}
Otherwise 0,
1101t)3,X(t if1,Z(t)
![Page 8: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/8.jpg)
8
Sequence Recognizer
Time 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16X(t) 1 0 0 1 0 1 1 0 1 0 1 1 0 1 1 0 1 Z(t) 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1
Otherwise 0,
1101t)3,X(t if 1,Z(t)
![Page 9: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/9.jpg)
9
Sequence Recognizer
Time 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16X(t) 1 0 0 1 0 1 1 0 1 0 1 1 0 1 1 0 1 Z(t) 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1
S0 S1
1/0
Otherwise 0,
1101t)3,X(t if 1,Z(t)
0/0 0/0
S2
1/0
S3
0/0
1/0
0/0
1/1
A Meanly Machine
![Page 10: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/10.jpg)
10
State Table
00
1/0
0/0 0/0
1/0 0/0
1/0
0/0
1/1
01 10 11
Present StatePresent State Input Input
XXNext StateNext State OutpuOutpu
tt
ZZP1P1 P0P0 N1N1 N0N0
0 0 0 0 0 0
0 0 1 0 1 0
0 1 0 0 0 0
0 1 1 1 0 0
1 0 0 1 1 0
1 0 1 1 0 0
1 1 0 0 0 0
1 1 1 0 1 1
![Page 11: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/11.jpg)
11
Logic Circuits Design Steps
• Generate a Boolean function for – Each external output – Each state encoded bit
• Simplify the Boolean functions• Draw a D F/F (or register) for each state
encoded bit• Draw logic circuits for
– External outputs– Each inputs of state encoded bits – Input of state encoded bits = the next state– Output of state encoded bits = the current state
![Page 12: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/12.jpg)
12
Logic Circuits Design
Present Present StateState XX
Next StateNext State
ZZ
P1P1 P0P0 N1N1 N0N0
0 0 0 0 0 0
0 0 1 0 1 0
0 1 0 0 0 0
0 1 1 1 0 0
1 0 0 1 1 0
1 0 1 1 0 0
1 1 0 0 0 0
1 1 1 0 1 1
00 01 11 10
0 0 0 0 1
1 0 1 0 1
XP1P0 N1N1
0101 PPPPXN1
00 01 11 10
0 0 0 0 1
1 1 0 1 0
XP1P0 N0N0
01
010101
PPX)P0P1X(
PPXPXPPPXN0
01PXPZ
![Page 13: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/13.jpg)
13
Logic Circuits Design
0101 PPPPXN1 01PPX)P0P1X(N0 01PXPZ
D0F/F
1 2
P0N0
D1F/F
1 2
P1N1
Z
D0F/F
1 2
P0N0
XX
![Page 14: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/14.jpg)
14
Example 2
• Input: X(t) {a, b, c}• Output: Z(t) {q, p}
Otherwise p,
sb' of #odd and sa' of #even
has sequence input whenq,
Z(t)
![Page 15: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/15.jpg)
15
State Diagram
Otherwise p,
sb' of #odd and sa' of #even
has sequence input whenq,
Z(t)
SEO/q
A Moore Machine
b
SEE/p SOO/p SOE/p
a
ac
b
c
a
C
b
a
bc
![Page 16: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/16.jpg)
16
State Table
01/q
b
00/p 10/p 11/p
a
ac
b
c
a
C
b
a
bc
Present State Input (a, b, c) Next State Output
P1 P0 X1 X0 N1 N0 Z
0 0 0 0 1 1 0
0 0 0 1 0 1 0
0 0 1 0 0 0 0
0 1 0 0 1 0 1
0 1 0 1 0 0 1
0 1 1 0 0 1 1
1 0 0 0 0 1 0
1 0 0 1 1 1 0
1 0 1 0 1 0 0
1 1 0 0 0 0 0
1 1 0 1 1 0 0
1 1 1 0 1 1 0
SEE = 00SEO = 01SOO = 10SOE = 11
a = 00 b = 01 c = 10
p = 0 q = 1
![Page 17: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/17.jpg)
17
Logic Circuit Design
Present State
Input Next State Output
P1 P0 X1 X0 N1 N0 Z
0 0 0 0 1 1 0
0 0 0 1 0 1 0
0 0 1 0 0 0 0
0 1 0 0 1 0 1
0 1 0 1 0 0 1
0 1 1 0 0 1 1
1 0 0 0 0 1 0
1 0 0 1 1 1 0
1 0 1 0 1 0 0
1 1 0 0 0 0 0
1 1 0 1 1 0 0
1 1 1 0 1 1 0
X0)(X1P1
X1)P1(X0)X0X1(P1
P1X1P1X0X0X1P1N1
00 01 11 10
00 1 0 X 0
01 1 0 X 0
11 0 1 X 1
10 0 1 X 1
P1P0X1X0 N1
X1P0
P0X1X1P0N0
00 01 11 10
00 1 1 X 0
01 0 0 X 1
11 0 0 X 1
10 1 1 X 0
P1P0X1X0 N0
P0P1Z 00 01 11 10
00 0 0 X 0
01 1 1 X 1
11 0 0 X 0
10 0 0 X 0
P1P0X1X0 Z
![Page 18: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/18.jpg)
18
Logic Circuit Design
X0)(X1P1N1 P0P1Z
D1F/F
1 2
P1N1
D0F/F
1 2
P0N0X1
X0
Z
X1P0N0
![Page 19: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/19.jpg)
19
Vending Machine State Machine• Dispense a Coke when depositing 15
¢• Inputs
– 5 = a nickel– 10 = a dime– BC = bad coin (including quarters in this
example)• Outputs
– R = reject– C = coke– N = no coke
![Page 20: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/20.jpg)
20
State Diagram
0 ¢
BC/R
5 ¢
5/N
10 ¢
10/N
5/C
10/C
5/N
BC/R
10/C
BC/R
![Page 21: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/21.jpg)
21
State Table
0 ¢(00)
BC/R5/N
10/N
5/C
10/C
5/N
BC/R
10/C
BC/R
Present State (0¢, 5¢, 10¢)
Input (5¢, 10¢ ,
BC)
Next State (0¢, 5¢, 10¢)
Output (C, N, R)
P1 P0 X1 X0 N1 N0 C1 C0
0 0 0 0 0 1 0 0
0 0 0 1 1 0 0 0
0 0 1 0 0 0 1 0
0 1 0 0 1 0 0 0
0 1 0 1 0 0 0 1
0 1 1 0 0 1 1 0
1 0 0 0 0 0 0 1
1 0 0 1 0 1 0 1
1 0 1 0 1 0 1 0
X X 1 1 X X X X
1 1 X X X X X X
5 ¢(01)
10 ¢(10)
5: 0010: 01BC: 10
N: 00C: 01 R: 10
![Page 22: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/22.jpg)
22
Logic Circuits Design
Present State
Input Next State
Output
P1 P0 X1 X0 N1 N0 C1 C0
0 0 0 0 0 1 0 0
0 0 0 1 1 0 0 0
0 0 1 0 0 0 1 0
0 1 0 0 1 0 0 0
0 1 0 1 0 0 0 1
0 1 1 0 0 1 1 0
1 0 0 0 0 0 0 1
1 0 0 1 0 1 0 1
1 0 1 0 1 0 1 0
X X 1 1 X X X X
1 1 X X X X X X
11001010N1 XPXPPXXP
00 01 11 10
00 0 1 X 0
01 1 0 X 0
11 X X X X
10 0 0 X 1
P1P0X1X0 N1
10010101N0 XPXPXXPP
00 01 11 10
00 1 0 X 0
01 0 0 X 1
11 X X X X
10 0 1 X 0
P1P0X1X0 N0
![Page 23: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/23.jpg)
23
Logic Circuits Design
Present State
Input Next State
Output
P1 P0 X1 X0 N1 N0 C1 C0
0 0 0 0 0 1 0 0
0 0 0 1 1 0 0 0
0 0 1 0 0 0 1 0
0 1 0 0 1 0 0 0
0 1 0 1 0 0 0 1
0 1 1 0 0 1 1 0
1 0 0 0 0 0 0 1
1 0 0 1 0 1 0 1
1 0 1 0 1 0 1 0
X X 1 1 X X X X
1 1 X X X X X X
X1C1
00 01 11 10
00 0 0 X 1
01 0 0 X 1
11 X X X X
10 0 0 X 1
P1P0X1X0 C1
P0X0X1P1C0
00 01 11 10
00 0 0 X 0
01 0 1 X 0
11 X X X X
10 1 1 X 0
P1P0X1X0 C0
![Page 24: ECE2030 Introduction to Computer Engineering Lecture 16: Finite State Machines Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering](https://reader035.vdocuments.mx/reader035/viewer/2022062304/56649ea95503460f94bad991/html5/thumbnails/24.jpg)
24
Logic Circuits of the Vending Machine
X1C1P0X0X1P1C0
P1X1X0P0P1X0X1P0N1 P0X1P1X0X0X1P0P1N0
D1F/F
1 2
P1N1
D0F/F
1 2
P0N0
X1 X0 P0P1
C0
C1