Professional Documents
Culture Documents
FSM Word Problems PDF
FSM Word Problems PDF
FSM Word Problems PDF
FSM Example
Traffic light controller
Traffic sensors: TA, TB (TRUE when theres traffic)
Lights: LA, LB
If LA = GREEN, then LA remains GREEN as
long as A has cars (i.e. TA = 1)
If LB = GREEN, then LB remains
GREEN as long as B has cars
(i.e. TB = 1)
Light colors change
(GREEN, RED)
(YELLOW, RED)
(RED, GREEN)
FSM Blackbox
Inputs: CLK, TA, TB
Outputs: LA, LB
If LB is GREEN: Case
FSM Blackbox
FSM Inputs: CLK, TA, TB, CR (to reset counter)
FSM Outputs: LA, LB, CT (TRUE if count is 15, all 1s)
0000
Datapath: 4-bit counter
4
CLK
TB
CT
Traffic
Light
Controller
Reset
CR
TA
MUX
LA
4-bit D-FFs
LB
CR
4-input AND
CT
0001
+
4
TA TB
CT
S0
Reset
LA = G
LB= R
CR= 1
S5
LA = R
LB= Y
CR= *
TA TB
TA TB
S1
LA = G
LB= R
CR= 0
LA LB
S4
CT
LA = R
LB= G
CR= 0
LA LB
CT
S2
CT
LA = Y
LB= R
CR= *
LA LB
TA TB
TA TB
LA LB
TA TB
S3
LA = R
LB= G
CR= 1
LA LB
TA TB
LA LB
String Recognition
Simple case: recognize 1101
0
0
Reset
0
1
0
11
0
110
0
1101
1
String Recognition
General rules:
1. Create string matching tree
2. State output = 1 if a pattern is contained along the path
3. Add failure edges: find longest suffix of string seen so
far and transition to the corresponding prefix state
String Recognition
Example: 1101, 1011, 101
1. Create string matching tree
2. State output = 1 if a pattern is contained along the path
3. Add failure edges: find longest suffix of string seen so
far and transition to the corresponding prefix state
Reset
1
0
11
0
110
0
1101
1
10
0
101
1
1011
1
String Recognition
Example: 1111, 1011, 101
1. Create string matching tree
2. State output = 1 if a pattern is contained along the path
3. Add failure edges: find longest suffix of string seen so
far and transition to the corresponding prefix state
1
Reset
1
0
11
0
0
10
0
111
0
1
0
1111
1
0
1
101
1
0
0
1
1011
1
S2
S1
S0
FF
FF
FF
FF
OUTPUT
INPUT