320 likes | 581 Views
ECE 667 Synthesis and Verification of Digital Circuits Boolean Functions Basics. Maciej Ciesielski ciesiel@ecs.umass.edu Univ. of Massachusetts, Amherst. Slides adopted (with permission) from A. Kuehlmann, UC Berkeley 2003. Outline. Boolean function representation
E N D
ECE 667Synthesis and Verificationof Digital CircuitsBoolean Functions Basics Maciej Ciesielski ciesiel@ecs.umass.edu Univ. of Massachusetts, Amherst Slides adopted (with permission) from A. Kuehlmann, UC Berkeley 2003
Outline • Boolean function representation • Boolean space, cubes, cover • SoP, truth tables • Canonicity • Operations on Boolean functions • Cofactoring, Shannon expansion • Quantification • Basic theorems • Quine’s theorem • Fundamental theorem, tautology • Properties, special functions • Symmetry, unateness • Incompletely specified Boolean functions • Two-level logic minimization • Recursive factorization (heuristic, espresso) • Exact method (Quine McCluskey) Boolean Functions
B0 B1 B2 B4 The Boolean Space Bn B = { 0,1}, B2 = {0,1} X {0,1} = {00, 01, 10, 11}, etc. Karnaugh Maps: Boolean Spaces: B3 Boolean Functions
= on-set minterm (f = 1) = off-set minterm (f = 0) Boolean Functions x2 x1 Boolean Functions
= on-set minterm (f = 1) = off-set minterm (f = 0) f = x1 f = x1 x3 x3 Notation: x’ = x x2 x2 x1 x1 On-set, Off-set, Tautology Literal x1 represents the logic function f, where f = {x| x1 = 1} Literal x1 represents the logic function g where g = {x| x1 = 0} Boolean Functions
X1x2x3 F 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 0 Set of Boolean Functions • Truth Table or Function Table: • There are 2n vertices in input space Bn • There are 22n distinct logic functions. • Each subset of vertices is a distinct logic function: f Bn x3 x2 x1 Boolean Functions
Boolean Operations - AND, OR, COMPLEMENT Given two Boolean functions: f : Bn B g : Bn B • AND operation f × g = {x | f(x)=1 Ù g(x)=1} • The OR operation f + g= {x | f(x)=1 Ú g(x)=1} • The COMPLEMENT operation (^f or f’ ) f’ = {x | f(x) = 0} Boolean Functions
Cofactor and Quantification Given a Boolean function: f : Bn B, with the input variables (x1,x2,…,xi,…,xn) • Positive Cofactor of function f w.r.t variable xi fxi= f(xi=1) • Negative Cofactor of f w.r.t variable xi fxi’ = f(xi=0) • Existential Quantification of function f w.r.t variable xi, $xi f = fxiÚ fxi’ • Universal Quantification of function f w.r.t variable xi, "xi f = fxiÙ fxi’ Boolean Functions
Representations of Boolean Functions • We need representations for Boolean Functions for two reasons: • to represent and manipulate the actual circuit we are “synthesizing” • as mechanism to do efficient Boolean reasoning • Forms to represent Boolean Functions • Truth table • List of cubes: Sum of Products, Disjunctive Normal Form (DNF) • List of conjuncts: Product of Sums, Conjunctive Normal Form (CNF) • Binary Decision Tree, Binary Decision Diagram • Boolean formula • Boolean network • Canonicity – which forms are canonical? Boolean Functions
Boolean Formula • A Boolean formula is defined as an expression with the following syntax: formula ::= ‘(‘ formula ‘)’ | <variable> | formula “+” formula (OR operator) | formula “×” formula (AND operator) | ^ formula (complement) Example: f = (x1×x2) + (x3) + ^^(x4 × (^x1)) typically the “×” is omitted and the ‘(‘ and ‘^’ are simply reduced by priority, e.g. f = x1x2 + x3 + x4^x1 Boolean Functions
= on-set minterm (f = 1) = off-set minterm (f = 0) c = x1 f = x1x2 f = x1x2x3 x3 x3 x3 x2 x2 x2 x1 x1 x1 Cubes • A cube is defined as the product (AND) of a set of literal functions (“conjunction” of literals). Example: C = x1x’2x3 represents the following logic function f = (x1=1)(x2=0)(x3=1) Other examples of cubes: Boolean Functions
Set of Cubes – SoP vs Cover • A function can be represented by a sum of cubes: f = ab + ac + bc Since each cube is a product of literals, this is a “sum of products” (SOP) representation • A SOP can be thought of as a set of cubes F (a cover of f ). F = {ab, ac, bc} • Definition: coverF of function f = set of implicants that cover all minterms of functionf • Cover is non-unique, e.g., F1={ab, ac, bc} and F2={abc, a’bc, ab’c, abc’} are some of possible covers of Boolean function f = ab + ac + bc. Boolean Functions
ac bc = on-set minterm (f = 1) = off-set minterm (f = 0) = don’t care-set minterm (f = x) ab b Cover minimization • Two-level minimization seeks a minimum size cover (least number of cubes). Reason: minimize number of product terms in PLA c Note: each onset minterm is “covered” by at least one of the cubes and none of the offset minterms is covered. a Boolean Functions
n=3, m=3 a a b b c c f1 f2 f3 PLAs - Multiple Output Functions • A PLA is a functionf : BnBmrepresented in SOP form • Each distinct cube appears only once in the AND-plane, and can be shared by (multiple) outputs in the OR-plane, e.g., cube abc. OR plane Personality Matrix abc f1f2f3 10- 1 - - -11 1 - - 0-0 - 1 - 111 - 1 1 00- - - 1 AND plane Boolean Functions
ac bc bc F \ {ab} f ab ac c not covered, so ab is irredundant b a Irredundant Cubes • Definition: Let F = {c1, c2, …, ck} be a cover for f, i.e. f = ik=1ci A cube ci F is irredundant if F \ {ci} f A cover is irredundant if all its cubes are irredundant. Example: f = ab + ac + bc Boolean Functions
abc bd c b d cd a Prime, Essential, Irredundant • Definition: A cube is primeif it is not contained in any other cube. A cover is primeif all its cubes are prime. • Definition: A prime of f is essential if it contains a minterm that is not contained by any other prime. Example: f = abc + b’d + c’d is prime and irredundant. abc is essential since abcd’ abc but not in the other cubes abcd abcd’ Boolean Functions
abc bd c b d cd a Prime and Irredundant Covers Example:f = abc + b’d + c’d is prime and irredundant. abcd abcd’ • Why is abcdnot an essential vertex of abc? • What is an essential vertex of abc? • What other cube is essential? What prime is not essential? Boolean Functions
Implicants • Formally: cube C f is an implicant of f • It is called implicant since C = 1 f = 1 • In an n-dimensional Boolean space Bn, an implicant with n literals is a minterm. • Prime implicants • Essential implicants • Irredundant implicants are defined similarly as for cubes. Boolean Functions
Quine’s Theorem • Importance of having prime cubes: • minimum SOP solution can be composed of prime cubes only • Theorem(Quine): • There exists a minimum cover that is prime • Given initial cover for F = (f,d,r), • find a minimum cover G of primes where: f G f+d • G is a prime cover of F ; f = on-set, r = off-set, d = don’t care set Boolean Functions
f = x fx + x’ fx’ Shannon (Boole) Cofactors Let f : Bn B be a Boolean function, and x= (x1, x2, …, xn) the variables in the support of f. The cofactorfa of f w.r.t literal a=xi or a=x’i is: fxi (x1, x2, …, xn) = f (x1, …, xi-1, 1, xi+1,…, xn) fx’i (x1, x2, …, xn) = f (x1, …, xi-1, 0, xi+1,…, xn Computation of cofactors is a fundamental operation in Boolean reasoning Shannon (Boole) expansion Boolean Functions
Generalized Cofactor • The generalized cofactorfC of f by a cube C is f with the fixed values indicated by the literals of C, • Eg. if C= x1 x’4 x6 fC is just the function f restricted to the subspace where x1 =x6 =1 and x4 =0. • As a function, fC does not depend on x1,x4or x6 anymore (However, we still consider fC as a function of all n variables, it just happens to be independent of x1,x4and x6). • x1f fx1 Example: f = ac + a’c , af = ac, fa=c Boolean Functions
{ c i } Cofactor of Cover Definition: The cofactor of a coverF is the sum of the cofactors of each of the cubes of F. Given the cover The cofactor of the cover is simply Note: If F={c1, c2,…, ck} is a cover of f, then Fc= {(c1)c, (c2)c,…, (ck)c} is a cover of fc. Boolean Functions
Cofactor of Cubes Definition: The cofactor Cxjof a cube C with respect to a literal xj is • C if xj and x’jdo not appear in C • C\{xj} if xj appears positively in C, i.e. xjC • if xj appears negatively in C, i.e. xj’C Example 1:C = x1 x’4 x6 Cx2 = C (x2 and x’2 do not appear in C ) Cx1 = x’4 x6(x1appears positively in C) Cx4 = (x4 appears negatively in C) Example 2:F = abc + b’d + c’d Fb = ac + c’d (Just dropb everywhere and delete cubes containing literalb) Boolean Functions
f c Fundamental Theorem Theorem:Let c be a cube and f a function. Then c f fc 1. Proof.We use the fact that x fx = x f, and fx is independent of x. If : Suppose fc 1. Then cf =fcc = c. Thus, c f. Boolean Functions
C=xz m= 000 m’= 101 m’ Proof (cont.) Only if. Assume c f Then c cf = cfc. But fc is independent of literals i c. If fc 1, then m Bn, fc(m)=0. We will construct a m’ from m and c in the following manner: mi’=mi, if xic and xic, mi’=1, if xi c, mi’=0, if xi c. i.e., we made the literals of m’ agree with c, i.e. m’ c Þ c(m’)=1 Also, fcis independent of literals xi,xi cÞfc(m’) =fc(m) = 0 Þ fc(m’) c(m’)= 0 contradicting c cfc. m Boolean Functions
Application of Containment Test: c F Boolean Functions
Extra slides Boolean Functions
Prime and Essential Implicants • Quine’s Theorem (Willard Quine, 1908 – 2000, Harvard Univ.): • Boolean function can be implemented with only prime implicants (but other solutions exist) • The number of such implicants is minimum • Essential prime implicant • Prime implicant that covers a minterm that is not covered by any other prime implicant Boolean Functions
Essential Prime Implicants • Example:F= (0,1,2,6,8,9,10,14) • Essential implicants : • Implicant 1 = (0,1,8,9) • Implicant 2 = (2,6,14,10) • Non-essential implicant:(0,2,8,10) Boolean Functions
Don’t Cares: Incompletely Specified Functions • Output of function is irrelevant for some inputs • Input might never occur • Input is invalid • Function is incompletely specified • Multiple completely specified functions can implement it • Karnaugh map is marked with ‘x’ for don’t cares • Output can be set to 1 or 0 (hence “don’t care”) • Choose most convenient output • Maximize block size • Specification of don’t care conditions: • Function: F(w,x,y,z) = (1,3,7,11,15) • Don’t cares: d(w,x,y,z) = ∑(0,2,5) Boolean Functions
Incompletely Specified Functions • Design a logic function that determines if a BCD digit is divisible by 3 • Find minimum SOP logic implementation • What are the possible inputs for this function? • Only (0000)2 (1001)2 are used • Other inputs are not valid • What should we do with invalid inputs? • “Don’t care” • Output can take any value • F(A,B,C,D) = AD + B’CD + BCD’ + A’B’C’D’ Boolean Functions
Example with Don’t Cares • Minimization example: • F(w,x,y,z) = (1,3,7,11,15) and d(w,x,y,z) = (0,2,5) • Solution is non-unique Boolean Functions