Lecture: Sequential ISM:

advertisement
Sequential System Synthesis
-- Incompletely Specified Machines
Outline
 Incompletely Specified Machine (ISM)
 State Minimization for ISM
 Brute Force Method
 Compatible, Maximal, Prime, Class Set
 Algorithm for ISM State Minimization
• Find all pairs of compatible states
• Find the maximal compatibles
• Find the prime compatibles
• Set up the covering problem
• Solve the binate covering problem
 The Binate Covering Problem
ENEE 644
2
FSM with Incomplete Specification
An FSM <I,S,,S0,O,> is incompletely specified if
 and/or  are incompletely specified functions.
(I.e., they are not defined on some combinations
of inputs and present states.) Otherwise, it is
completely specified.
 In STG, this means there exist nodes with less than |I|
outgoing edges or edges carrying don’t care as output;
 In flow table, this means there exist incompletely
defined entries;
 In cube table, this means there exist incompletely
defined rows.
ENEE 644
3
Examples: ISM
x/0
I = {x,y}
S = {A,B,C,D}
S0= {A}
(A,x) = A, (A,y) = B,
(B,x) = A, (B,y) = C,
(C,y) = D
 O = {0,1}
 (A,x) = 0, (A,y) = 1,
(B,x) = 0,
(C,y) = 1




A
D
y/1
x/0
y/-
B
ENEE 644
y/1
C
x
y
A
A,0
B,1
B
A,0
C,-
C
-,-
D,1
D
-,-
-,-
4
State Minimization for ISM
Goal: For a given incompletely specified
machine M, find a machine M’ such that:
 on any input sequence, M’ produces the
same outputs as M, whenever M is
specified.
 there does not exist a machine M’’ with
fewer states than M’ which has the
same property.
ENEE 644
5
Brute Force Method
 Idea:
 Build a CSM (completely
specified machines) for every
possible combination of the
don’t cares;
 Minimize the resulting CSMs;
 Choose the one with the
smallest number of states.
 Example:
In this example, it means state
minimization for two CSMs obtained
from M, by setting the don’t care to 0
and 1 (i.e. all possible alphabets).
ENEE 644
x
x
y
A
C,0
B,0
B
B,-
C,0
C
C,1
B,0
y
x
y
A C,0
B,0
A C,0
B,0
B B,0
C,0
B B,1
C,0
C C,1
B,0
C C,1
B,0
6
Brute Force Method
 A and C, B and C are not equivalent;
 A and B are not equivalent;
 So this CSM cannot be reduced, I.e., it is
already minimized.
 A and B, A and C are not equivalent;
 B and C are equivalent;
 So this CSM can be reduced to a machine
with only two states.
x
y
A C,0
B,0
B B,0
C,0
C C,1
B,0
x
y
A C,0
B,0
B B,1
C,0
C C,1
B,0
 Conclusion: The ISM can be reduced to a 2-state machine.
 Question: Can this always be done?
ENEE 644
7
Brute Force Method
x
Apply the brute force method to this ISM:
 A and C, B and C are not equivalent;
 A and B are not equivalent;
 So this CSM cannot be reduced.
 A and B, A and C are not equivalent;
 B and C are not equivalent;
 So this CSM cannot be reduced.
 Conclusion: The ISM cannot be reduced.
 Question: Is this correct?
ENEE 644
y
A C,0
B,0
B B,-
A,0
C A,1
B,0
x
y
A C,0
B,0
B B,0
A,0
C A,1
B,0
x
y
A C,0
B,0
B B,1
A,0
C A,1
B,0
8
Brute Force Method Fails
x
Apply the brute force method to this ISM:
x
Consider this CSM:
y
S T,0
S,0
T S,1
S,0
y
A C,0
B,0
B B,-
A,0
C A,1
B,0
 One can verify that on any input sequence, the CSM produces
the same outputs as the ISM, whenever it is specified.
 One way to see this is that the ISM is defined to be 1 iff the
machine receives ‘xx’ at the starting state A, which is also true
for the CSM.
 Notice that on certain input sequences, e.g. ‘yx’, the ISM is not
specified, but this does not prevent us from reducing the ISM to
this CSM.
ENEE 644
9
Compatible States
 Two states are compatible if they have the same
output values wherever they are both specified,
and all pairs of successors are compatible
x
y
whenever they are specified.
A C,0 B,0
 Example:
B B,-
A,0
 A and C are not compatible.
C A,1 B,0
 A and B, B and C are compatible.
For A and B to be compatible, we need B and C to be
compatible, we call {(B,C)} the class set of (A,B).
 We can merge two states if they
are compatible.
ENEE 644
x
y
S T,0
S,0
T S,1
S,0
10
Any Shortcuts: ISM State Minimization
 Can we simply modify the partition-refinement
procedure for CSM by replacing equivalent
states with compatible states?
 No. Compatibility is not transitive, therefore it is not an
equivalent relation, and thus it does not give partitions.
 Can we first find all the compatibles, and then
look for a minimum number of compatibles, such
that every original state is in at least one
compatible? (unate covering problem)
 No. One compatible may require other compatibles,
therefore choosing a given compatible may imply that
some other compatibles must be chosen too.
ENEE 644
11
Maximal and Prime Compatibles
 A set of states is compatible iff all pairs in the set
are compatible.
 A set of compatible states is maximal if it cannot
be strictly contained in any compatible sets.
 A set of compatible states is prime if it cannot be
contained in another compatible whose class set
is contained in this compatible’s class set. (C is
prime means that there does not exist C’C and ’).
 Theorem. There exists an optimal solution that
consists of prime compatibles.
ENEE 644
12
ISM State Minimization Algorithm





Find all pairs of compatible states;
Find the maximal compatibles;
Find the prime compatibles;
Set up the covering problem;
Solve the binate covering problem.
ENEE 644
13
Find All Compatible Pairs
1. For i=1,…,|S|-1
2. { for j = i+1, …, |S|
3. { if states i and j have conflict outputs or incompatible
4.
5.
6.
7.
8.
9.
successors
{ mark ‘x’ in entry (i,j); /* i and j are incompatible*/
update the compatibility table; }
else if some successor pairs are different but not yet
known as incompatibles
enter such pairs in entry (i,j); /*questionable pairs*/
else /*no conflicts on outputs and successors*/
mark ‘~’ in entry (i,j); }}
ENEE 644
14
Example: Find All Compatible Pairs
A
B
C
D
E
F
G
H
B
C
D
1
A,0
B,0
B,0
-,B,B,0
-,A,1
2
3
4
5
6
7
-,- D,0 E,1 B,0 A,- -,D,1 A,- -,- A,- A,1 -,D,1 A,1 -,-,-,- G,0
E,- -,- B,- B,0 -,- A,E,- A,- -,- B,- E,- A,1
C,- -,1 H,1 F,1 G,0 -,C,1 -,- E,1 -,- G,0 F,0
E,0 D,1 B,0 B,- E,- A,1
E
F
G
H
A
B
C
D
ENEE 644
E
F
G
15
Example: Find All Compatible Pairs
A
B
C
D
E
F
G
H
1
A,0
B,0
B,0
-,B,B,0
-,A,1
2
3
4
5
6
7
-,- D,0 E,1 B,0 A,- -,D,1 A,- -,- A,- A,1 -,D,1 A,1 -,-,-,- G,0
E,- -,- B,- B,0 -,- A,E,- A,- -,- B,- E,- A,1
C,- -,1 H,1 F,1 G,0 -,C,1 -,- E,1 -,- G,0 F,0
E,0 D,1 B,0 B,- E,- A,1
B
(A,D)
C
X
~
D
(B,E)
(A,B)(D,E)
(A,G)(D,E)
E
(A,B)
(A,D)
(A,B)(A,E)
(D,E)
X
~
F
X
X
(C,D)
X
X
G
~
X
(C,D)(F,G)
X
X
(E,H)
H
X
X
X
~
(A,B)(A,D)
X
X
A
B
C
D
E
F
G
ENEE 644
16
Find the Maximal Compatibles
A set of states is compatible iff all pairs in the set
are compatible; it is maximal if it cannot be
strictly contained in any compatible sets.
1. Define Boolean formula F = 1;
2. For each incompatible pair (i,j)
3. F = F (xi’+xj’); /* i and j cannot be in the same set*/
4. Rewrite F to SOP form; /*a complete sum*/
5. Every term of the this SOP is a maximal
compatible set (consists of states that do not
appear in the term);
ENEE 644
17
Example: Find the Maximal Compatibles
x
y
A C,0
B,0
B B,-
C,0
C A,1
B,0
A’+C’  (B,C), (A,B)
B (B,C)
C X (A,B)
A
B
(a’+c’)(a’+f’)(a’+h’)(b’+f’)(b’+g’)(b’+h’)(c’+e’)
(c’+h’)(d’+f’)(d’+g’)(e’+f’)(e’+g’)(f’+h’)(g’+h’)
~
= c’f’g’h’+a’e’f’g’h’+b’c’d’e’f’h’
(A,B)(D,E) (A,G)(D,E)
+a’b’c’f’g’+a’b’d’e’h’
(A,B)(A,E)
 (A,B,D,E),(B,C,D),(A,G),
(D,E)
X
~
(D,E,H),(C,F,G)
X
(C,D)
X
X
B
(A,D)
C
X
D
(B,E)
E
(A,B)
(A,D)
F
X
G
~
X
(C,D)(F,G)
X
X
(E,H)
H
X
X
X
~
(A,B)(A,D)
X
X
A
B
C
D
E
F
G
ENEE 644
18
Find the Prime Compatibles
 Maximal compatibles are prime. (C is prime means
that there does not exist C’C and ’).
 If a prime compatible has empty class set, all its
subsets cannot be prime.
 If a prime compatible has non-empty class set,
we should check its subsets (by definition).
 Process according to the size of the prime.
 Stop when all the single state sets have been
checked.
ENEE 644
19
Find the Prime Compatibles
B
(A,D)
C
X
~
D
(B,E)
(A,B)(D,E)
(A,G)(D,E)
E
(A,B)
(A,D)
(A,B)(A,E)
(D,E)
X
~
F
X
X
(C,D)
X
G
~
X
(C,D)(F,G)
X
H
X
X
X
~
A
B
C
D
1.
2.
3.
4.
5.
6.
7.
Maximal Compatibles and their class sets:
(A,B,D,E): empty
(B,C,D): {(A,B),(D,E),(A,G)}
(A,G):
empty
X
(D,E,H): {(A,B),(A,D)}
X
(E,H)
(A,B)(A,D)
X
X (C,F,G):
{(C,D),(E,H)}
E
F
G
Maximal compatible: (A,B,D,E)
Maximal compatible: (B,C,D), (D,E,H), (C,F,G)
Subsets of (B,C,D): (B,C), (C,D)
Subsets of (D,E,H): (D,H)
Subsets of (C,F,G): (C,F),(C,G),(F,G)
Maximal compatible: (A,G)
Subsets of compatibles with 2 states: (F)
(A,B,D,E),(A,G),(B,C), (D,H) all have empty class sets.
ENEE 644
20
ISM State Minimization Algorithm





Find all pairs of compatible states;
Find the maximal compatibles;
Find the prime compatibles;
Set up the covering problem;
Solve the binate covering problem.
ENEE 644
21
The Covering Problem
 Now we have found all the prime compatibles,
our goal is to collect some prime compatibles
such that
 Every state is contained in at least one compatible
(covering constraint);
Is this always possible?
 All the class sets of the selected compatibles are
contained in some compatibles (closure constraint).
A set of compatibles satisfying these two
constraints is called a cover, we want to find a
cover with the minimal number of compatibles.
ENEE 644
22
Covering Problem as SAT
 The Boolean satisfiability (SAT) problem seeks to
determine whether there exists a 0/1 assignment
to the Boolean variables such that a given
Boolean formula is true.
 Example:
• (x+y)(y’+z)z’ is satisfiable (x=1,y=0,z=0)
• x’(x+y’)(y+z’)(x+z) is unsatisfiable.
 Covering problem as SAT
 Prime compatible  a Boolean variable x
• x=1  the compatible is selected in the cover
• x=0  the compatible is not selected in the cover
 Covering/closure constraints  clauses
ENEE 644
23
Covering Constraints
 Covering constraint: every state has to be
covered.
 If a state S is contained in the following prime
compatibles: x1,x2,…,xk, then at least one of these has
to be selected. (Otherwise, S will be left uncovered.)
 If xi is selected in the cover, we have xi=1.
 Therefore, all we need to do is to satisfy the clause
x1+x2+…+xk.
 For each state, construct a clause as above.
ENEE 644
24
Closure Constraints
 Closure constraint: if one compatible is select (x=1), then
all its class set must be covered.
 For a compatible pair (S1,S2), if state S1 is contained in the following
prime compatibles: x11,x12,…,x1m, and state S2 in x21,x22,…,x2n, let
{x1,x2,…,xk}={x11,x12,…,x1m}{x21,x22,…,x2n}, then the pair (S1,S2) can be
covered by any of the followings x1,x2,…,xk.
 If x is selected in the cover (x=1), for each pair (S1,S2) in x’s class set,
one of the follows must be selected: x1,x2,…,xk. I.e., x1+x2+…+xk must be
true.
 If x is not selected, we don’t care its class set
 Therefore, all we need to do is to satisfy the clause
x’+x1+x2+…+xk for each of the pairs in x’s class set. (why?)
 For each compatible, construct a clause as above for
each compatible pair in its class set.
ENEE 644
25
Example: Setting Up the Covering Problem
Prime Compatibles and their class sets:
x1: (A,B,D,E): empty
x2: (B,C,D):
{(A,B),(A,G),(D,E)}
x3: (D,E,H):
{(A,B),(A,D)}
x4: (C,F,G):
{(C,D),(E,H)}
x5: (B,C):
empty
x6: (C,D):
{(A,G),(D,E)}
x7: (D,H):
x8: (C,F):
x9: (C,G):
x10:(A,G):
x11: (F,G):
x12: (F):
Covering constraints:
A: x1 + x10
B: x1 + x2 + x5
C:x2 + x4 + x5 + x6 + x8 + x9
D:x1 + x2 + x3 + x6 + x7
E: x1 + x3
F: x4 + x8 + x11 + x12
G: x4 + x9 + x10 + x11
H: x3 + x7
ENEE 644
empty
{(C,D)}
{(C,D),(F,G)}
empty
{(E,H)}
empty
26
Example: Setting Up the Covering Problem
Prime Compatibles and their class sets:
x1: (A,B,D,E): empty
x2: (B,C,D):
{(A,B),(A,G),(D,E)}
x3: (D,E,H):
{(A,B),(A,D)}
x4: (C,F,G):
{(C,D),(E,H)}
x5: (B,C):
empty
x6: (C,D):
{(A,G),(D,E)}
x7: (D,H):
x8: (C,F):
x9: (C,G):
x10:(A,G):
x11: (F,G):
x12: (F):
empty
{(C,D)}
{(C,D),(F,G)}
empty
{(E,H)}
empty
Closure constraints:
x2: (x2’ + x1)(x2’ + x10)(x2’ + x1 + x3)
x3: (x3’ + x1)(x3’ + x1)
x8: (x8’ + x2 + x6)
x4: (x4’ + x2 + x6)(x4’ + x3)
x9: (x9’ + x2 + x6)(x9’ + x4)
x6: (x6’ + x10)(x6’ + x1 + x3)
x11: (x11’ + x3)
ENEE 644
27
Example: Setting Up the Covering Problem
Covering constraints:
A: x1 + x10
B: x1 + x2 + x5
C:x2 + x4 + x5 + x6 + x8 + x9
D:x1 + x2 + x3 + x6 + x7
E: x1 + x3
F: x4 + x8 + x11 + x12
G: x4 + x9 + x10 + x11
H: x3 + x7
Closure constraints:
x2: (x2’ + x1)(x2’ + x10)(x2’ + x1 + x3)
x3: (x3’ + x1)(x3’ + x1)
x8: (x8’ + x2 + x6)
x4: (x4’ + x2 + x6)(x4’ + x3)
x9: (x9’ + x2 + x6)(x9’ + x4)
x6: (x6’ + x10)(x6’ + x1 + x3)
x11: (x11’ + x3)
SAT instance:
(x1+x10)(x1+x2+x5)(x2+x4+x5+x6+x8+x9)(x1+x2+x3+x6+x7)(x1+x3)(x4+x8+x11+
x12)(x4+x9+x10+x11)(x3+x7)
(x2’+x1)(x2’+x10)(x2’+x1+x3) (x3’+x1) (x4’+x2+x6)(x4’+x3) (x6’+x10)(x6’+x1+x3)
(x8’+x2+x6) (x9’+x2+x6)(x9’+x4) (x11’+x3)
ENEE 644
28
Example: Setting Up the Covering Problem
SAT instance:
(x1+x10)(x1+x2+x5)(x2+x4+x5+x6+x8+x9)(x1+x2+x3+x6+x7)(x1+x3)(x4+x8+x11+
x12)(x4+x9+x10+x11)(x3+x7)
(x2’+x1)(x2’+x10)(x2’+x1+x3) (x3’+x1) (x4’+x2+x6)(x4’+x3) (x6’+x10)(x6’+x1+x3)
(x8’+x2+x6) (x9’+x2+x6)(x9’+x4) (x11’+x3)
Solution: x1=x3=x5= x11= 1, all others set to 0.
Prime Compatibles and their class sets:
x1: (A,B,D,E): empty
x7: (D,H):
x2: (B,C,D):
{(A,B),(A,G),(D,E)}
x8: (C,F):
x3: (D,E,H):
{(A,B),(A,D)}
x9: (C,G):
x4: (C,F,G):
{(C,D),(E,H)}
x10:(A,G):
x5: (B,C):
empty
x11: (F,G):
x6: (C,D):
{(A,G),(D,E)}
x12: (F):
Selection: {(A,B,D,E), (D,E,H), (B,C), (F,G)}
ENEE 644
empty
{(C,D)}
{(C,D),(F,G)}
empty
{(E,H)}
empty
29
Representing the Reduced ISM
In the reduced ISM:
 There is a state for
each compatible;
 Next state will be a
compatible that
contains all the
original next states
(if there are more
than one, randomly
pick one);
 Output remains the
same.
A
B
C
D
E
F
G
H
1
A,0
B,0
B,0
-,B,B,0
-,A,1
(A,B,D,E) W
(D,E,H)
X
(B,C)
Y
(F,G)
Z
ENEE 644
2
3
4
5
6
7
-,- D,0 E,1 B,0 A,- -,D,1 A,- -,- A,- A,1 -,D,1 A,1 -,-,-,- G,0
E,- -,- B,- B,0 -,- A,E,- A,- -,- B,- E,- A,1
C,- -,1 H,1 F,1 G,0 -,C,1 -,- E,1 -,- G,0 F,0
E,0 D,1 B,0 B,- E,- A,1
1
2
W,0
?,1
Y,0
W,1
3
4
5
6
7
W,1
-,-
W,-
W,1
Z,0
30
Recall:
Unate and Binate
 A function f(x1,•••xi•••xn) is positive unate in xi if its
cofactor
f xi includes f xi '
Negative unate is defined in a similar way. If a function is
neither positive unate nor negative unate in a variable, it
is called binate in this variable.
A function is positive/negative unate if it is so for all
variables, otherwise it is called binate.
 Example: f(x,y,z) = xy + xz’ + yz’




f is positive unate in x: fx=y+z’+yz’, fx’=yz’
f is positive unate in y: fy=x+xz’+z’, fy’=xz’
f is negative unate in z: fz=xy, fz’=xy+x+y
f is a binate function
ENEE 644
31
Binate Covering Problem in Matrix Form
F = (x1+x3)(x2+x4+x6)(x3’+x4+x5)(x6’)(x1’+x6’)(x3+x4’+x5)
x1
x2
x3
x4
x5
x6
1


0

-
-
1
-
-
1
-
1
-
-
0
1
1
-
-
-
-
-
-
-
-
-
1
0
1
-
1

-

0
0

-
For each clause (row fi) and
each variable (column Fj):
fij = 1: normal form
fij = 0: complement form
fij = -: does not appear
The Binate Cover Problem: Find a minimum cost subset S
of columns, such that for each row fi:
 Either j s.t. fij = 1 and Fj S;
 Or j s.t. fij = 0 and Fj S
ENEE 644
32
Recall:
Unate Covering Problem (UCP)
 Let Mmxn be a Boolean matrix, the UCP is to find
a minimum number of columns to cover M in the
sense that any row with a 1-entry has at least
one of its 1-entries covered by these columns.
wxy
wx’y’z’
w’x’y’z
w’x’y’z’
wxyz
wxyz’
wx’yz’
w’x’yz’
wxy’z
wx’y’z
1
1
wxz wyz’ wy’z
x’y’
1
1
1
x’z’
1
1
1
1
1
1
1
1
1
1
ENEE 644
Solutions to UCP:
{x’y’, x’z’,wxy, wxz},
{x’y’, x’z’,wxy, wy’z},
{x’y’, x’z’,wxz, wyz’}.
1
33
Recall:
Reduction Techniques
1. Check for essential columns, remove them (they must
be in the selection) and all the rows that have a 1 in
such columns;
2. Check for row dominance and remove all dominating
rows;
3. Check for column dominance and remove all dominated
columns;
4. Repeat 1, 2, 3 if there is any removal occurs.
What is left?


If no rows/columns left, we find an optimal solution;
Otherwise, this UCP instance is called cyclic.
ENEE 644
34
Essential Row in BCP
F = (x1+x3)(x2+x4+x6)(x3’+x4+x5)(x6’)(x1’+x6’)(x3+x4’+x5)
 For F to be true, the term x6’ must be true, or
equivalently, x6=0.
 In the matrix form, this is a row of -----0, to cover
this row, from definition, we cannot select the
column corresponding to x6.
 An essential row of F is a row where only one
entry fij is not -. It corresponds to a single literal
clause in the SAT instance.
ENEE 644
35
Essential Row in BCP
 Action on essential row:
 If fij=1, select Fj; remove all rows fk if fkj=1;
 If fij=0, unselect Fj; remove all rows fk if fkj=0;
 Remove column Fj;
 F = (x1+x3)(x2+x4+x6)(x3’+x4+x5)(x6’)(x1’+x6’)(x3+x4’+x5)
 x6=0;
 x2+x4+x6: x2+x4
 x1’+x6’: deleted
x1
x2
x3
x4
x5
x6
1


0

-
-
1
-
-
1
-
1
-
-
0
1
1
-
-
-
-
-
-
-
-
-
1
0
1
-
1

-

0
0

-
ENEE 644
36
Row Dominance in BCP
F = (x1’+x2+x3’) (x2+x3’)(x1+x4)(x1+x2’+x3+x4’)
 For F to be true, all clauses must be true.
Whenever x2+x3’ is true, x1’+x2+x3’ is also true. We say
the latter dominates the former.
 A row fi dominates another
row fj if fi is satisfied whenever
fj is satisfied, I.e. fjfi.
 In matrix form, this means that
fik=fjk for all k that fjk-.
 Remove dominating rows.
ENEE 644
x1
x2
x3
x4
0


1

1
0 

1 0 

  1

0 1 0
1
37
Column Dominance in BCP
 Column Fj dominates column Fk if for each row fi,
one of the following occurs:
x3
x4
0 1 0
 1 0

 If Fk is selected, we can always  1  
replace it by Fj. This does not

increase the number of columns.  1 0 1
 Action: remove dominated columns; remove
rows that have 0 at dominated columns.




1

0
 fij=1;
 fij= - and fik 1;
 fij= fik= 0.
ENEE 644
x1
x2
38
Example:
x1
 Last row is essential
 x6=1;
 Remove row 4 and 6;
 Column 1 can be dominated by
column 2
 Remove column 1, x1=0;
 Column 4 is dominated by 5
 Remove column 4, x4=0;
 Remove rows 1 and 2;
 Column 5 dominates 2 and 3
 Remove columns 2 and 3, x2=x3=0;
 Select column 5, x5=1.
ENEE 644



-
x2
x3
x4
x5
x6
-
0
0
-
-
-
0
0
-
1
1
1
1
-
1
-
1
-
-
1
-
-
-
-
-
-

-

1
-

1
x5
x2
x3
x4





1
0
0

0
1
1



0

1

1
39
Download