Upload
vominh
View
216
Download
1
Embed Size (px)
Citation preview
19 OhehotPage 1
ECE 238L © 2006
One-Hot EncodedFinite State Machines
19 OhehotPage 2
ECE 238L © 2006
Example State Machine
C
B
InA
InA’
Z
A
D
InA
InB
InA’
InB’
Z
InA InB CS NS Z
0 - A A 01 - A B 00 - B A 11 - B C 1- 0 C C 1- 1 C D 1- - D A 0
InA InB CS NS Z
0 - 00 00 01 - 00 01 00 - 01 00 11 - 01 10 1- 0 10 10 1- 1 10 11 1- - 11 00 0
State A = 00State B = 01State C = 10State D = 11
19 OhehotPage 3
ECE 238L © 2006
Example Machine Implementation
N1 = Q1•Q0’ + Q1’•Q0•InAN0 = Q1•Q0’•InB + Q1’•Q0’•InAZ = Q1’•Q0 + Q1•Q0’
9 gates21 gate inputs
D Q
D Q Q0
CLK
N0InBQ1Q0’
InA
Q1’Q0’
Q1N1Q1
Q0’
InA
Q1’Q0
CLK
ZQ1
Q0’
Q1’
Q0
19 OhehotPage 4
ECE 238L © 2006
Choose a Different Encoding
• A=1000, B=0100, C=0010, D=0001InA InB CS NS Z
0 - 1000 1000 01 - 1000 0100 00 - 0100 1000 11 - 0100 0010 1- 0 0010 0010 1- 1 0010 0001 1- - 0001 1000 0
InA InB CS NS Z
0 - 1--- 1000 01 - 1--- 0100 00 - -1-- 1000 11 - -1-- 0010 1- 0 --1- 0010 1- 1 --1- 0001 1- - ---1 1000 0
Because of the state encodings,there are many illegal states.
This TT with all these input don’t cares is the result
This is called a one-hot encoding.
Only one state bit is on at a time
19 OhehotPage 5
ECE 238L © 2006
One-Hot Encoding Results
By inspection we see:
NA = A•InA’ + B•InA’ + DNB = A•InANC = B•InA + C•InB’ND = C•InBZ = B + C
• Will require 4 flip flops– One per state– Call the current state bits A, B, C, and D– Call the next state bits NA, NB, NC, and ND
C
B
InA
InA’
Z
A
D
InA
InB
InA’
InB’
Z
19 OhehotPage 6
ECE 238L © 2006
One-Hot Implementation
9 gates19 gate inputs
D Q
D Q B
CLK
N_B
AN_A
CLK
ZB
C
D Q
D Q D
CLK
N_D
CN_C
CLK
B
InA’
D
A
InA
C
InB
A
InA’ B
InA
C
InB’
19 OhehotPage 7
ECE 238L © 2006
One-Hot - Observations
• Choosing a one-hot encoding results in many, many don’t cares in transition table
• Minimization results in simpler IFL and OFL
• Can do one-hot design by inspection– without using transition tables…
19 OhehotPage 8
ECE 238L © 2006
State EncodingA 100B 010C 001
Another One-Hot Example
C
B
y
x’
Ax
y’z
y’z’
19 OhehotPage 9
ECE 238L © 2006
D Q ANA
D Q BNB
D Q CNC
With one-hot encoding, each state has its own flip flop.
Note: ‘A’ is the name of a state. It is also the name of the wire coming out from the flip flop for state ‘A’.
The same holds true for states ‘B’ and ‘C’
State EncodingA 100B 010C 001
State Encoding and Structure
19 OhehotPage 10
ECE 238L © 2006
When is A the next state?
Look at the arcs entering state A
NA = A•x’ + B•y’z + C
One-Hot Encodings By Inspection
C
B
y
x’
Ax
y’z
y’z’
19 OhehotPage 11
ECE 238L © 2006
When is A the next state?
Look at the arcs entering state A
NA = A•x’ + B•y’z + C
One-Hot Encodings By Inspection
C
B
y
x’
Ax
y’z
y’z’
19 OhehotPage 12
ECE 238L © 2006
When is A the next state?
Look at the arcs entering state A
NA = A•x’ + B•y’z + C
One-Hot Encodings By Inspection
C
B
y
x’
Ax
y’z
y’z’
19 OhehotPage 13
ECE 238L © 2006
When is A the next state?
Look at the arcs entering state A
NA = A•x’ + B•y’z + C
One-Hot Encodings By Inspection
C
B
y
x’
Ax
y’z
y’z’
Similar reasoning leads to:NB = A•x + B•y’z’NC = B•y
19 OhehotPage 14
ECE 238L © 2006
The Key Lock Problem – One-Hot Version
There will be 6 flip flops
One for each state
19 OhehotPage 15
ECE 238L © 2006
Key Lock Input Forming Logic
19 OhehotPage 16
ECE 238L © 2006
A+ = (PUSHED’ A) + (ECNT3’ E)+ (WAITDONE F) + (LOCKED D)
Key Lock Input Forming Logic
19 OhehotPage 17
ECE 238L © 2006
A+ = (PUSHED’ A) + (ECNT3’ E)+ (WAITDONE F) + (LOCKED D)
B+ = (PUSHED’ B)+(PUSHED 7 A)
Key Lock Input Forming Logic
19 OhehotPage 18
ECE 238L © 2006
A+ = (PUSHED’ A) + (ECNT3’ E)+ (WAITDONE F) + (LOCKED D)
B+ = (PUSHED’ B)+(PUSHED 7 A)C+ = (PUSHED’ C)+(PUSHED 8 B)
Key Lock Input Forming Logic
19 OhehotPage 19
ECE 238L © 2006
A+ = (PUSHED’ A) + (ECNT3’ E)+ (WAITDONE F) + (LOCKED D)
B+ = (PUSHED’ B)+(PUSHED 7 A)C+ = (PUSHED’ C)+(PUSHED 8 B)D+ = (LOCKED’ D)+(PUSHED 9 C)
Key Lock Input Forming Logic
19 OhehotPage 20
ECE 238L © 2006
A+ = (PUSHED’ A) + (ECNT3’ E)+ (WAITDONE F) + (LOCKED D)
B+ = (PUSHED’ B)+(PUSHED 7 A)C+ = (PUSHED’ C)+(PUSHED 8 B)D+ = (LOCKED’ D)+(PUSHED 9 C)E+ = (PUSHED 7’ A)
+ (PUSHED 8’ B) + (PUSHED 9’ C)
Key Lock Input Forming Logic
19 OhehotPage 21
ECE 238L © 2006
A+ = (PUSHED’ A) + (ECNT3’ E)+ (WAITDONE F) + (LOCKED D)
B+ = (PUSHED’ B)+(PUSHED 7 A)C+ = (PUSHED’ C)+(PUSHED 8 B)D+ = (LOCKED’ D)+(PUSHED 9 C)E+ = (PUSHED 7’ A)
+ (PUSHED 8’ B) + (PUSHED 9’ C)
F+ = (ECNT3 E)+ (WAITDONE’ F)
Key Lock Input Forming Logic
19 OhehotPage 22
ECE 238L © 2006
ERROR = E
Key Lock Output Forming Logic
19 OhehotPage 23
ECE 238L © 2006
ERROR = EINC = (PUSHED 7’ A)
+ (PUSHED 8’ B)+ (PUSHED 9’ C)
Key Lock Output Forming Logic
19 OhehotPage 24
ECE 238L © 2006
ERROR = EINC = (PUSHED 7’ A)
+ (PUSHED 8’ B)+ (PUSHED 9’ C)
CLRTIMER = ECNT3 E
Key Lock Output Forming Logic
19 OhehotPage 25
ECE 238L © 2006
ERROR = EINC = (PUSHED 7’ A)
+ (PUSHED 8’ B)+ (PUSHED 9’ C)
CLRTIMER = ECNT3 ECLRCNTR = (WAITDONE F)
+ ((LOCKED D)
Key Lock Output Forming Logic
19 OhehotPage 26
ECE 238L © 2006
ERROR = EINC = (PUSHED 7’ A)
+ (PUSHED 8’ B)+ (PUSHED 9’ C)
CLRTIMER = ECNT3 ECLRCNTR = (WAITDONE F)
+ ((LOCKED D)UNLOCK = (PUSHED 9 C)
Key Lock Output Forming Logic
19 OhehotPage 27
ECE 238L © 2006
Other State Encoding Techniques
• You have learned the 2 extremes– Fully encoded (8 states 3 state bits)– One-hot encoded (8 states 8 state bits)
• A range of options exist in between
• A good choice of encoding– Can minimize IFL and OFL complexity– Algorithms have been developed for this…– Beyond the scope of this class