Heuristic Minimization of Two Level Circuits Sungho Kang Yonsei University
Outline Local Search Checking for Equivalence and Tautology Choosing the Right Direction Identifying Essential Implicants
Local Search Local search algorithms The algorithms that start from an initial solution and try to find a better one by applying successive modifications One property of the solution of a local search algorithm is local optimality A solution is locally optimal if its neighborhood does not contain any solution of lower cost
Local Search Applied to Logic Minimization Starting point is a cover for a multi-output function and the cost is the number of cubes with the number of literals as a tie-breaker The neighborhood is defined as the set of covers that are obtained from the original cover by adding or removing exactly one literal to one of the cubes A new cover obtained is a feasible point if it is equivalent to the original one The solutions with more cubes than the initial cover are not part of the search space
Local Search Applied to Logic Minimization xyz f 000 1 xyz f 01- 1 change 000 1 into 0-0 1 0-0 1 - 11 1 -11 1 Expand output xyz fg xyz fg xyz fg xyz fg xyz fg 0-1 10 0-1 11 0-1 11 1- - 10 1- - 10 1-0 10 1-0 10 1-0 10 - - 1 10 0- 1 11 00- 01 00- 01 -00 01 0-1 01 -10 01 -00 01 -00 01 -11 01 -10 01 -11 01 -11 01
Simple Local Search Algorithm F = EXPAND(F,D); F = IRREDUNDANT(F,D); do { cost = |F|; F = REDUCE(F,D); } while (|F| < cost); F = MAKE_SPARSE(F,D);
Checking for Equivalence Equivalence and Tautology The expansion or reduction is valid if and only if ci* ( F-{ci} ) D F={cj} is the current cover for ON-set and D is the cover for DC-set ci is the cube of F that is being added or reduced ci* is the cube that contains the newly added or removed minterms xyz f check the validity of the expansion of 000 1 to 0-0 1 000 1 01- 1 must check the containment of 010 1 in -11 1 xyz ( F-{ci} ) D 100 - 01- 1 - 11 1 100 1
Checking for Tautology Equivalence and Tautology The cofactor of a function f(x1, x2, …, xn) with respect to literal x1, written fx1, is f(1, x2, …, xn) The cofactor of a function f(x1, x2, …, xn) with respect to literal x1’, written fx1’, is f(0, x2, …, xn) The cofactor of a function f(x1, x2, …, xn) with respect to cube c is the successive cofactoring of f with respect to all the literals in c A function that is identically 1 is called a tautology For a function f and a cube c c f fc 1
Checking for Tautology Equivalence and Tautology General rule Eliminate the rows that disagree with the input part of ci* A disagreement means that the row has a 1 in an input column where ci* has a 0 or vice versa Eliminate the rows that do not have at least a 1 in an output column where ci* has a one
Unate Functions Equivalence and Tautology A function f(x1, x2, …, xn) is monotonically increasing in variable x1 if and only if f(0, x2, …, xn ) f(1, x2, …, xn) A function f(x1, x2, …, xn) is monotonically decreasing in variable x1 if and only if f(0, x2, …, xn ) f(1, x2, …, xn) If neither of the two above is true, f is non monotonic in x1 A function f(x1, x2, …, xn) is unate in variable x1 if and only if it is either monotonic increasing or monotonic decreasing in x1 It is unate if it is unate in all of its variables
Unate Functions Equivalence and Tautology A cover F is monotonically increasing in variable x1 if and only if x1 never appears complemented in the terms of F It is monotonically decreasing in variable x1 if and only if x1 never appears uncomplemented in the terms of F If neither of the two above is true, F is non monotonic in x1 If function f(x1, x2, …, xn) is unate in variable x1, then there exists a cover of f unate in x1 If a cover F is unate in x1, then the function F represents is also in x1 A unate cover F is a tautology if and only if it contains the constant term 1
Unate Functions Non-unate cover wxyz f - 1- 1 1 0 -10 1 010- 1 Equivalence and Tautology Non-unate cover xyz f yz fx yz fx’ 1-1 1 after splitting -1 1 0- 1 11- 1 1- 1 -0 1 00- 1 0-0 1 It is sufficient to examine one of them to see that the function is not a tautology wxyz f - 1- 1 1 0 -10 1 010- 1 All minterms with w=1 and x=0 cause f to be 0 After simplification, no row is left The fucntion is not tautologous
Speed-up for Tautology Checking Equivalence and Tautology A row of all - in the input part If such a row is found, the function is tautologous in all the outputs that have a 1 in that row This condition is always sufficient and is also necessary for unate functions An input column of all 1s or all 0s If such a column is found, the function is not a tautology If the number of inputs is less than 8, the truth table is generated and the tautology question is answered by inspection The rationale is that if the number of inputs is small enough, generating the truth table is faster than recurring If the vertex count of the cover is insufficient, the function is not a tautology The vertex count of the cover is the sum of the vertex counts of the cubes
Tautology Checks : Example Equivalence and Tautology First : Not a tautology wxyz f cover is unate in w and x - - 1 - 1 1 - - 1 1 cofactor wrt to w’ and x yz f - 0 - 0 1 1- 1 - 0 0 - 1 Second : Not a tautology wxyz fg cover is unate in x and x 1- 01 01 - 110 10 cofactor yz fg 1110 11 -0 10 - - - 0 10 -1 11 - - - 1 11 can drop y g is not a tautology
Choosing the Right Direction The choice of one direction over another may influence the quality of the solution
Recursive Complementation Right Direction For a Boolean function f f’ = x fx’ +x’ fx’’ For f monotonic increasing in x f’ = fx’ +x’ fx’’ For f monotonic decreasing in x f’ = x fx’ + fx’’
Recursive Complementation Right Direction Example wxyz If we select w, a row of all dashes will appear in fw 11 - - Complement of the tautology is trivial to compute 1 - - - - 1 - 1 fw’ = 0 - 11 - compute fw’’ cofactoring f xyz - 111 1- 1 11- 111 fw’’ = x’+G’ xyz final result 0- - wxyz -00 00 - - 0 - 00
Using the OFF-set in the Expansion Right Direction Build a blocking matrix, that has a row for each cube in the OFF-set and a column for each variable A row of the blocking matrix tells us that it is OK to expand the cube, as long as at least one of the directions corresponding to one of its ones is not expanded
Identifying Essential Primes Let F be a cover composed of prime implicants Let e be one of the primes in F and let G be the cover composed of the remaining primes Then e is an essential prime if and only if it is not covered by the union of ; 1. The consensus terms of e and each term of G 2. The intersections of e and each term of G