ECE 667 Synthesis and Verification of Digital Circuits Boolean Functions Basics

Post on 31-Dec-2015

38 views 0 download

description

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 - PowerPoint PPT Presentation

transcript

1Boolean Functions

ECE 667ECE 667Synthesis 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 2003Slides adopted (with permission) from A. Kuehlmann, UC Berkeley 2003

Boolean Functions 2

OutlineOutline• 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 3

The Boolean Space The Boolean Space BBnn

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

BB00

BB11

BB22

Karnaugh Maps: Boolean Spaces:

BB33

BB44

Boolean Functions 4

Boolean FunctionsBoolean 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,

ables

literals

1

n

nn i

n

f x B B

B

x x x x B x B

x x

x 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)

Boolean Functions 5

On-set, Off-set, TautologyOn-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 ( ) ( ) , t

e

hen a

n

n

n

f x f x f f

f x f x f f

f B f f

f B f f f

f x g x for all x B f1

nd

- we say

are equiva

instea

le

nt

d of

g

f 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)

Boolean Functions 6

Set of Boolean FunctionsSet of Boolean Functions

• 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

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

Boolean Functions 7

Boolean OperationsBoolean Operations - - AND, OR, COMPLEMENTAND, 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 8

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

Boolean Functions 9

Representations of Boolean FunctionsRepresentations 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 10

Boolean FormulaBoolean 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 = (x1x2) + (x3) + ^^(x4 (^x1))

typically the “” is omitted and the ‘(‘ and ‘^’ are simply reduced by priority, e.g.

f = x1x2 + x3 + x4^x1

Boolean Functions 11

CubesCubes

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

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)

Boolean Functions 12

Set of Cubes – SoP vs CoverSet 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: 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.

Boolean Functions 13

Cover minimizationCover 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.

Boolean Functions 14

PLAs - Multiple Output FunctionsPLAs - 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 f1f2f3

10- 1 - -

-11 1 - -

0-0 - 1 -

111 - 1 1

00- - - 1

Personality Matrix

AND plane

OR plane

Boolean Functions 15

Irredundant CubesIrredundant 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} f

A cover is irredundant if all its cubes are irredundant.

Example: f = ab + ac + bc

Boolean Functions 16

Prime, Essential, IrredundantPrime, 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’ abc but not in the other cubes

abc

bd

cdda

cb

abcdabcd’

Boolean Functions 17

Prime and Irredundant CoversPrime and Irredundant Covers

Example: 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?

Boolean Functions 18

ImplicantsImplicants

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

Quine’s TheoremQuine’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 20

Shannon (Boole) CofactorsShannon (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’

Boolean Functions 21

Generalized CofactorGeneralized 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 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,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 fx1

Example: f = ac + a’c , af = ac, fa=c

Boolean Functions 22

Cofactor of CoverCofactor of Cover

Definition: 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

i

F x c

( ) { }ii j i

i i j

F x c c { c i }

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. 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 (x1 appears positively in C)

Cx4 = (x4 appears negatively in C)

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

Fb = ac + c’d

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

Cofactor of CubesCofactor of Cubes

Boolean Functions 24

Fundamental TheoremFundamental 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.

ff

cc

Boolean Functions 25

Proof (cont.)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, fc is independent of literals xi,xi c fc(m’) = fc(m) = 0

fc(m’) c(m’)= 0

contradicting c cfc.

m

m= 000m’= 101

m’

C=xz

Boolean Functions 26

Application of Containment Test: Application of Containment Test: c F

Boolean Functions 27

Extra slidesExtra slides

Boolean Functions 28

Prime and Essential ImplicantsPrime 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 29

Essential Prime ImplicantsEssential 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

Boolean Functions 30

Don’t CaresDon’t Cares: Incompletely Specified Functions: 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 31

Incompletely Specified FunctionsIncompletely 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

Boolean Functions 32

Example with Don’t CaresExample 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