Académique Documents
Professionnel Documents
Culture Documents
Logistics
HW8 due Monday (6/2), HW9 due Friday (6/6)
Ant extra credit due 6/6
Take home extra credit final handed out 6/6
Final exam 6/9 8:30am
Review?
Last lecture
Simplification
T
Today
d
State encoding
Ó One-hot encoding
Ó Output encoding
CSE370, Lecture 24
22 1
Doesn
Doesn’tt take pennies or quarters Reset
CSE370, Lecture 24
22 2
A vending machine: State minimization
CSE370, Lecture 24
22 3
CSE370, Lecture 24
22 4
A vending machine: Logic minimization
Q1 Q1
D1 Q1 Open
D0
0 0 1 1
0 1 1 0 0 0 1 0
0 1 1 1 N 1 0 1 1 N 0 0 1 0 N
D X X X X
D X X X X D X X 1 X
1 1 1 1
0 1 1 1 0 0 1 0
Q0 Q0 Q0
D1 = Q1 + D + Q0 N
D0 = Q0’ N + Q0 N’ + Q1 N + Q1 D
OPEN = Q1 Q0
CSE370, Lecture 24
22 5
CSE370, Lecture 24
22 6
State encoding
Assume n state bits and m states
2n! / (2n – m)! possible encodings
Ó Example: 3 state bits
bits, 4 states,
states 1680 possible state assignments
CSE370, Lecture 24
22 7
State-encoding strategies
No guarantee of optimality
An intractable problem
CSE370, Lecture 24
22 8
One-hot encoding
One-hot: Encode n states using n flip-flops
Assign a single “1” for each state
Ó Example: 0001,
0001 0010,
0010 0100,
0100 1000
Propagate a single “1” from one flip-flop to the next
Ó All other flip-flop outputs are “0”
CSE370, Lecture 24
22 9
CSE370, Lecture 24
22 10
Example: A vending machine … again
15 cents for a cup of coffee
Doesn
Doesn’tt take pennies or quarters Reset
CSE370, Lecture 24
22 11
CSE370, Lecture 24
22 12
Designing from the state diagram
Reset D0 = Q0D’N’
D' N' D1 = Q0N + Q1D
D’N’
N
0¢ D2 = Q0D + Q1N + Q2D’N’
D' N' N D3 = Q1D + Q2D + Q2N + Q3
D OPEN = Q3
5¢
N+D
15¢
[open] 1
CSE370, Lecture 24
22 13
Output encoding
Reuse outputs as state bits
Why create new functions when you can use outputs?
Bits from state assignments are the outputs for that state
Ó Take outputs directly from the flip-flops
ad hoc - no tools
Yields small circuits for most FSMs
CSE370, Lecture 24
22 14
Vending machine
--- already in output encoding form
Reset D0 = Q0D’N’
D' N' D1 = Q0N + Q1D
D’N’
N
0¢ D2 = Q0D + Q1N + Q2D’N’
D' N' N D3 = Q1D + Q2D + Q2N + Q3
D OPEN = Q3
5¢
N+D
15¢
[open] 1
CSE370, Lecture 24
22 15
clock
open/closed
CSE370, Lecture 24
22 16
Separate data path and control
Design datapath first Control has 2 outputs
After the state diagram Mux control to datapath
Before the state encoding Lock open/closed
C1 C2 C3 new reset
4 4 4 mux
multiplexer
control
4 controller
t ll
value comparator
clock
4 equal
open/closed
CSE370, Lecture 24
22 17
ERR
closed
not equal
not equal
& new not equal
& new
S0 S1 S2 & new S3
closed closed closed
start open
mux=C1
mux C1 equa
equal mux=C2
mux C2 equa
equal mux=C3
mux C3 equa
equal
& new & new & new
CSE370, Lecture 24
22 18
Design the datapath
C1 C2 C3 valuei C1i C2i C3i
4 4 4 mux mux
multiplexer
control control
4
value comparator
4 equal
CSE370, Lecture 24
22 19
CSE370, Lecture 24
22 20
FSM has 4 state bits and 2 inputs...
Output encoded!
Outputs and state bits are the same
CSE370, Lecture 24
22 21
not equal
not equal
& new not equal
& new
S0 S1 S2 & new S3
closed closed closed
start open
mux=C1 equal mux=C2 equal mux=C3 equal
& new & new & new
D0 = Q0N’
D1 = Q0EN + Q1N’ Can we encode the ERR state
D2 = Q1EN + Q2N’ with reset/preset of flipflops?
D3 = Q2EN + Q3
CSE370, Lecture 24
22 22
Answer: Yes! ERR
closed
not equal
not equal
& new not equal
& new
S0 S1 S2 & new S3
closed closed closed
start open
mux=C1 equal mux=C2 equal mux=C3 equal
& new & new & new
CSE370, Lecture 24
22 23
D0 = Q0N’
D1 = Q0EN + Q1N’
D2 = Q1EN + Q2N’
D3 = Q2EN + Q3
Preset0 = start
Preset1,2,3 = 0
Reset0 = start’(E’N + (Q0+Q1+Q2+Q3)’)
Reset1,2,3 = start + (E’N + (Q0+Q1+Q2+Q3)’)
CSE370, Lecture 24
22 24
FSM design
FSM-design procedure
1. State diagram
g
2. state-transition table
3. State minimization
4. State encoding
5. Next-state logic minimization
6. Implement the design
CSE370, Lecture 24
22 25