Professional Documents
Culture Documents
Finite State Machine Design: Prith Banerjee Ece C03 Advanced Digital Design Spring 1998
Finite State Machine Design: Prith Banerjee Ece C03 Advanced Digital Design Spring 1998
Outline
Review of sequential machine design
Moore/Mealy Machines
FSM Word Problems
Finite string recognizer
Traffic light controller
Registers
Combinational Functional
Units (e.g., ALU)
Busses
Qualifiers
Control
Control
State
Control
Signal
Outputs
Qualifiers
and
Inputs
"Puppet"
Datapath
Reset
0
Even
[0]
1
1
Odd
[1]
State
Diagram
Present State
Even
Even
Odd
Odd
Input
0
1
0
1
Next State
Even
Odd
Odd
Even
Output
0
0
1
1
Input
0
1
0
1
Input
NS
Input
CLK
R
CLK
PS/Output
\Reset
T FF Implementation
D FF Implementation
1
Output
Q
R
\Reset
Input
Clk
Output
Timing Behavior:
Input
10011
ECE C03
Lecture
120 1 0 1 1 1 0
Clock
Inputs
Immediate Outputs:
affect datapath immediately
could cause inputs from datapath to change
Outputs
Delayed Outputs:
take effect on next clock edge
propagation delays must exceed hold times
FSM 1
CLK
FSM 1
Y=0
Y=0
A
[1]
X=0
X=0
C
[0]
X
FSM 2
X=1
Y=0,1
X=1
Y=1
B
[0]
X=0
D
[1]
N
Coin
Sensor
D
Reset
Vending
Machine
FSM
Open
Gum
Release
Mechanism
Clk
10
N
S1
Inputs: N, D, reset
Output: open
D
S2
S4
S5
S6
[open]
[open]
[open]
S3
S0
S7
S8
[open]
[open]
11
Reset
0
0
N
5
D
N
10
D
10
N, D
15
[open]
15
reuse states
whenever
possible
Inputs
D N
0
0
1
1
0
0
1
1
0
0
1
1
X
0
1
0
1
0
1
0
1
0
1
0
1
X
Next
State
Output
Open
0
5
10
X
5
10
15
X
10
15
15
X
15
0
0
0
X
0
0
0
X
0
0
0
X
1
12
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
Next State
D1 D0
Output
Open
0 0
0 1
1 0
X X
0 1
1 0
1 1
X X
1 0
1 1
1 1
X X
1 1
1 1
1 1
X X
0
0
0
X
0
0
0
X
0
0
0
X
1
1
1
X
13
Q1 Q0
DN
0
Q1 Q0
DN
N
D
Q0
K-map for D1
Q1
D
Q0
N
N
\ Q0
Q0
\N
Q1
N
Q1
D
D1
D FF easiest to use
Q1
1
N
D
Q0
K-map for D0
D
CLK
Q1
\ Q1
Q1
Q1 Q0
DN
0
Q0
K-map for Open
D1 = Q1 + D + Q0 N
\reset
OPEN
D0
CLK
\reset
Q0
\ Q0
D0 = N Q0 + Q0 N + Q1 N + Q1 D
OPEN = Q1 Q0
8 Gates
14
Not flexible enough for describing very complex finite state machines
Not suitable for gradual refinement of finite state machine
Do not obviously describe an algorithm: that is, well specified
sequence of actions based on input data
algorithm = sequencing + data manipulation
separation of control and data
15
Decision Box
Output Box
State Code
State
Name
State
Output List
T
***
State Box
Condition
Condition
Box
Conditional
Output List
ASM
Block
Output
Box
Exits to
other ASM Blocks
16
ASM Notation
Condition Boxes:
Ordering has no effect on final outcome
Equivalent ASM charts:
A exits to B on (I0 I1) else exit to C
A
010
I0
T
010
I1
T
F
I1
F
F
I0
T
B
17
T
Odd
Present Next
Input State
State Output
F
Even
Even
T
Even
Odd
F
A
Odd
Odd
T
A
Odd
Even
1
H.Z
Trace
Tracepaths
pathsto
toderive
derive
state
transition
state transitiontables
tables
Present Next
Input State
State Output
0
0
0
0
1
0
0
1
0
1
1
1
1
1
1
0
18
00
10
10
F
F
F
F
15
01
11
H.Open
T
Reset
F
F
T
T
19
Zk
Outputs
Combinational
Logic for
Outputs and
Next State
State Register
Clock
State
Feedback
State
Register
Xi
Inputs
Mealy Machine
Comb.
Logic for
Outputs
Combinational
Logic for
Next State
(Flip-flop
Inputs)
Zk
Outputs
Clock
state
feedback
Outputs depend on
state AND inputs
Input change causes
an immediate output
change
Asynchronous signals
20
(N D + Reset)/0
Reset/0
N D + Reset
Reset
0
Reset/0
[0]
Reset
N/0
N
5
5
N D/0
D/0
ND
[0]
N/0
10
10
D
D/1
Mealy
Machine
N D/0
N+D/1
[0]
N+D
ND
15
15
[1]
Reset/1
Reset
21
States vs Transitions
Mealy Machine typically has fewer states than Moore Machine
for same output sequence
0
0/0
0
[0]
Different # of states
1/0
0/0
1
1/1
[0]
1
2
[1]
S0
00
S0
IN
S1
IN
01
IN
S2
S1
Equivalent
ASM Charts
IN
10
H.OUT
IN
H.OUT
22
J
Q
C
KR Q
FFa
A
\A
Input X
Output Z
State A, B = Z
\Reset
Clk
X
X
\A
J
Q
C
KR Q
FFb
Z
\B
\Reset
23
Partially Derived
State Transition
Table
0 1
1 0
1 1
X
0
1
0
1
0
1
0
1
A+
?
1
0
?
1
0
1
1
B+
?
1
0
?
0
1
1
0
Z
0
0
1
1
0
0
1
1
24
Z=B
Ka = X B
Kb = X xor A
A+
B+
25
00
S0
11
S3
H.Z
X
1
S1
01
S2
10
H.Z
0
26
DA
D
C
Q
R Q
\A
X
\A
\X
J
Q
C
KR Q
\Reset
A
X
B
\B
\Reset
DA
\X
B
Z
\X
X
A
27
100
Note glitches
in Z!
Clk
A
Outputs valid at
following falling
clock edge
B
Z
\Reset
Reset
AB=00
Z =0
X =1
AB=00
Z =0
X =0
AB=00
Z =0
X =1
AB=01
Z =0
X =0
AB=11
Z=1
X
0
1
Partially completed
0 1
0
state transition table
1
based on the signal
1 0
0
trace
1
1 1
0
1
ECE C03 Lecture
X =1
AB=10
Z =1
A B
0 0
12
A+
0
0
?
1
?
0
1
?
X =1
AB=01
Z =0
B+
1
0
?
1
?
1
0
?
Z
0
0
?
0
?
1
1
?
28
= A X + B X
A+
B+
29
S0
H. Z
00
0
X
0
S1
10
S2
H. Z
X
1
S3
01
11
H.Z
X
0
30
Zk
Outputs
Combinational
Logic for
Outputs and
Next State
State Register
Clock
state
feedback
31
Case Studies:
Finite String Pattern Recognizer
Traffic Light Controller
32
A finite string recognizer has one input (X) and one output (Z).
The output is asserted whenever the input sequence 010
has been observed, as long as the sequence 100 has never been
seen.
Step 1. Understanding the problem statement
Sample input/output behavior:
X: 00101010010
Z: 00010101000
X: 11011010010
Z: 00000001000
33
Outputs 1
Reset
S1
[0]
S4
[0]
S2
[0]
S5
[0]
S3
[1]
S6
[0]
Loops in State
34
Reset
S1
[0]
S4
[0]
S2
[0]
S5
[0]
S3
[1]
S6
[0]
35
Reset
S1
[0]
S4
[0]
S2
[0]
S5
[0]
S3
[1]
S6
[0]
36
Reset
S1
[0]
S4
[0]
S2
[0]
S5
[0]
S3
[1]
S6
[0]
37
38
39
HL
FL
Highway
Highway
HL
FL
C
Farmroad
40
Description
place FSM in initial state
detect vehicle on farmroad
short time interval expired
long time interval expired
Output Signal
HG, HY, HR
FG, FY, FR
ST
Description
assert green/yellow/red highway lights
assert green/yellow/red farmroad lights
start timing a short or long interval
Description
Highway green (farmroad red)
Highway yellow (farmroad red)
Farmroad green (highway red)
Farmroad yellow (highway red)
41
S0
S3
H.HG
H.FR
H.HR
H.FY
S1
H.HY
H.FR
S2
H.HR
H.FG
42
S0
H.HG
H.FR
0
H.HG
H.FR
0
TL
TL C
1
0
1
H.ST
1
H.ST
S1
H.HY
H.FR
S1
H.HY
H.FR
43
S1
H.HY
H.FR
0
TS
H.ST
S2
H.HR
H.FG
44
S0
H.HG
H.FR
0
H.ST
1
TL C
S3
H.HR
H.FY
TS
1
H.ST
S1
H.HY
H.FR
0
TS
H.ST
H.ST
S2
H.HR
H.FG
TL + C
1
Complete ASM
Chart
forLecture
Traffic Light
ECE
C03
12 Controller
45
TS/ST
S1: HY
TS
S1
S2: FG
S3
TS
TS/ST
S2
S0: HG
S3: FY
TL + C/ST
TL C
46
Summary
Review of sequential machine design
Moore/Mealy Machines
FSM Word Problems
Finite string recognizer
Traffic light controller
47