Beruflich Dokumente
Kultur Dokumente
Administrivia
No class this Friday (check out the undergraduate research
symposium)
HW 8 due Monday, May 22
Last Lecture
FSM minimization
Today
Factoring FSMs
Output encoding
Communicating FSMs
Design Example
highway
Initial attempt:
description
assert green/yellow/red highway lights
assert green/yellow/red highway lights
C'
HG
description
highway green (farm road red)
highway yellow (farm road red)
farm road green (highway red)
farm road yellow (highway red)
HY0
HY1
HY2
HY3
HY4
C'
description
place FSM in initial state
detect vehicle on the farm road
short time interval expired
long time interval expired
outputs
HG, HY, HR
FG, FY, FR
ST
description
assert green/yellow/red highway lights
assert green/yellow/red highway lights
start timing a short or long interval
description
highway green (farm road red)
highway yellow (farm road red)
farm road green (highway red)
farm road yellow (highway red)
State diagram
Reset
(TLC)'
HG
TLC / ST
TS'
TS / ST
HY
FY
TS / ST
TS'
TL+C' / ST
FG
Inputs
C
TL
0
0
1
1
1
0
0
TS
0
1
0
1
SA1:
SA2:
SA3:
(TL+C')'
H0 = PS1PS0'
F0 = PS1PS0
SA3
Present State
HG
HG
HG
HY
HY
FG
FG
FG
FY
FY
HG = 00
HG = 00
HG = 0001
Next State
HG
HG
HY
HY
FG
FG
FY
FY
FY
HG
HY = 01
HY = 10
HY = 0010
FG = 11
FG = 01
FG = 0100
Outputs
ST H
0
Green
0
Green
1
Green
0
Yellow
1
Yellow
0
Red
1
Red
1
Red
0
Red
1
Red
FY = 10
FY = 11
FY = 1000
F
Red
Red
Red
Red
Red
Green
Green
Green
Yellow
Yellow
(one-hot)
Output-based encoding
Reuse outputs as state bits - use outputs to help
distinguish states
why create new functions for state bits when output can
serve as well
fits in nicely with synchronous Mealy implementations
Inputs
C
TL
0
0
1
1
1
0
0
TS
0
1
0
1
Present State
HG
HG
HG
HY
HY
FG
FG
FG
FY
FY
HG = ST H1 H0 F1 F0 + ST H1 H0 F1 F0
HY = ST H1 H0 F1 F0 + ST H1 H0 F1 F0
FG = ST H1 H0 F1 F0 + ST H1 H0 F1 F0
HY = ST H1 H0 F1 F0 + ST H1 H0 F1 F0
Next State
HG
HG
HY
HY
FG
FG
FY
FY
FY
HG
Outputs
ST H
0
00
0
00
1
00
0
01
1
01
0
10
1
10
1
10
0
10
1
10
F
10
10
10
10
10
00
00
00
01
01
traffic light
controller
ST
TS TL
timer
module FSM(HR, HY, HG, FR, FY, FG, ST, TS, TL, C, reset, Clk);
output
HR;
output
HY;
output
HG;
parameter highwaygreen
output
FR;
parameter highwayyellow
output
FY;
parameter farmroadgreen
output
FG;
parameter farmroadyellow
output
ST;
input
TS;
input
TL;
assign HR = state[6];
input
C;
assign HY = state[5];
input
reset;
assign HG = state[4];
input
Clk;
assign FR = state[3];
assign FY = state[2];
reg [6:1] state;
assign FG = state[1];
reg
ST;
=
=
=
=
6'b001100;
6'b010100;
6'b100001;
6'b100010;
FSM 1
traffic light
controller
ST
TS TL
timer
FSM 2
CLK
FSM1
X
Y==0
A
[1]
Y==0
X==0
C
[0]
FSM2
Y
X==1
Y==1
B
[0]
X==0
D
[1]
X==1
X==0
S1
[0]
S4
[0]
S2
[0]
S5
[0]
S3
[1]
S6
[0]
0 or 1
S6
...100 [0]
0 or 1
parameter
parameter
parameter
parameter
parameter
parameter
parameter
S0
S1
S2
S3
S4
S5
S6
=
=
=
=
=
=
=
[0,0,0];
[0,0,1];
[0,1,0];
[0,1,1];
[1,0,0];
[1,0,1];
[1,1,0];
//reset state
//strings ending
//strings ending
//strings ending
//strings ending
//strings ending
//strings ending
reg state[0:2];
assign
assign
assign
assign
Q0 = state[0];
Q1 = state[1];
Q2 = state[2];
Z = (state == S3);
in
...0
in ...01
in ...010
in
...1
in ...10
in ...100
0 or 1
state
state
state
state
state
state
=
=
=
=
=
=
S1;
S1;
S3;
S6;
S5;
S6;
reached);
Review of process
understanding problem
write down sample inputs and outputs to understand
specification
derive a state diagram
write down sequences of states and transitions for
sequences to be recognized
minimize number of states
add missing transitions; reuse states as much as possible
state assignment or encoding
encode states with unique patterns
simulate realization
verify I/O behavior of your state diagram to ensure it
matches specification