Professional Documents
Culture Documents
Next
k
k State
State
Registers Current
State Combinational
Clock Logic
m n
Input Output
Specification:
• One input ( “0” or “1”)
IN
Lock U
• One output (“Unlock”
CLK
signal)
How many
state bits
• UNLOCK is 1 if and only if:
do I need?
Last 4 inputs were the
“combination”: 0110
m
inputs Clocked n
FSM outputs
0
1
SX S0 S01 S011 S0110
1 U=0 0 U=0 1 U=0 1 U=0 0 U=1
0 0
1
Heavy circle
Designing our lock … Means
INITIAL state
• Need an initial state; call it SX. NAME
of state
• Must have a separate state for 0
XXX
each step of the proper entry
U=0
sequence OUTPUT INPUT
• Must handle other (erroneous) when in this causing
state transition
entries
S1 S3 S1 S3
0 1 1 1/0
0 0/0 0/1
0
S2 Inputs/outputs S2 0/0
0 0
1 1/0
0 0 diagrams can be
1
described by truth
IN Current State Next State Unlock tables…
0 000 SX S0 001 0
1 000 SX SX 000 0 Binary encodings are
0 001 S0 S0 001 0
assigned to each
1 001 S0 S01 011 0
0 011 S01 S0 001 0 state (a bit of an art)
1 011 S01 S011 010 0
0 010 S011 S0110 100 0 The truth table can
1 010 S011 SX 000 0
0 100 S0110 S0 001 1 then be simplified
1 100 S0110 S01 011 1 using the reduction
The assignment of codes to
techniques we
states can be arbitrary, however, learned for
if you choose them carefully you combinational logic
can greatly reduce your logic
requirements.
6.004 Computation Structures L6: Finite State Machines, Slide #7
Now Put It In Hardware!
We assume 4 inputs ⇒ 24 locations,
inputs are each location supplies
synchronized 4 bits
with clock…
unlock
IN
ROM
16x4
Current Next
state state
3 3
5 states
⇒ 3-bit encoding
inputs outputs
ROM
Two design choices:
(1) outputs only depend on state (Moore)
STATE NEXT (2) outputs depend on inputs + state (Mealy)
s s
s state bits ⇒ 2s possible states
Clock
STATE
NEXT
Clock Clock Clock Clock Clock
Period Period Period Period Period
1 2 3 4 5
reset
4. Synchronizing input changes with
U state update?
IN
CLK
Now, that’s a funny
looking state machine
x y z
2. Same question: m n
States States
1
0=OFF, 0 1 vs.
1=ON? 0
1 1 1 1
"1111" = 0 1
Surprise! 01 0 0 0
1 1 1 1 1
0 1 vs. 0 1
0 0 0 0 0
ENGINEERING GOAL:
• HAVE an FSM which works...
• WANT simplest (ergo cheapest) equivalent FSM.
GOAL: Make our ant smart enough to get out of a maze like:
LOST L+R
F
__
LR
“lost” is the
initial state
_ _
__ LR
LR
_ _ R
__ LR
LR
Wall1
_
TR,F R
Action: Step and turn left a little, till not touching (again)
L+R _
LR
LOST L+R RCCW Wall2
F TL L TL,F
_ _ R
__ LR __
LR LR
Wall1
_
TR,F R
Reduction Strategy:
Find pairs of equivalent states, MERGE them.
L+R _
LR
LOST L+R RCCW Wall2
F TL L TL,F
_ _ R
__ LR __
LR LR
R _
R
Wall1 Corner
_
TR,F R TR,F
L+R _
LR
LOST L+R RCCW Wall2
F TL L TL,F
_ _ R
__ LR __
LR LR
Wall1
TR,F
_
R
S L R | S’ TR TL F
-------+-----------
L+R 00 0 0 | 00 0 0 1
00 0 1 | 01 0 0 1
LOST L+R RCCW 00 1 0 | 01 0 0 1
F TL 00 1 1 | 01 0 0 1
01 0 1 | 01 0 1 0
__ 01 1 0 | 01 0 1 0
LR 01 1 1 | 01 0 1 0
S1’ S1S 0
S L R | S’ TR TL F 00 01 11 10
-------+----------- 00 0 1 1 1
00 0 0 | 00 0 0 1 LR 01 0 0 1 1
00 1 - | 01 0 0 1 11 0 0 0 1
LOST
00 - 1 | 01 0 0 1 10 0 0 0 1
01 1 - | 01 0 1 0
S1! = S1 S 0 + LS1 + L RS 0
RCCW 01 - 1 | 01 0 1 0
01 0 0 | 10 0 1 0
10 – 0 | 10 1 0 1 S0’ S1S 0
WALL1 00 01 11 10
10 – 1 | 11 1 0 1
00 0 0 0 0
11 1 - | 01 0 1 1
LR 01 1 1 1 1
WALL2 11 0 0 | 10 0 1 1
11 1 1 1 1
11 0 1 | 11 0 1 1
10 1 1 1 0
Complete Transition table
S 0! = R + L S1 + LS 0
6.004 Computation Structures L6: Finite State Machines, Slide #23
Ant Schematic
• What if:
We replaced the ROM with a RAM
and have outputs that modify the
RAM?
Vin 0 VTC of
Q “closed” latch
Vout Y
1 Vout Latched in
a ‘1’ state
Latched in
Recall that the latch output is an undefined
state VTC of feedback
the solution to two
path (Vin=Vout)
simultaneous constraints:
1. The VTC of path
thru MUX; and Latched in
a ‘0’ state
2. Vin = Vout Vin
additional registers.
And one here will almost
certainly get resolved.
Clk