More Design Examples, State Assignment and Reduction
More Design Examples, State Assignment and Reduction
Page 1
Serial Parity Checker
D Q
x
FF
Clock
X/Q 0 1
Next State KM
Page 2
Serial Comparator
Page 3
A>B EAB
00 01 11 10
1xx /1
000 0 0 0 0 0xx
001 0 0 0 0
110
Output equation: 011 0 0 0 0 101
A>B = Q1Q0 (simplify to Q1) 0xx, ??/ A<
010 0 0 0 0
Next state equations: 100, 0 B/0
100 0 0 0 1 111 0xx
DQ1=(Q1+Q0AB )E
=(Q1+Q0AB )E 101 0 0 0 1
DQ0=(Q0+Q1Q0AB )E
1xx
111 0 0 0 1
=(Q0+Q1AB )E 110 1 0 0 1
Present Next
State Inputs State Output
Q1 Q1Q0 EAB Q1Q0 A>B
00 0xx 00 0
00 100 00 0
00 111 00 0
00 110 10 0
00 101 01 0
10 1xx 10 1
10 0xx 00 1
01 1xx 01 0
01 0xx 00 0
Page 4
Example using JK
PS X NS Using JK
Q1Q0 Q1Q0 00
JK=1x 11
0 0 0 0 0 X=1
JK=x0
0 0 1 0 1 X=0
0 1 X 1 0 0 1 01
10
1 0 X 1 1
JK=0x
1 1 X 0 0 JK=x1
X=0 X=1 X=0 X=1
J(Q1) Q1Q0 Q1Q0
00 (0->0):0 (0->0)0 00 X X
01 (0->1):1 (0->1)1 01 1 X
K(Q1)
10 (1->1):X (1->1)X 10 0 0
11 (1->0):X (1->0)X 11 1 1
Page 5
State Assignment
Selecting binary patterns for the symbolic states impacts circuit complexity.
Outputs and FF input equations depend on current state and are therefore
influenced by the assignment of binary values to states.
We can use more than the minimum number of flip-flops and this might result in
much simpler logic equations for the flip-flop inputs and circuit outputs.
Assume we have the following state diagram. Circuit requires 7 states (S0, … , S6)
and has 3 inputs (R, B, W). Circuit has 4 outputs (say A, B, C and D).
R S2/0100
!W
R W RB R R
S0/0000 S1/0000 S3/1000 S4/1001 S5/1010 S6/1011
R !B
R
With n-bits (i.e., n flip-flops) we can encode 2n states. This always gives the
minimum number of flip-flops required.
In our example, we have 7 states and therefore would need 3 bits for encoding.
S0 Ã 000, S1 Ã 001
S2 Ã 010, S3 Ã 011
S4 Ã 100, S5 Ã 101
S6 Ã 110
Note: No particular method for assigning any given binary pattern to any particular
symbolic state.
Sometimes, we can encode the states such that the output of the flip-flops are
ALSO the outputs of the circuit!!!
Consider listing the states of the system, along with their outputs.
When we list outputs along with states, we will see one of two cases:
CASE 1: Outputs for each state are distinct (output value becomes the state
encoding).
CASE 2: Outputs for some states are identical (add additional bits to
distinguish those states with identical outputs).
In our example, we need to add an extra bit to distinguish between S0 and S1:
Can encode states using 5 flip-flops (let don’t cares be 0 for illustration purposes):
S0 Ã 00000, S1 Ã 00001, S2 Ã 01000, S3 Ã 10000
S4 Ã 10010, S5 Ã 10100, S6 Ã 10110
However, no output equations (less logic, less output delays) since outputs come
directly from flip-flop outputs.
Potentially many unused states, and we might need to be careful about unused
states.
Only the output of 1 flip-flop is ever high at any given time. When the flip-flop
output is 1, then we know which state we are in.
Generally (although not always), one-hot encoding reduces logic required for
output equations and next state equations, but uses more flip-flops.
For our example we have 7 states, so with one hot encoding, we would need 7 flip-
flops and use the following encoding scheme:
In generating a state table/diagram from a verbal description, can get more states
than required.
The number of flip-flops, complexity of next state and output equations, etc. all
depend on the number of states, it is reasonable to ask if a state table/diagram can
be simplified to remove redundant states.
Sometimes, states are equivalent to each other and can be combine into a single
state.
For each circuit input, the states give exactly the same outputs, AND
For each circuit input, the states give the same next state or an equivalent
next state.
Call e
Page 19
Reduced states
Partitioning.
Our initial design resulted in a state table with 5 states and needs at least 3 flip-
flops. But, we can do better…
The implication chart looks like the lower triangle of a matrix – each entry is
intended to tell us under what conditions two states are equivalent.
S1
S2
S3
S4
S0 S1 S2 S3
We begin by marking entries in the implication chart with an “x” if two states
cannot be equivalent due to different output values.
S1
S2
S3
S4
S0 S1 S2 S3
Next, we mark entries that are definitely equivalent. We also mark entries that
are equivalent under implied decisions.
S1
S2
(S0,S1)
S3 (S3,S4)
(S0,S2) (S1,S2)
S4 (S1,S3)
S0 S1 S2 S3
Finally, we perform passes over the entries from top-left to bottom-right trying to
cross out those states that cannot be equivalent due to implied decisions.
S1
S2
(S0,S1)
S3 (S3,S4)
(S0,S2) (S1,S2)
S4 (S1,S3)
S0 S1 S2 S3
From the implication chart, we can built a graph (Merger Diagram) that shows
merges. Nodes are states and edges represent equivalency.
Boxes with any “x” in them represent non-equivalent states. Boxes with all “v” in
them represent equivalency and are represented by an edge.
S1
S0
S2
(S0,S1)
S2
S3 (S3,S4) S1
(S0,S2) (S1,S2)
S4 (S1,S3)
S3 S4
S0 S1 S2 S3
E.g., (S1,S4) required that (S0,S2) are implied (see implication chart). We
have this merge, so it is true, and we are okay.
Since implied decisions all check out, our reduction is good and we are done.
Reduction of state tables using implication charts and merger diagrams is covered in
Chapter 9, Section 9.5 of the course textbook.
Consider the following state table for a circuit with 1 input A and 1 output Z:
Procedure:
FIRST: Group states according to circuit outputs produced.
States are only equivalent if their outputs are the same for all input
patterns.
So, we get groups in which all the states in each group might be
equivalent.
LOOP: For each group, consider each input pattern.
If, for any input pattern, different states in a group result in a
transition to a different other groups, then those states are not
equivalent.
So, we separate the group in to two smaller groups.
Continue dividing groups into smaller partitions until all the states in any group
transition to the SAME other group for ANY input pattern.
Once we reach the point where further division of groups is not required, we have
identified the equivalent states.
Consider our example… We can see that, in fact, there are only 3 required states
(and not 5) since some states are equivalent.
This means less flip-flops and (likely) less logic to produce next state and
output equations.
(S0,S2) (S0,S2)
(S1,S4)
(S0,S1,S2,S3,S4)
(S1,S3,S4) (S3)
We can merge together equivalent states and end up with a smaller state diagram
and state table:
1
1
(S0,S2) (S0,S2)
(S0,S2)
0 0
(S1,S4)
1
0 (S1,S4)
0
1
(S0,S1,S2,S3,S4)
0
(S1,S3,S4) (S3)
0
1
(S3)
divide based on outputs divide based on next state
1