33
Boolean Functions 1 ECE 667 Synthesis and Verification of Digital Circuits Boolean Functions Basics Maciej Ciesielski [email protected] Univ. of Massachusetts, Amherst Slides adopted (with permission) from A. Kuehlmann, UC Berkeley 2003

Logic Synthesis - UMass Amherst

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Logic Synthesis - UMass Amherst

Boolean Functions1

ECE 667Synthesis and Verification

of Digital Circuits

Boolean Functions Basics

Maciej [email protected]

Univ. of Massachusetts, Amherst

Slides adopted (with permission) from A. Kuehlmann, UC Berkeley 2003

Page 2: Logic Synthesis - UMass Amherst

Boolean Functions 2

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)

Page 3: Logic Synthesis - UMass Amherst

Boolean Functions 3

The Boolean Space Bn

B = { 0,1}, B2 = {0,1} X {0,1} = {00, 01, 10, 11} , etc.

B0

B1

B2

Karnaugh Maps: Boolean Spaces:

B3

B4

Page 4: Logic Synthesis - UMass Amherst

Boolean Functions 4

Boolean Functions

=

= ∈ ∈

= = = = =

1 2

1 2

1 1 2 2

1 2 1 2

Boolean Function: ( ) :{0,1}( , ,..., ) ;

- , ,... are - , , , ,... are - essentially: maps each vertex of to 0 or 1

Exampl

vari

e:{(( 0, 0),0),(( 0,

ablesliterals

1

n

nn i

n

f x B BBx x x x B x B

x xx x x x

f B

f x x x x= = = =1 2 1 2

),1), (( 1, 0), 1),(( 1, 1),0)}x x x x

1x

2x

001

1

x2

x1

= on-set minterm (f = 1)= off-set minterm (f = 0)

Page 5: Logic Synthesis - UMass Amherst

Boolean Functions 5

On-set, Off-set, Tautology−

= = =

= = =

= ≡

= = ∅ ≡

= ∈

1 1

1 0

1

0 1

- The of is { | ( ) 1} (1)- The of is { | ( ) 0} (0)

- if , is the i.e. 1- if ( ), is

Onset Offset

tautology. not satisfyabl , i.e. 0

- if ( ) ( ) , te

hen a

n

n

n

f x f x f ff x f x f f

f B f ff B f f ff x g x for all x B f

1

nd - we say

are equiva instea

le

ntd of

gf f

- literals: A is a variable or its negation , and represents a logic l functioniteral x x

Literal x1 represents the logic function f, where f = {x| x1 = 1}Literal x1 represents the logic function g where g = {x| x1 = 0}

x1

x3

x2

f = x1

x1

x2

x3

f = x1

Notation: x’ = x

= on-set minterm (f = 1)= off-set minterm (f = 0)

Page 6: Logic Synthesis - UMass Amherst

Boolean Functions 6

Set of Boolean Functions

• There are 2n vertices in input space Bn

• There are 22ndistinct logic functions.

– Each subset of vertices is a distinct logic function: f ⊆ Bn

x1

x2

x3

• Truth Table or Function Table:X1x2x3 F

0 0 0 10 0 1 00 1 0 10 1 1 01 0 0 11 0 1 01 1 0 11 1 1 0

Page 7: Logic Synthesis - UMass Amherst

Boolean Functions 7

Boolean Operations - AND, OR, COMPLEMENT

Given two Boolean functions:f : Bn → Bg : Bn → B

• AND operationf ⋅ g = {x | f(x)=1 ∧ g(x)=1}

• The OR operationf + g = {x | f(x)=1 ∨ g(x)=1}

• The COMPLEMENT operation (^f or f’ )f’ = {x | f(x) = 0}

Page 8: Logic Synthesis - UMass Amherst

Boolean Functions 8

Cofactor and QuantificationGiven 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’

Page 9: Logic Synthesis - UMass Amherst

Boolean Functions 9

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?

Page 10: Logic Synthesis - UMass Amherst

Boolean Functions 10

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

Page 11: Logic Synthesis - UMass Amherst

Boolean Functions 11

Cubes• A cube is defined as the product (AND) of a set of literal

functions (“conjunction” of literals).Example:

C = x1x’2x3represents the following logic function

f = (x1=1)(x2=0)(x3=1)

Other examples of cubes:

x1

x2

x3

c = x1

x1

x2

x3

f = x1x2

x1

x2

x3

f = x1x2x3

= on-set minterm (f = 1)= off-set minterm (f = 0)

Page 12: Logic Synthesis - UMass Amherst

Boolean Functions 12

Set of Cubes – SoP vs Cover• A function can be represented by a sum of cubes:

f = ab + ac + bcSince 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: cover F of function f = set of implicants that cover all minterms of function f

• 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.

Page 13: Logic Synthesis - UMass Amherst

Boolean Functions 13

Cover minimization

c

a

bc ac

ab

b

= on-set minterm (f = 1)= off-set minterm (f = 0)= don’t care-set minterm (f = x)

• Two-level minimization seeks a minimum size cover (least number of cubes). Reason: minimize number of product terms in PLA

Note: each onset minterm is “covered” by at least one of the cubes and none of the offset minterms is covered.

Page 14: Logic Synthesis - UMass Amherst

Boolean Functions 14

PLAs - Multiple Output Functions• A PLA is a function f : Bn → Bm represented 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.

f2 f3f1

n=3, m=3

a a b b c c

abc f1f2f310- 1 - --11 1 - -0-0 - 1 -111 - 1 100- - - 1

Personality Matrix

AND plane

OR plane

Page 15: Logic Synthesis - UMass Amherst

Boolean Functions 15

Irredundant Cubes

bc ac

abc

a

b

bc

ac

not covered,so ab is irredundant

F \ {ab} ≠ f

• Definition: Let F = {c1, c2, …, ck} be a cover for f, i.e. f = ∑ik=1 ci

A cube ci∈ F is irredundant if F \ {ci} ≠ fA cover is irredundant if all its cubes are irredundant.

Example: f = ab + ac + bc

Page 16: Logic Synthesis - UMass Amherst

Boolean Functions 16

Prime, Essential, Irredundant

• Definition: A cube is prime if it is not contained in any other cube. A cover is prime if 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’ ∈ abcbut not in the other cubes

abc

bd

cdda

cb

abcdabcd’

Page 17: Logic Synthesis - UMass Amherst

Boolean Functions 17

Prime and Irredundant CoversExample: f = abc + b’d + c’d is prime and irredundant.

abc

bd

cdda

cb

abcdabcd’

• Why is abcd not an essential vertex of abc?• What is an essential vertex of abc?• What other cube is essential? What prime is not essential?

Page 18: Logic Synthesis - UMass Amherst

Boolean Functions 18

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 implicantsare defined similarly as for cubes.

Page 19: Logic Synthesis - UMass Amherst

Boolean Functions 19

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

Page 20: Logic Synthesis - UMass Amherst

Boolean Functions 20

Shannon (Boole) Cofactors

Let f : Bn → B be a Boolean function, and x= (x1, x2, …, xn) the variables in the support of f. The cofactor fa 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

f = x fx + x’ fx’

Page 21: Logic Synthesis - UMass Amherst

Boolean Functions 21

Generalized Cofactor

• The generalized cofactor fC of f by a cube C is f with the fixed values indicated by the literals of C,

• Eg. if C= x1 x’4 x6fC 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,x4 or x6 anymore(However, we still consider fC as a function of all n variables, it just happens to be independent of x1,x4 and x6).

• x1f ≠ fx1Example: f = ac + a’c , af = ac, fa=c

Page 22: Logic Synthesis - UMass Amherst

Boolean Functions 22

Cofactor of CoverDefinition:

The cofactor of a cover F 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.

( ) ( )j jx i x

iF x c= ∑

( ) { }ii j i

i i j

F x c c= = =∑ ∑∏{ c i }

Page 23: Logic Synthesis - UMass Amherst

Boolean Functions 23

Definition: The cofactor Cxj of a cube C with respect to a literal xj is• C if xj and x’j do not appear in C• C\{xj} if xj appears positively in C, i.e. xj∈C• ∅ 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 (x1 appears positively in C)Cx4 = ∅ (x4 appears negatively in C)

Example 2: F = abc + b’d + c’dFb = ac + c’d

(Just drop b everywhere and delete cubes containing literal b)

Cofactor of Cubes

Page 24: Logic Synthesis - UMass Amherst

Boolean Functions 24

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.

f

c

Page 25: Logic Synthesis - UMass Amherst

Boolean Functions 25

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 xi∉c and xi∉c,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’)=1Also, fc is independent of literals xi,xi ∈ c ⇒ fc(m’) = fc(m) = 0

⇒ fc(m’) c(m’)= 0contradicting c ⊆ cfc.

m

m= 000

m’= 101m’

C=xz

Page 26: Logic Synthesis - UMass Amherst

Boolean Functions 26

Application of Containment Test: c ⊆ F

Page 27: Logic Synthesis - UMass Amherst

ReduceSimilar to Expand, uses the containment check• This checks if cube C is redundant, can be removed• Note the same cube C in both places!

(F – C) C ≡ 1

ECE 667 - Espresso logic minimizer27

Page 28: Logic Synthesis - UMass Amherst

Boolean Functions 28

Extra slides

Page 29: Logic Synthesis - UMass Amherst

Boolean Functions 29

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

Page 30: Logic Synthesis - UMass Amherst

Boolean Functions 30

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)

1

1

1

1

1

1

1

1

Page 31: Logic Synthesis - UMass Amherst

Boolean Functions 31

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)

Page 32: Logic Synthesis - UMass Amherst

Boolean Functions 32

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’

1

X

1

X

1

X

X

1

X

XA

B

C

D

Page 33: Logic Synthesis - UMass Amherst

Boolean Functions 33

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