Professional Documents
Culture Documents
LECTURE B 4 FSM Encoding Intro
LECTURE B 4 FSM Encoding Intro
LECTURE B 4 FSM Encoding Intro
Sequential Circuits
State tables
net-list
Sequential Circuits
Sequential Circuits
Primitive sequential elements
Combinational logic
Models for representing sequential circuits
Finite-state machines (Moore and Mealy)
Representation of memory (states)
Changes in state (transitions)
Basic sequential circuits
Shift registers
Counters
Design procedure
State diagrams
State transition table
Next state functions
State Assignment
Choose bit vectors to assign to each “symbolic” state
With n state bits for m states there are 2n! / (2n – m)!
state assignments [log n <= m <= 2n]
2n codes possible for 1st state, 2n–1 for 2nd, 2n–2 for 3rd, …
Huge number even for small values of n and m
Intractable for state machines of any size
Heuristics are necessary for practical solutions
Optimize some metric for the combinational logic
Size (amount of logic and number of FFs)
Speed (depth of logic and fanout)
Dependencies (decomposition)
State Assignment Strategies
Possible Strategies
Sequential – just number states as they appear in the
state table
Random – pick random codes
One-hot – use as many state bits as there are states
(bit=1 –> state)
Output – use outputs to help encode states (counters)
Heuristic – rules of thumb that seem to work in most
cases
No guarantee of optimality – an intractable problem
One-hot State Assignment
Simple
Easy to encode, debug
Small Logic Functions
Each state function requires only predecessor state bits
as input
Good for Programmable Devices
Lots of flip-flops readily available
Simple functions with small support (signals its
dependent upon)
Impractical for Large Machines
Too many states require too many flip-flops
Decompose FSMs into smaller pieces that can be one-hot
encoded
Many Slight Variations to One-hot – “two hot”
Heuristics for State Assignment
Adjacent codes to states that share a common
next state
Group 1's in next state map
HG = ST’ H1’ H0’ F1 F0’ + ST H1 H0’ F1’ F0 Output patterns are unique to states, we do not
HY = ST H1’ H0’ F1 F0’ + ST’ H1’ H0 F1 F0’ need ANY state bits – implement 5 functions
FG = ST H1’ H0 F1 F0’ + ST’ H1 H0’ F1’ F0’ (one for each output) instead of 7 (outputs plus
HY = ST H1 H0’ F1’ F0’ + ST’ H1 H0’ F1’ F0 2 state bits)
Current State Assignment
Approaches
For tight encodings using close to the minimum number of
state bits
Best of 10 random seems to be adequate (averages as well as
heuristics)
Heuristic approaches are not even close to optimality
Used in custom chip design
One-hot encoding
Easy for small state machines
Generates small equations with easy to estimate complexity
Common in FPGAs and other programmable logic
Output-based encoding
Ad hoc - no tools
Most common approach taken by human designers
Yields very small circuits for most FSMs
State Assignment = Various Methods
Assign unique code to each state to produce logic-level description
utilize unassigned codes effectively as don’t cares
log S
maximum-bit encoding
one-hot encoding
something in between
Modern techniques
hypercube embedding of face constraint derived for collections of
states (Kiss,Nova)
adjacency embedding guided by weights derived between state pairs
(Mustang)
Hypercube Embedding Technique
Observation : one -hot encoding is the easiest
to decode
Am I in state 2,5,12 or 17?
binary : x4’x3’x2’x1x0’(00010) +
x4’x3’x2x1’x0 (00101) +
x4’x3x2x1’x0’(01100) +
x4x3’x2’x1’x0 (10001)
one hot : x2+x5+x12+x17
But one hot uses too many flip flops.
Exploit this observation
1. two-level minimization after one hot
encoding identifies useful state group for
decoding
2. assigning the states in each group to a single
face of the hypercube allows a single product
term to decode the group to states.
FSM Optimization
01 00
S2 -0 S3
11 01 1- 0- 10
-0 -1
S1 S4
11
PI Combinational PO
Logic
v1 u1
PS NS
v2 u2
State Group Identification
Ex: state machine
input current-state next state output
0 start S6 00
0 S2 S5 00
0 S3 S5 00
0 S4 S6 00
0 S5 start 10
0 S6 start 01
0 S7 S5 00
1 start S4 01
1 S2 S3 10
1 S3 S7 10
1 S4 S6 10
1 S5 S2 00
1 S6 S2 00
1 S7 S6 00
Symbolic Implicant : represent a transition from
one or more state to a next state under some input
condition.
Representation of Symbolic Implicant
b state groups :
a
{2,5,12,17}
{2,6,17}
12 17
6
5 2
2 17
wrong!
6
5 12
Hyper-cube Embedding
c
b state groups :
a
6 17 {2, 6, 17}
{2, 4, 5}
2
5 4
6 17
2 4
wrong!
5
Hyper-cube Embedding
Advantage :
use two-level logic minimizer to identify good state
group
almost all of the advantage of one-hot encoding,
but fewer state-bit
Adjacency-Based State Assignment
Basic algorithm:
(1) Assign weight w(s,t) to each pair of states
weight reflects desire of placing states
adjacent on the hypercube
(2) Define cost function for assignment of codes
to the states
penalize weights for the distance between the state codes
to improve solution
Adjacency-Based State Assignment
S1 S3
S2
$$$ S1 S2 $$$$
$$$ S3 S2 $$$$
S1 S3
$/j $/j
S2 S4
$$$ S1 S2 $$$1$
$$$ S3 S4 $$$1$
S1
S2 S4
$$$ S1 S2 $$$$
$$$ S1 S4 $$$$
S1 S3
i i
S2 S4
$0$ S1 S2 $$$$
$0$ S3 S4 $$$$
MISII
SIS Sequential Circuit
Partitioning
Facilities for handling latches