<<

Binary

1

Unate functions

! If a cover C(f) is unate in xj, then f is unate in xj.

! Theorem If f is unate in xj, then every prime implicant of f is unate in xj.

2

1 Why are unate functions so special?

! Special Boolean algorithms for unate functions are not only fast, but also give the guaranteed minimum result. ! The algorithms presented perform the Boolean operations and simplify the result in the same time. ! In practice, many functions are partially unate. The divide and conquer strategy aimed at unateness produces very shallow ; algorithms are fast in practice.

3

Unate recursive paradigm works for:

! Complementation ! Irredundant cover ! Reduce ! Essential primes

= + ! Example f x 1 x 2 x 2 x 3 is unate

4

2 Important facts about unate functions

Proposition 1.

A f is monotone increasing (decreasing) in x j if and only if no prime implicant of f has a 0 (1) in the j-th position. Proof: (if) If no prime implicant has a 0 in the jth position, any prime

cover C(f) is unate in x j . So f is unate in x j. (only if) Let c i is a prime with 0 at jth position -> the cube c~i obtained by replacing 0 in jth position with a 1 contains at least one vector in f . For the input v corresponding to that vertex, f(v)=0. If we change x j from 1 to 0 in v, the value of f changes from 0 to 1, so f is not monotone increasing. 5

Proposition 2. A unate cover is a if and only if it contains a row of all 2s (it contains a universal cube).

Proposition 3. Let C be a unate cover, S any of the cubes of C and c a cube in C. Then c ⊆ S if and only if c ⊆ s for some s ∈ S .

(Only if) Let C be a positive unate cover. Since C is positive, unate, every cube in C contains the vertex (1,1,…1) and so c ∩ s ≠ 0 ∀s∈ S ⊆ ≡ Now, suppose c S . This implies that S c 1 but a unate cover is a tautology if and only if it contains a row of all 2s. So there exists s ∈ S Which generated this row. Thus c ⊆ s from this s ∈ S .

The if part is trivially true.

6

3 Proposition 4. Every prime of a unate function is essential.

Proposition 5. Let C be a unate cover and P be a of all primes of b(C), the logical function specified by C. Then P ⊆ C . If in addition, C is minimal with respect to single cube containment, then P=C, and C is unique minimum cover.

( C minimal with respect to containment ≡ any c is contained in some p)

From proposition 5, it follows that we can find the minimum cardinality prime cover of a unate function starting from any cover and (a) expand each cube to a prime (b) remove any cube which is contained in any other cube of the cover.

7

The following are helpful in constructing an efficient algorithm for finding the complement of a function:

• If a logic function f is monotone increasing in x j , then the complement of f, f is monotone increasing in x j .

• The complement of a unate function is unate.

•The cofactors of a unate function f with respect to x j and x j are unate.

8

4 How to simplify a unate function?

Example: f = abc + abc + abc + abc + abc

f is monotone increasing in a, decreasing in b and c. c

b a f = ab/c + abc/ + abc + a/bc/ + a/bc = ac + ab + abc + b + bc (unate cover)

f = b + ac (set of all primes = global unate cover)

9

Proposition.

Let f = x f + x j f be the Shannon expansion of a j x j x j completely specified logic function f. Then f=1 (tautology) if and only if f ≡ 1 and f ≡ 1 . x j x j Proof (If) If f ≡1 ∧ f ≡1⇒ f = x + x ≡1. x j x j j j (only if) f f Suppose that x j is not a tautology -> exists an input of x j say y , such that the output of f x is 0. Since f x j j j = is independent of x j , an input combination with x j 1 can be selected so that the output of x f is 0. j x j For this input combination, the output of f = x f + x j f j x j x j corresponding to y j must be 0, -> f is not a tautology.

10

5 General recursive paradigm Applies to: intersection complementation tautology 1. Apply the operation to the 2 cofactors. 2. Merge the results. Operate( f , g) = merge(x operate( f , g ), j x j x j

x joperate( f , g )) x j x j

11

Recursion tree

Each node merges the results of its 2 children trees.

For tautology checking - merging is simple, both trees must be tautologies.

Complementation and reduction are more complicated.

h h = x h + x jh (for function) j x j x j

h0 h1 H = x H + x j H j x j x j (for covers)

12

6 Binary recursion tree

! The recursive Shannon expansion corresponds to a binary recursion tree = + = + + + f xf x x f x x(yf xy y f x y ) x(yf xy y f xy )

x1 f x f 1 0 0 1 f f x P(v) = x2 x c x1x2 x3 0 y 0 y 0 1 P(v) 1 1 f f f x y xy f y x y x P(v) x3 0 Path P(v) to node v corresponds to cube c 1 v 13

Binary recursion tree

! The root represents the original function f ! Each node v corresponds to f cP (v ) ! f If ever c P ( v ) =1 or 0 we can terminate the tree and replace v by 1 or 0. Such a node is a leaf.

! Example: f = ab + a’c splitting variable 1 a 0 1 a 0 c b 1 b 0 b 1 0 1 0 1 0 c c 0 1 0 1 0 1 1 1 0 0 1 0 1 0

14

7 Implicit - branch and bound

! Checking for tautology and many other theoretically intractable problems (co-NP complete) can be effectively solved using implicit enumeration. n ! Use recursive Shannon expansion to explore B n ! in (hopefully) large subspaces of B , prune the binary recursion tree by f ! exploiting properties of the node function cP (v ) ! exploiting heuristic bounding techniques n ! even though in the worst case the recursion tree may have 2 nodes, in practice we typically encounter a linear number of nodes ! thus we say that the 2 n min-terms of f have been implicitly enumerated ! BDD’s are alternate representations in which implicit enumeration is performed statically, and nodes with identical path cofactors are identified.

15

Unate recursive paradigm

! In the ESPRESSO program, the key pruning technique is based on exploiting the properties of unate functions. ! The splitting variable is chosen so that the functions at lower nodes of the recursion tree become unate. ! Unate covers F have many good properties: ! If a cover F is minimal with respect to single cube containment, all of its cubes are essential primes. ! In this case F is the unique minimum cube representation of its logic function. ! A unate cover represents the tautology iff it contains a cube with no literals. ! This type of implicit enumeration applies to many subproblems (prime generation, complementation, reduction).

16

8 Recursion tree

! Each node merges results of its 2 children trees. ! For tautology checking - merging is simple, both subtrees must be tautologies. ! Complementation and reduction are more complicated. ! h0 and h1 are the logic functions corresponding to the trees below a node h of a tree. h h=xj’h0+xjh1

! We work with covers and their matrix h0 h1 representations: H = xj’H0 + xjH1

17

How to keep results compact?

! If H0 and H1 are prime and irredundant, we would like to have the same property at the next stage, i.e. H which is prime and irredundant. ! IDEA: Make all the cubes in H prime: pick one cube of H at a time and make it as large as possible, provided that it does not contain vertex not in H.Then remove redundant covers. ! HERE: H0 and H1 are prime and irredundant and in a form of Shannon expansion, so to enlarge a cube, one has to change a 0 or a 1 in the input cube to 2, or change 3 in the output to 4. ! The only possibility is to change 1 or 0 to 2 at the j-th position. ! “Rising” cubes and checking redundancy is expensive. Fast heuristics are needed.

18

9 Unate complementation

! Proposition The complement of a unate cover F can be expressed as j F = x F + F x j x j (a) if F is monotone increasing in xj, or as (b) j j F = x F + F x x j Proof. If F is monotone increasing in xj, every cube of F has either ⊆ a 1 or a 2 in the j-th position. Hence F F j and F can be x j x written as = j + = j + F x F j F (x F )F j x x j x j x j F = x F x j + F x j

19

Computing a complement of a unate cover

! Compute x j F x j , this involves complementation of a reduced # of cubes (assuming F depended on xj ) | F |<| F | F and one less variable xj, since x j and x j contains a column of 2s in the j-th position.

! Compute F x j ; this involves complementation of the | F |=| F | original cover dropping one variable, since x j because F is monotone increasing in xj.

20

10 The process:

! Choose the variable; ! Recursively complement a cover consisting of cubes not containing that variable; ! Complement the original cover with that variable dropped; ! Tack the variable onto cubes of the first result; ! Concatenate the two results

! Termination: Complement of a cover with no cubes is the universe and the complement of a cover with no variables is empty.

21

1 2 k ! Definition : Given C = { c , c , L , c } a unate cover, define a matrix B: i ≠ 1 if (c ) j 2 Bij = 0 otherwise B is the personality matrix of C. ! Theorem: Suppose S={ j1,j2, …,jr} is a set of column indices which is minimal cover* of B. Construct a cube c as follows: 2 if j ∉ S cj = 0 if C is increasing in xj 1 if C is decreasing in xj then c is prime of b(C).

22

11 ! A column cover of a binary matrix B is defined as a set of ≥ columns L such that ∑ M ij 1 ∀ i . j∈L

! Complementation of unate function 0 1 1 … 0 1 cube 1 M= 1 0 1 … cube 2 … Minimal column cover of M = minimal set of columns such that ≥ ∀ ∑ M ij 1 i j∈J ! Theorem: If f is unate, then the set of all minimal column covers of M is the minimum cube cover of f. ! Example f = ab’ + b’c + d A 1 in every possible row, one possible cover 1 1 0 0 M = 0 1 1 0 Minimal covers { (2,4), (1,3,4)}, f’ = bd’ + a’c’d’ 0 0 0 1

23

! Algorithm COMP ! If f is unate then f’=UCOMP(f) ! Else f’<- Merge(xCOMP(fx) + x’COMP(fx’)) ! Algorithm UCOMP ! Represent function as a Boolean matrix 1 if xj or xj’ occurs in prime i Bij = 0 otherwise

! A column cover of B is a set of columns {jk} such that ∀i∃k such that B =1 ijk ! Complement f = set of all minimal column covers of B. ! Example: = + f x1 x2 x3 x2 x4

B = 1 1 1 0 {2}, {1,4}, {3,4} 0 1 0 1 = + + f x2 x1 x4 x3 x4

24

12 Algorithm UNATE COMPLEMENT

! Generate the set of all minimal covers of a 0-1 matrix B. How to generate? ! Select column j (heuristic ?) ! Select Bj = all rows not covered by column j and all columns except j. ! Generate set Sj of all minimal covers of Bj (then {j} + Sj is the set of minimal covers of B which include j) [ x’j f’x’j] ! Set B’ = all columns of B except j ! Generate set Sj’ of all minimal covers of B’j (S’j is all minimal covers of B which don’t include j) [ f’xj] ! Return ( {j} + Sj ) + S’j

25

Illustration of a UNATE COMPLEMENT

j1 no j1 = + ! Example f abc bd j2 no j2

j3 no j3

C = 1 0 1 2 B = 1 1 1 0 2 0 2 1 0 1 0 1

1,4 1 2 ~1 1 1 0 1 0 1 3,4 1 0 1 2 [2,4]

2 3 4 1,2 1,4 Not minimal cover; 1,2 is contained in 2.

26

13 Fast Recursive Boolean Function Manipulation

! The unate recursion paradigm: RECURSIVE UNATE ALGORITHMS: ! simplification ! complementation ! tautology ! reduction ! generating all prime implicants ! irredundant cover ! multiplication ! subtraction ! equivalence

27

Unate recursion paradigm f=C x x’ z’ y z ! Choose the splitting variable y’ u u which is the most binate. w w’ u q’ u v v’ q ! Operate on unate levels: u u u u ! intersection ! complementation ! simplification ! tautology ! e.t.c. ! Merge appropriately = + f x( f x ) x( f x )

28

14 Divide and conquer strategy

! Cofactor f until a unate function appears ! Operate on unate function (complement, minimize, etc) and compose ! GOAL: Get to unate level as fast as possible; Keep cube duplication to minimum. Choice of splitting variable : choose xi such that it has minimum # of 2s (most binate column).

29

In VLSI a spectrum of algorithms is needed fast

! Merging with Identity no guarantee of prime ! Merging with Containment or irredundant ! Merging with Cover (prime) ! Merging with Cover and Irredundant (prime and irredundant) slow

30

15 Merging

! Rising cubes and making them irredundant is expensive ! Merge with Identity: checks only for identity between cubes in H0 and H1. ! Merge with Containment checks additionally for containment by a single cube H0 and H1.

! Both heuristics do not guarantee that H is a set of primes. Moreover, the only possibility of redundancy detected is when two cubes in H0 and H1 are identical.

31

Merging

! Identity can be checked by encoding and sorting ~0(Nlogn), n=|H0|+|H1|. ! Straightforward pairwise containment is 0(|H0| |H1|). ! Complementation = ⊕ Complementation f x( f x ) x( f x ) = + + ( f x ) d1 d2 Ldk f = c + c + = + + 1 2 L ( f x ) e1 e2 el L x x’ = ()f () di e j ⇒ di x f x ⊆ di e j ⇒ di , xe j

else ⇒ xdi , xe j

32

16 Simplification

! A fast, heuristic algorithm SIMPLIFY. No guarantee that each cube of the cover will be prime irredundant. Works well for single output functions. ! Idea: f = x f + x j f ! Use Shannon expression j x j x j ! obtain simplification by applying the merging and simplification operations on the cofactors:

SIMPLIFY ( f ) = MWC(x SIMPLIFY ( f ) + x j SIMPLIFY ( f )) j x j x j

where MWC=merge with containment

33

Minimization of a single output unate cover

! Eliminate each cube that is contained in any other cube or cover. We are sure that the cover constructed is the minimum prime cover for this unate function. ! Primness and irredundancy are sacrificed in the merging process. ! Optimality at the leaf level, to make the algorithm work well: choose splitting variables such that the depth of the tree is as shallow as possible -> fewer merging.

34

17 Procedure SIMPLIFY(F)

/* F: a cover of f, single output function */ /* Returns F*, a smaller or equal sized cover */ begin if (F unate) return ( F*<- UNATE_SIMPLIFY(F)); j<-BINATE_SELECT(F);

F*<- MERGE_WITH_CONTAINMENT( x j SIMPLIFY(Fx ), x j SIMPLIFY(F )) j x j if (|F|<|F*|) return (F*=F) else return (F*) end

35

EXAMPLE RESULT :

x1 x2 x3 f = 2 1 2 0 2 2 0 2 2 F is unate, -> min. cover f= 1 1 2 The only binate variable is x1 2 1 1 f = 2 1 2 It is unate, and 2-nd cube is contained in the 1-st, so x1 2 1 1

2 2 2 f = [2 1 2 ] f = x1 x1 2 1 1 which simplifies to [2 2 2]

f ⊆ f Perform MERGE_WITH_CONTAINMENT x1 x 1 , we express f as

f = f + x f x f + x1 f x1 x1 instead of 1 x1 x1

36

18 Example f = bcd f + abce + acf + abd + be f + bcd f + abcde + bcd f + abcde + bcd f + abd f + abdf

f = 2 0 0 0 2 0 f b = 1 2 1 2 2 1 1 2 1 2 2 1 0 0 1 2 1 2 0 2 2 1 2 2 2 2 2 2 0 1 1 2 1 2 2 1 2 2 2 2 0 1 2 2 0 0 2 2 0 1 2 1 2 2 2 2 0 0 2 1 -> 2 2 2 1 2 2 2 1 2 2 0 1 2 2 0 0 2 0 f = 1 1 1 2 2 1 2 1 0 0 2 1 1 2 2 1 2 0 2 1 2 1 2 2 1 0 1 0 0 2 1 2 2 1 2 1 2 1 2 2 0 1 2 0 0 0 2 1 2 1 0 0 2 2 1 0 1 0 1 2 1 2 1 2 2 1 0 0 1 2 1 2 2 1 0 0 2 0 f = 0 2 1 2 1 2 1 0 1 0 2 2 1 1 2 1 2 0 b 2 2 0 0 2 2 1 2 1 2 2 1 1 1 2 1 2 1 1 2 1 0 2 2 2 2 0 0 2 2

37

Example (continues)

! Original function : f = bcd f + abce + acf + abd + be f + bcd f + abcde + bcd f + abcde + bcd f + abd f + abdf

! Simplified function:

f = abcf + bd + be f + bcd + abce + abcd + acf + cd

! A more powerful minimizer yields:

f = bd + be f + abce + abcd + acf + cd

38

19 Espresso II heuristics

! Input = F and D, cube covers of the on-set and don’t care set of an incompletely specified Boolean function. ! Output : a minimized cover. ! Objectives: ! Minimize the # of product terms in the cover (NPT) ! Minimize # literals (non 2s) in the output (NLI) ! Minimize the output part in terms of the number of literals (NLO) ! Goal when building the algorithm : ! resources are limited ! Obtain a solution which is as close to the optimum, as possible.

39

Sequence of operations in ESPRESSO II

! Complement: (compute the complement and the don’t care set). ! Expand : (Expand each implicant into a prime and remove covered implicants). ! Essential Primes: (Extract the essential primes and put them in the don’t care set). ! Irredundant cover:(Find a minimal irredundant cover). ! Reduce:(Reduce each implicant to a minimum essential implicant). ! Iterate 2,4,5 until no improvement. ! Lastgasp: (try reduce, expand and irredundant cover one last time using a different strategy. If successful, continue the iteration. ! Make sparse: (Include the essential primes back into the cover and make the PLA structure as sparse as possible)

40

20 Complementation

! Idea: iterate over each output using the single-output complementer based on the unite recursion paradigm.

! We remember that the complement of a given Boolean function can be obtained by recursive use of the Shannon formula:

f = x f + x j f j x j x j

! xj are splitting variables, chosen such that the cofactors become more unate. When leaf is unate, then we use unate-complement to find the result.

41

Complementation (continued)

! A complement of a given multi-output function is computed and represented as the concatenation of the single output function. ! Reasons: ! Experiments show that multi-output complementation seldom saves time and often leads to huge CPU times. ! Single output format allows for more efficiency in EXPAND (a major component of COMPLEMENT).

42

21 Complement of a single output function

! Take advantage of the special cases: ! If the given function has a cube of all 2s -> the complement is empty ! F is unate cover ( in each column in the matrix representation there are no both 1s and 0s) -> call UNATE_COMPLEMENT ! A column of all 0s or all 1s occurs -> extract a cube which represents the columns where this case occurs. For each j, if column j has 0s only -> then cj = 0, if column j has 1s = ∩ only, then cj=1 and otherwise cj=2. So the cover F c Fc = ∪ De Morgan’s law: F c Fc c is unate, so its complement by UNATE_COMPLEMENT. ! Now F is binate and no cube factors out, use recursive Shannon expansion with appropriate choice of splitting variable.

43

Example

! x x x x x 2 f = x f , f = x2 + f 1 2 3 4 5 X -> all 1’s -> 2 x2 x2 2 1 1 1 1 2 1 1 1 0 F = 2 2 1 1 1 F = 2 2 2 1 1 x x x 2 1 0 1 2 2 2 2 1 1 0 2 3 2 2 2 1 0 2 1 0 2 1 2 2 0 1 2 2 2 0 2 1 F x x = 2 2 2 1 2 2 3 2 2 2 2 1

Unate, so it is passed to UNATE_COMPLEMENT

Split by x5 2 2 2 1 2

2 2 2 1 2

44

22 Merging example at the branch x3

! Suppose the cofactors are

F = 2 2 2 0 0 F = 2 2 2 0 0 x3 x3 2 1 2 1 1 2 1 2 2 1

Both cofactors contain (2 2 2 0 0) (21211) ⊆ (21221) ⇒ (21211) remains unchanged and (21221) becomes (21021) F = 2 2 2 0 0 2 1 2 1 1 2 1 0 2 1

In Espresso we seek only a representation of the off-set, but not necessarily minimal representation of it. Off-set is needed for EXPAND.

45

23