Logi Synthesis nd Verifition SOPs nd Inompletely Speified Funtions Jie-Hong Rolnd Jing 江介宏 Deprtment of Eletril Engineering Ntionl Tiwn University Fll 22 Reding: Logi Synthesis in Nutshell Setion 2 most of the following slides re y ourtesy of Andres Kuehlmnn 2 Boolen Funtion Representtion Sum of Produts A funtion n e represented y sum of ues (produts): E.g., f = + + Sine eh ue is produt of literls, this is sum of produts (SOP) representtion An SOP n e thought of s set of ues F E.g., F = {,, A set of ues tht represents f is lled over of f E.g., F ={,, nd F 2 ={,,, re overs of f = + +. List of Cues (Cover Mtrix) We often use mtrix nottion to represent over: Exmple F = + d = d d 2 2 or - - d 2 2 - - Eh row represents ue mens tht the positive literl ppers in the ue mens tht the negtive literl ppers in the ue 2 (or -) mens tht the vrile does not pper in the ue. It impliitly represents oth nd vlues. 3 4
PLA A PLA is (multiple-output) funtion f : B n B m represented in SOP form n=3, m=3 over mtrix PLA Eh distint ue ppers just one in the ANDplne, nd n e shred y (multiple) outputs in the OR-plne, e.g., ue () f f 2 f 3 - - - - - - - - - - - - - Extensions from single-output to multiple-output minimiztion theory re strightforwrd f f 2 f 3 5 6 SOP Irredundnt Cue The over (set of SOPs) n effiiently represent mny prtil logi funtions (i.e., for mny prtil funtions, there exist smll overs) Two-level minimiztion seeks the over of minimum size (lest numer of ues) = onset minterm Note tht eh onset minterm is overed y t lest one of the ues! None of the offset minterms is overed 7 Let F = {, 2,, k e over for f, i.e., f = i k = i A ue i F is irredundnt if F\{ i f Exmple f = + + F\{ f Not overed 8
Prime Cue A literl x ( vrile or its negtion) of ue F (over of f) is prime if (F \ {) { x f, where x (oftor w.r.t. x) is with literl x of deleted A ue of F is prime if ll its literls re prime Exmple f = xy + xz + yz = xy; y = x (literl y deleted) F \ { { y = x + xz + yz z yz xz x Prime nd Irredundnt Cover Definition. A over is prime (resp. irredundnt) if ll its ues re prime (resp. irredundnt) Definition 2. A prime (ue) of f is essentil (essentil prime) if there is onset minterm (essentil vertex) in tht prime ut not in ny other prime Definition 3. Two ues re orthogonl if they do not hve ny minterm in ommon E.g. = xy 2 = y z re orthogonl = x y 2 = yz re not orthogonl inequivlent to f sine offset vertex is overed x y 9 Prime nd Irredundnt Cover Inompletely Speified Funtion Exmple f = + d + d is prime nd irredundnt. is essentil sine d, ut not in d or d or d Why is d not n essentil vertex of? Wht is n essentil vertex of? Wht other ue is essentil? Wht prime is not essentil? d d d Let F = (f, d, r) : B n {,, *, where * represents don t re f = onset funtion f(x)= F(x)= r = offset funtion r(x)= F(x)= d = don t re funtion d(x)= F(x)=* (f,d,r) forms prtition of B n, i.e, f + d + r = B n (f d) = (f r) = (d r) = (pirwise disjoint) (Here we don t distinguish hrteristi funtions nd the sets they represent) 2
Inompletely Speified Funtion A ompletely speified funtion g is over for F = (f,d,r) if f g f+d gr = if xd (i.e. d(x)=), then g(x) n e or ; if xf, then g(x) = ; if xr, then g(x) = We don t re whih vlue g hs t xd Prime of Inompletely Speified Funtion Definition. A ue is prime of F = (f,d,r) if f+d (n implint of f+d), nd no other implint (of f+d) ontins (i.e., it is simply prime of f+d) Definition. Cue j of over G = { i of F = (f,d,r) is redundnt if f G\{ j ; otherwise it is irredundnt Note tht f+d r = 3 4 Prime of Inompletely Speified Funtion Exmple Consider logi minimiztion of F(,,)=(f,d,r) with f= + + nd d = + on off don t re F ={,, Expnd F 2 ={,, is redundnt is prime F 3 = {, Expnd Cheking of Prime nd Irredundny Let G e over of F = (f,d,r), nd D e over for d i G is redundnt iff i (G\{ i ) D () (Let G i G\{ i D. Sine i G i nd f G f+d, then i i f+ i dnd i f G\{ i. Thus f G\{ i.) A literl l i is prime if ( i \{ l ) ( = ( i ) l ) is not n implint of F A ue i is prime of F iff ll literls l i re prime Literl l i is not prime ( i ) l f+d (2) Note: Both tests () nd (2) n e heked y tutology (to e explined): (G i ) i (implies i redundnt) (fd) (i)l (implies l not prime) The ove two oftors re with respet to ues insted of literls F 4 = {, 5 6
(Literl) Coftor (Literl) Coftor Let f : B n B e Boolen funtion, nd x= (x, x 2,, x n ) the vriles in the support of f; the oftor f of f y literl = x i or = x i is f xi (x, x 2,, x n ) = f (x,, x i-,, x i+,, x n ) f xi (x, x 2,, x n ) = f (x,, x i-,, x i+,, x n ) The omputtion of the oftor is fundmentl opertion in Boolen resoning! Exmple f = + f = 7 The oftor Cx j of ue C (representing some Boolen funtion) with respet to literl x j is C if x j nd x j do not pper in C C\{x j if x j ppers positively in C, i.e., x j C if x j ppers negtively in C, i.e., x j C Exmple C = x x 4 x 6, Cx 2 = C (x 2 nd x 2 do not pper in C) Cx = x 4 x 6 (x ppers positively in C) Cx 4 = (x 4 ppers negtively in C) 8 (Literl) Coftor Exmple F = + d + d F = + d (Just drop everywhere nd throw wy ues ontining literl ) Coftor nd disjuntion ommute! Shnnon Expnsion Let f : B n B Shnnon Expnsion: f = x i f xi + x i f xi Theorem: F is over of f. Then F = x i F xi + x i F xi We sy tht f nd F re expnded out x i, nd x i is lled the splitting vrile 9 2
Shnnon Expnsion Exmple F = + + F = F + F = (++)+ () = +++ Cue got split into two ues (Cue) Coftor The oftor f C of f y ue C is f with the fixed vlues indited y the literls of C E.g., if C = x i x j, then x i = nd x j = For C = x x 4 x 6, f C is just the funtion f restrited to the suspe where x = x 6 = nd x 4 = Note tht f C does not depend on x,x 4 or x 6 nymore (However, we still onsider f C s funtion of ll n vriles, it just hppens to e independent of x,x 4 nd x 6 ) x f f x E.g., for f = +, f = f = nd f = 2 22 (Cue) Coftor The oftor of the over F of some funtion f is the sum of the oftors of eh of the ues of F If F={, 2,, k is over of f, then F = {( ), ( 2 ),, ( k ) is over of f Continment vs. Tutology A fundmentl theorem tht onnets funtionl ontinment nd tutology: Theorem. Let e ue nd f funtion. Then f f. Proof. We use the ft tht xf x = xf, nd f x is independent of x. () Suppose f. Then f = f =. Thus, f. () Suppose f. Then f+=f. In ddition, f = (f+) = f +=. Thus, f =. f 23 24
Cheking of Prime nd Irredundny (Revisited) Let G e over of F = (f,d,r). Let D e over for d i G is redundnt iff i (G\{ i ) D () (Let G i G\{ i D. Sine i G i nd f G f+d, then i i f+ i dnd i f G\{ i. Thus f G\{ i.) A literl l i is prime if ( i \{ l ) ( = ( i ) l ) is not n implint of F A ue i is prime of F iff ll literls l i re prime Literl l i is not prime ( i ) l f+d (2) Note: Both tests () nd (2) n e heked y tutology (explined): (G i ) i (implies i redundnt) (fd) (i)l (implies l not prime) The ove two oftors re with respet to ues insted of literls Generlized Coftor Definition. Let f, g e ompletely speified funtions. The generlized oftor of f with respet to g is the inompletely speified funtion: o( f,g) ( f g,g, f g) Definition. Let = (f, d, r) nd g e given. Then o(,g) ( f g,d g,r g) 25 26 Shnnon vs. Generlized Coftor Shnnon vs. Generlized Coftor Let g = x i. Shnnon oftor is f xi (x, x 2,, x n ) = f (x,, x i-,, x i+,, x n ) Generlized oftor with respet to g=x i is Note tht o( f, x i ) ( f x i, x i, f x i ) f on off Don t t re f x i f xi f x i x i f x i In ft f xi is the unique over of o(f, x i ) independent of the vrile x i. o( f,) ( f,, f ) f 27 28
Shnnon vs. Generlized Coftor Shnnon vs. Generlized Coftor o( f,) ( f,, f ) Shnnon Coftor Generlized Coftor f So f f f f f f x f x x f x f f x y f xy f g y f y g y f x f x f g o( f,g) g o( f,g) o(o( f, g),h) o( f,gh) o( f g,h) o( f,h) o(g,h) o( f,g) o( f,g) We will get k to the use of generlized oftor lter 29 3 Dt Struture for SOP Mnipultion most of the following slides re y ourtesy of Andres Kuehlmnn Opertion on Cue Lists AND opertion: tke two lists of ues ompute pir-wise AND etween individul ues nd put result on new list represent ues in omputer words implement set opertions s it-vetor opertions Algorithm AND(List_of_Cues C,List_of_Cues C2) { C = foreh C { foreh 2 C2 { = 2 C = C return C 3 32
Opertion on Cue Lists OR opertion: tke two lists of ues omputes union of oth lists Nive implementtion: Algorithm OR(List_of_Cues C, List_of_Cues C2) { return C C2 On-the-fly optimiztions: remove ues tht re ompletely overed y other ues omplexity is O(m 2 ); m is length of list onjoin djent ues (onsensus opertion) remove redundnt ues? onp-omplete too expensive for non-orthogonl lists of ues Opertion on Cue Lists Simple trik: keep ues in lists orthogonl hek for redundny eomes O(m 2 ) ut lists eome signifintly lrger (worst se: exponentil) Exmple - - -- - OR = - - - - 33 34 Opertion on Cue Lists Opertion on Cue Lists Adding ues to orthogonl list: Algorithm ADD_CUBE(List_of_Cues C, Cue ) { if(c = ) return { = TOP(C) Cres = - /* hopping off minterms my result in multiple ues */ foreh res Cres { C = ADD_CUBE(C\{,res) { return C How n the ove proedure e further improved? Wht out the AND opertion, does it gin from orthogonl ue lists? Nive implementtion of COMPLEMENT opertion pply De Morgn s lw to SOP omplement eh ue nd use AND opertion Exmple Input non-orth. orthogonl - => ---- => ---- ---- --- ---- -- ---- - Nive implementtion of TAUTOLOGY hek omplement funtion using the COMPLEMENT opertor nd hek for emptiness We will show tht we n do etter thn tht! 35 36
Tutology Cheking Let A e n orthogonl over mtrix, nd ll ues of A e pir-wise distinguished y t lest two literls (this n e hieved y n on-the-fly merge of ue pirs tht re distinguished y only one literl) Does the following onjeture hold? A A hs row of ll - s? This would drmtilly simplify the tutology hek! Tutology Cheking Algorithm CHECK_TAUTOLOGY(List_of_Cues C) { if(c == ) return FALSE; if(c == {-...-)return TRUE; // ue with ll - xi = SELECT_VARIABLE(C) C = COFACTOR(C,Xi) if(check_tautology(c) == FALSE) { print xi = return FALSE; C = COFACTOR(C,Xi) if(check_tautology(c) == FALSE) { print xi = return FALSE; return TRUE; 37 38 Tutology Cheking Tutology Cheking Implementtion triks Vrile ordering: pik vrile tht minimizes the two su-ses ( - s get replited into oth ses) Quik deision t lef: return TRUE if C ontins t lest one omplete - ue mong others (se ) return FALSE if numer of minterms in onset is < 2 n (se 2) return FALSE if C ontins sme literl in every ue (se 3) 39 Exmple -- -- - --- x -- -- -- x2 --- -- -- x3 --- --- x4 x4 x x2 x3 -- -- ---- -- -- --- ---- tutology (se ) ---- tutology (se ) tutology (se ) not tutology (se 3) not tutology (se 3) 4
Speil Funtions Definition. A funtion f : B n B is symmetri with respet to vriles x i nd x j iff f(x,,x i,,x j,,x n ) = f(x,,x j,,x i,,x n ) Definition. A funtion f : B n B is totlly symmetri iff ny permuttion of the vriles in f does not hnge the funtion Symmetry n e exploited in serhing BDD sine f xx f xx i j i j - n skip one of four su-ses - used in utomti vrile ordering for BDDs Speil Funtions Definition. A funtion f : B n B is positive unte in vrile x i iff f xi f xi This is equivlent to monotone inresing in x i : f (m ) f (m ) for ll min-term pirs (m -, m + ) where m j m j, j i m i m i Exmple (, ) with i = 3 4 42 Speil Funtions Speil Funtions Similrly for negtive unte f xi f xi Exmple monotone deresing f (m ) f (m ) A funtion is unte in x i if it is positive unte or negtive unte in x i Definition. A funtion is unte if it is unte in eh vrile Definition. A over F is positive unte in x i iff x i j for ll ues j F Note tht over of unte funtion is not neessrily unte! (However, there exists unte over for unte funtion.) f m + positive unte in, negtive unte in m - f(m- )= f(m+ )= 43 44
Key pruning tehnique is sed on exploiting the properties of unte funtions sed on the ft tht unte lef ses n e solved effiiently New se splitting heuristi splitting vrile is hosen so tht the funtions t lower nodes of the reursion tree eome unte Unte overs F hve mny extrordinry properties: If prime over F is miniml with respet to singleue ontinment, ll of its ues re essentil primes In this se F is the unique minimum ue representtion of its logi funtion A unte over represents tutology iff it ontins ue with no literls, i.e., single tutologous ue This type of impliit enumertion pplies to mny suprolems (prime genertion, redution, omplementtion, et.). Hene, we refer to it s the Unte Reursive Prdigm. 45 46. Crete oftoring tree stopping t unte overs hoose, t eh node, the most inte vrile for splitting iterte until no inte vrile left (unte lef) 2. Operte on the unte over t eh lef to otin the result for tht lef. Return the result 3. At eh non-lef node, merge (ppropritely) the results of the two hildren. merge Min ide: Opertion on unte lef is omputtionlly less omplex Opertions: omplement, simplify, tutology, prime genertion,... Binte selet heuristi Tutology nd other progrms sed on the unte reursive prdigm use heuristi lled BINATE_SELECT to hoose the splitting vrile in reursive Shnnon expnsion The ide is, for given over F, hoose the vrile whih ours, oth positively nd negtively, most often in the ues of F 47 48
Binte selet heuristi Exmple Unte nd non-unte overs: d G = +d - - - - d F = + d+d - - - - - Choose for splitting! is unte is not unte Binte vriles of over re those with oth s nd s in the orresponding olumn In the unte reursive prdigm, the BINATE_SELECT heuristi hooses (most) inte vrile for splitting, whih is thus eliminted from the su-overs Exmple f d d --- -- unte f e d de --- -- e F C F C ---- unte --- unte - - F= - - - - - F= - - - - 49 --- unte ---- unte 5 Unte Redution Let F(x) e over. Let (,) e prtition of the vriles x, nd let A F T C F where. the olumns of A ( unte sumtrix) orrespond to vriles of x 2. T is mtrix of ll - s Theorem. Assume A. Then F F* Unte Redution Exmple A F T C F We pik for the prtitioning unte vriles euse it is esy to deide tht A 5 52
Unte Redution Exmple A A 2 A 3 B B 2 Assume A nd A 2 re unte nd hve no row of ll - s. Note tht A 3 nd A 4 re unte (single-row su-mtries) Consequently only hve to look t D to test if this is tutology A 4 D Unte Redution Theorem: A F T C F Let A e non-tutologil unte mtrix (A) nd T is mtrix of ll - s. Then F F*. Proof: If prt: Assume F*. Then we n reple F* y ll - s. Then lst row of F eomes row of ll - s, so tutology. 53 54 Unte Redution Proof (ont d): Only if prt: Assume F*. Then there is minterm m 2 (in vriles) suh tht F* m2 = (oftor in ue), i.e. m 2 is not overed y F*. Similrly, m (in vriles) exists where A m =, i.e. m is not overed y A. Now the minterm m m 2 (in the full vrile set) stisfies F m m 2 =. Sine m m 2 is not overed y F, F. Applition Tutology Cheking Improved tutology hek Algorithm CHECK_TAUTOLOGY(List_of_Cues C) { if(c == ) return FALSE; if(c == {-...-) return TRUE; // ue with ll - C = UNATE_REDUCTION(C) xi = BINATE_SELECT(C) C = COFACTOR(C,xi) if(check_tautology(c) == FALSE) { return FALSE; C = COFACTOR(C,xi) if(check_tautology(c) == FALSE) { return FALSE; return TRUE; 55 56
Applition Tutology Cheking Applition Complement Exmple -- -- - --- x -- -- -- x2 --- -- -- x3 --- --- x4 x4 Unte redution x x2 x3 ---- ---- --- not tutology (se 2 nd 3) -- -- ---- -- -- --- tutology (se ) tutology (se ) tutology (se ) not tutology (se 3) not tutology (se 3) 57 We hve shown how tutology hek (SAT hek) n e implemented reursively using the Binry Deision Tree Similrly, we n implement Boolen opertions reursively, e.g. the COMPLEMENT opertion: Theorem. Proof. f x f x f g x fx x f f x f x f x x f g g f f g x x x 58 Applition Complement Complement opertion on ue list Algorithm COMPLEMENT(List_of_Cues C) { if(c ontins single ue ) { Cres = omplement_ue() // generte one ue per return Cres // literl l in with l else { xi = SELECT_VARIABLE(C) C = COMPLEMENT(COFACTOR(C,xi)) xi C = COMPLEMENT(COFACTOR(C,xi)) xi return OR(C,C) Applition Complement Effiient omplement of unte over Ide: vriles pper only in one polrity on the originl over ( + + ) = ( + )( + )( + ) when multiplied out, numer of produts re redundnt + + + + + + + = + + we just need to look t the omintions for whih the vriles over ll originl ues (see the following exmple) this works independent of the polrity of the vriles euse of symmetry to the (,,,,) se (see the following exmple) 59 6
Applition Complement Applition Complement Mp (unte) over mtrix F into Boolen mtrix B F d e B d e onvert:, in F to in B (literl is present) - in F to in B (literl is not present) Find ll miniml olumn overs of B. A olumn over is set of olumns J suh tht for eh row i, jj suh tht B ij = Exmple {,4 is miniml olumn over for mtrix B 2 3 4 5 All rows overed y t lest one 6 62 Applition Complement Applition Complement For eh miniml olumn over rete ue with opposite olumn literl from F Exmple By seleting olumn over {,4, d is ue of f 2 3 4 5 2 3 4 5 d e d e The set of ll miniml olumn overs = over of f Exmple d e d e {(,4), (2,3), (2,5), (4,5) is the set of ll miniml overs. This trnsltes into: f d e d e 63 64
Applition Complement Theorem (unte omplement theorem): Let F e unte over of f. The set of ues ssoited with the miniml olumn overs of B is ue over off. Proof: We first show tht ny suh ue generted is in the offset of f, y showing tht the ue is orthogonl with ny ue of F. Note, the literls of re the omplemented literls of F. Sine F is unte over, the literls of F re just the union of the literls of eh ue of F). For eh ue m i F, jj suh tht B ij =. J is the olumn over ssoited with. Thus, (m i ) j = x j j =x j nd (m i ) j =x j j = x j. Thus m i =. Thus f. Applition Complement Proof (ont d): We now show tht ny minterm m f is ontined in some ue generted: First, m must e orthogonl to eh ue of F. For eh row of F, there is t lest one literl of m tht onflits with tht row. The union of ll olumns (literls) where this hppens is olumn over of B Hene this union ontins t lest one miniml over nd the ssoited ue ontins m. 65 66 Applition Complement The unte overing prolem finds minimum olumn over for given Boolen mtrix B Unte omplementtion is one pplition sed on the unte overing prolem Unte Covering Prolem: Given mtrix B, with B ij {,, find x, with x i {,, suh tht Bx (omponentwise inequlity) nd j x j is minimized Sometimes we wnt to minimize j j x j where j is ost ssoited with olumn j 67