390 likes | 526 Views
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
E N D
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
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
x y x/0 A A,0 B,1 A D B A,0 C,- y/1 y/1 C -,- D,1 x/0 y/- B C D -,- -,- Examples: ISM • 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 ENEE 644
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
C,0 C,0 C,0 x x x y y y A A A B,0 B,0 B,0 B B B B,1 B,0 B,- C,0 C,0 C,0 C C C C,1 C,1 C,1 B,0 B,0 B,0 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
C,0 C,0 x x y y A A B,0 B,0 B B B,1 B,0 C,0 C,0 C C C,1 C,1 B,0 B,0 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. • Conclusion: The ISM can be reduced to a 2-state machine. • Question: Can this always be done? ENEE 644
C,0 C,0 C,0 x x x y y y A A A B,0 B,0 B,0 B B B B,0 B,- B,1 A,0 A,0 A,0 C C C A,1 A,1 A,1 B,0 B,0 B,0 Brute Force Method 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
C,0 T,0 x x y y S A S,0 B,0 T B B,- S,1 A,0 S,0 C A,1 B,0 Brute Force Method Fails Apply the brute force method to this ISM: Consider this CSM: • 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
C,0 T,0 x x y y S A S,0 B,0 B T B,- S,1 A,0 S,0 C A,1 B,0 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 whenever they are specified. • Example: • A and C are not compatible. • 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
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
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
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
Find All Compatible Pairs • For i=1,…,|S|-1 • { for j = i+1, …, |S| • { if states i and j have conflict outputs or incompatible 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
1 2 3 4 5 6 7 A A,0 -,- D,0 E,1 B,0 A,- -,- B B,0 D,1 A,- -,- A,- A,1 -,- C B,0 D,1 A,1 -,- -,- -,- G,0 D -,- E,- -,- B,- B,0 -,- A,- E B,- E,- A,- -,- B,- E,- A,1 F B,0 C,- -,1 H,1 F,1 G,0 -,- G -,- C,1 -,- E,1 -,- G,0 F,0 H A,1 E,0 D,1 B,0 B,- E,- A,1 Example: Find All Compatible Pairs B C D E F G H A B C D E F G ENEE 644
1 2 3 4 5 6 7 A A,0 -,- D,0 E,1 B,0 A,- -,- B B,0 D,1 A,- -,- A,- A,1 -,- C B,0 D,1 A,1 -,- -,- -,- G,0 D -,- E,- -,- B,- B,0 -,- A,- E B,- E,- A,- -,- B,- E,- A,1 B (A,D) F B,0 C,- -,1 H,1 F,1 G,0 -,- G -,- C,1 -,- E,1 -,- G,0 F,0 C X ~ H A,1 E,0 D,1 B,0 B,- E,- A,1 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 Example: Find All Compatible Pairs ENEE 644
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. • Define Boolean formula F = 1; • For each incompatible pair (i,j) • F = F (xi’+xj’); /* i and j cannot be in the same set*/ • Rewrite F to SOP form; /*a complete sum*/ • Every term of the this SOP is a maximal compatible set (consists of states that do not appear in the term); ENEE 644
C,0 B (A,D) C X ~ D (B,E) (A,B)(D,E) (A,G)(D,E) x y E (A,B) (A,D) (A,B)(A,E) (D,E) X ~ A B,0 F X X (C,D) X X B B,- C,0 G ~ X (C,D)(F,G) X X (E,H) C A,1 B,0 H X X X ~ (A,B)(A,D) X X A B C D E F G Example: Find the Maximal Compatibles 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’c’f’g’+a’b’d’e’h’ (A,B,D,E),(B,C,D),(A,G), (D,E,H),(C,F,G) ENEE 644
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
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 Find the Prime Compatibles Maximal Compatibles and their class sets: (A,B,D,E): empty (B,C,D): {(A,B),(D,E),(A,G)} (A,G): empty (D,E,H): {(A,B),(A,D)} (C,F,G): {(C,D),(E,H)} 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
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
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
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
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
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+…+xkfor 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
Example: Setting Up the Covering Problem Prime Compatibles and their class sets: x1: (A,B,D,E): empty x7: (D,H): empty x2: (B,C,D): {(A,B),(A,G),(D,E)} x8: (C,F): {(C,D)} x3: (D,E,H): {(A,B),(A,D)} x9: (C,G): {(C,D),(F,G)} x4: (C,F,G): {(C,D),(E,H)} x10:(A,G): empty x5: (B,C): empty x11: (F,G): {(E,H)} x6: (C,D): {(A,G),(D,E)} x12: (F): empty Covering constraints: A: x1 + x10E: x1 + x3 B: x1 + x2 + x5 F: x4 + x8 + x11 + x12 C: x2 + x4 + x5 + x6 + x8 + x9 G: x4 + x9 + x10 + x11 D: x1 + x2 + x3 + x6 + x7 H: x3 + x7 ENEE 644
Example: Setting Up the Covering Problem Prime Compatibles and their class sets: x1: (A,B,D,E): empty x7: (D,H): empty x2: (B,C,D): {(A,B),(A,G),(D,E)} x8: (C,F): {(C,D)} x3: (D,E,H): {(A,B),(A,D)} x9: (C,G): {(C,D),(F,G)} x4: (C,F,G): {(C,D),(E,H)} x10:(A,G): empty x5: (B,C): empty x11: (F,G): {(E,H)} x6: (C,D): {(A,G),(D,E)} x12: (F): 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
Example: Setting Up the Covering Problem Covering constraints: A: x1 + x10E: x1 + x3 B: x1 + x2 + x5 F: x4 + x8 + x11 + x12 C: x2 + x4 + x5 + x6 + x8 + x9 G: x4 + x9 + x10 + x11 D: x1 + x2 + x3 + x6 + x7 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
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) 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): empty x2: (B,C,D): {(A,B),(A,G),(D,E)} x8: (C,F): {(C,D)} x3: (D,E,H): {(A,B),(A,D)} x9: (C,G): {(C,D),(F,G)} x4: (C,F,G): {(C,D),(E,H)} x10:(A,G): empty x5: (B,C): empty x11: (F,G): {(E,H)} x6: (C,D): {(A,G),(D,E)} x12: (F): empty Selection:{(A,B,D,E), (D,E,H), (B,C), (F,G)} ENEE 644
1 2 3 4 5 6 7 A A,0 -,- D,0 E,1 B,0 A,- -,- B B,0 D,1 A,- -,- A,- A,1 -,- C B,0 D,1 A,1 -,- -,- -,- G,0 D -,- E,- -,- B,- B,0 -,- A,- E B,- E,- A,- -,- B,- E,- A,1 F B,0 C,- -,1 H,1 F,1 G,0 -,- G -,- C,1 -,- E,1 -,- G,0 F,0 H A,1 E,0 D,1 B,0 B,- E,- A,1 1 2 3 4 5 6 7 (A,B,D,E) W W,0 ?,1 (D,E,H) X (B,C) Y Y,0 W,1 W,1 -,- W,- W,1 Z,0 (F,G) Z 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. ENEE 644
Recall: Unate and Binate • A function f(x1,•••xi•••xn) is positive unate in xiif its cofactor 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
Binate Covering Problem in Matrix Form F = (x1+x3)(x2+x4+x6)(x3’+x4+x5)(x6’)(x1’+x6’)(x3+x4’+x5) 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
Recall: wxy wxz wyz’ wy’z x’y’ x’z’ wx’y’z’ 1 1 w’x’y’z 1 w’x’y’z’ 1 1 wxyz 1 1 wxyz’ 1 1 wx’yz’ 1 1 w’x’yz’ 1 wxy’z 1 1 wx’y’z 1 1 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. Solutions to UCP: {x’y’, x’z’,wxy, wxz}, {x’y’, x’z’,wxy, wy’z}, {x’y’, x’z’,wxz, wyz’}. ENEE 644
Recall: Reduction Techniques • Check for essential columns, remove them (they must be in the selection) and all the rows that have a 1 in such columns; • Check for row dominance and remove all dominating rows; • Check for column dominance and remove all dominated columns; • 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
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
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 ENEE 644
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. Wheneverx2+x3’ is true, x1’+x2+x3’ is also true. We say the latter dominates the former. • A row fidominates another row fj if fi is satisfied whenever fj is satisfied, I.e. fjfi. • In matrix form,this means that fik=fjk for all k that fjk-. • Remove dominating rows. ENEE 644
Column Dominance in BCP • Column Fjdominates column Fk if for each row fi, one of the following occurs: • fij=1; • fij= - and fik 1; • fij= fik= 0. • If Fk is selected, we can alwaysreplace it by Fj. This does not increase the number of columns. • Action: remove dominated columns; remove rows that have 0 at dominated columns. ENEE 644
Example: • 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