You are on page 1of 3

Lecture 23 FSM design process

1. Understand the problem


 Design example: Traffic light controller – State diagram and state-transition table
2. Determine the machine’s states
– Consider missing transitions: Will the machine start?
– Minimize the state diagram: Reuse states where possible
3. Encode the states
– Encode states, outputs with a reasonable encoding choice
– Consider the implementation target
4. Design the next-state logic
– Minimize the combinational logic
– Choices made in steps 2 & 3 affect the logic complexity
5. Implement the FSM

1 2

Example: Traffic light controller Example: Traffic light controller


 A busy highway is intersected by a little used farm road
 Highway/farm road intersection  Detectors C sense the presence of cars on the farm road
farm road  With no car on farm road, lights remain Green in highway
direction
car sensors (C)  If vehicle on farm road, highway lights go from Green to Yellow
to Red, allowing the farm road lights to become Green
 These stay Green only as long as a farm road car is detected but
never longer than a set interval (say, 20 time units)
highway  When these are met, farm lights transition from Green to Yellow
to Red, allowing highway to return to Green
 Even if farm road vehicles are waiting, highway gets at least a
set interval as Green (say, 20 time units)

3 4

What are inputs and outputs? What are the states?


 Inputs  Outputs  How about color of the lights?
 Reset  HG (highway green)
 C (farm road car  HY (highway yellow)  HG (highway green)
detector)  HR (highway red)  HY (highway yellow)
 FG (farm road green)
 HR (highway red)
 FY (farm road yellow)
 FR (farm road red)  FG (farm road green)
 FY (farm road yellow)
 FR (farm road red)

5 6
Any redundancy? Partial traffic light controller

 If the highway light is green or yellow,  Useful to walk through typical


the farm road light must be red. execution sequence
C
 States HG HY0 HY1 HY2 HY3 HY4
 HG (highway green)
 HY (highway yellow)
 FG (farm road green) C'
 FY (farm road yellow)  What's the problem?
7 8

FSM can get very big! External timer

 Utilize external timer like a subroutine  ST resets timer and starts counting
 Timer generates a short time pulse (TS) and a long
time pulse (TL)
TL·C HY TS  TS is to be used for timing yellow lights and TL for
a FG
HG [ST] HYb [ST] green lights

ST ST
Traffic Light
(TL·C)' TS' Controller Interval
TS TS short
Timer
TL
TL long

9 10

Revised FSM specification Traffic light controller


 Inputs
reset place FSM in initial state
C detect vehicle on the farm road reset C
TS short time interval expired
TL long time interval expired HG
ST
 Outputs HY Traffic Light
Controller Interval
HG, HY, HR assert green/yellow/red highway lights TS
FG, FY, FR assert green/yellow/red farm road lights Timer
ST start timing a short or long interval HR
TL
 State
HG highway green (farm road red) FG FY FR
HY highway yellow (farm road red)
FG farm road green (highway red)
FY farm road yellow (highway red)

11 12
Moore/Mealy hybrid State encoding

(TL•C)' Reset
 Let's use a one-hot encoding:
HG  HG = 0001
TL•C / ST TS / ST  HY = 0010
TS' HY FY TS'  FG = 0100
 FY = 1000
TS / ST TL+C' / ST
FG

(TL+C')'

13 14

Next-state logic Outputs

 P3 = (C'·Q2) + (TL·Q2) + (TS'·Q3)  Green = 00


 Yellow = 01
 P2 = (TS·Q1) + (C·TL'·Q2)  Red = 10
 P1 = (C·TL·Q0) + (TS'·Q1)
 Two sets of outputs: H1H0 and F1F0
 P0 = (C'·Q0) + (TL'·Q0) + (TS·Q3)
 H1 = Q 3 + Q 2
 H0 = Q 1
 ST = (C·TL·Q0) + (TS·Q1) + (C'·Q2) +  F1 = Q 1 + Q 0
(TL·Q2) + (TS·Q3)  F0 = Q 3
15 16

State partitioning State partitioning


Reset
(TL•C)' Add idle states
(TL•C)' Reset
Add return arcs
HG Label idle wait loops
HG
TL•C / ST
TL•C / ST TS / ST TS•FY
(TS•HY)’ Reset
TS' HY TS / ST
TS' HY FY TS' HR
TS / ST
FR
FY TS'
TS / ST TL+C' / ST (TS•FY)’
FG TS•HY
TL+C' / ST
FG
(TL+C')'

(TL+C')'
17 18

You might also like