38
1 ECE 667- Espresso logic minimizer ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization Heuristic Logic Optimization (Espresso) (Espresso)

1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

Embed Size (px)

Citation preview

Page 1: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

1ECE 667- Espresso logic minimizer

ECE 667ECE 667

Synthesis and Verificationof Digital Systems

Heuristic Logic Optimization Heuristic Logic Optimization (Espresso)(Espresso)

Page 2: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

2

OutlineOutline

• Two-level logic minimization– Heuristic logic optimizer Espresso

• Unate recursive paradigm– Unateness – Recursive optimization

• Single output optimization– Application of containment check

• Multiple output optimization– Generalization from single-output optimization– Concept of a characteristic function

Page 3: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

3

ESPRESSOESPRESSO – two-level logic optimizer – two-level logic optimizer

Page 4: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

4

Shannon ExpansionShannon Expansion

f : Bn BShannon Expansion:

Theorem: F is a cover of f. Then

F = x Fx + x’i Fx ‘

We say that f (F) is expanded about xi.

xi is called the splitting variable.

= +i i

ii x xf x f x f

Page 5: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

5

List of Cubes (Cover Matrix)List of Cubes (Cover Matrix)We often use matrix notation to represent a cover:

Example: F = ac + c’d + bcd’

a b c d a b c d a c 1 2 1 2 1 - 1 -

c’d 2 2 0 1 or - - 0 1bcd’ 2 1 1 0 - 1 1 0

• Each row represents a cube• 1 means that the positive literal appears in the cube • 0 means that the negative literal appears in the cube• The 2 (or -, don’t care) means that the variable does not appear in the

cube.• Finding factors from matrix representation is easy.

Page 6: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

6

Cover MatrixCover Matrix

Page 7: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

7

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

Page 8: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

8

Definition: A function f : Bn B is symmetric with respect to variables xi and xj iff

f(x1,…,xi,…,xj,…,xn) = f(x1,…,xj,…,xi,…,xn)

Definition: A function f : Bn B is totally symmetric iff any permutation of the variables in f does not change the function

Some Special FunctionsSome Special Functions

i j i jx x x xf f=Symmetry can be exploited in searching the binary decision tree

because:

- That means we can skip one of four sub-cases

- used in automatic variable ordering for BDDs

Page 9: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

9

Definition: A function f : Bn B is positive unate in variable xi iff

This is equivalent to monotone increasing in xi:

for all minterm pairs (m-, m+) where

For example, m-3=1001, m+

3=1011 (where i =3)

ii xxf f

f (m− )≤ f (m+ )

,

0

1

j j

i

i

m m j i

m

m

- +

-

+

= ¹

=

=

Unate FunctionsUnate Functions

Page 10: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

10

Similarly for negative unate

monotone decreasing:

A function is unate in xi if it is either positive unate or negative unate in xi.

Definition: A function is unate if it is unate in each variable.

Definition: A cover F is positive unate in xi iff xi cj for all cubes cjF

i ix xf f

f (m− )≥ f (m+ )

Unate FunctionsUnate Functions

Page 11: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

11

cb

a

mc+

mc-

f is positive unate in a,b :

f(ma+) f(ma

-)

f(mb+) f(mb

-)

and negative unate in c:

f(mc-) = 1 f(mc

+) = 0

f ab bc ac= + +

Example - unatenessExample - unateness

off

on

Minterms associated with c

mc- = (010) = 1

mc+ = (011) = 0

Page 12: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

12

The Unate Recursive ParadigmThe Unate Recursive Paradigm

• Key pruning technique based on exploiting the properties of unate functions– based on the fact that unate leaf cases can be solved

efficiently

• New case splitting heuristic– splitting variable is chosen so that the functions at

lower nodes of the recursion tree become unate

Page 13: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

13

Unate covers F have many extraordinary 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 (constant 1).

– Positive unate: f = x fx + fx’

– Negative unate: f = fx + x’fx’

This type of implicit enumeration applies to many sub-problems (prime generation, reduction, complementation, etc.).

The Unate Recursive ParadigmThe Unate Recursive Paradigm

Page 14: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

14

Unate Recursive ParadigmUnate Recursive Paradigm

• Create cofactoring tree stopping at unate covers – choose, at each node, the “most binate” variable for splitting– recurse until no binate variable left (unate leaf)

• “Operate” on the unate cover at each leaf to obtain the result for that leaf. Return the result

• At each non-leaf node, merge (appropriately) the results of the two children.

• Main idea: Operation on unate leaf is computationally less complex• Operations: complement, simplify, tautology, generate-primes,...etc.

a

cbmerge

Page 15: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

15

Two Useful Theorems - TautologyTwo Useful Theorems - Tautology

Theorem 1:

Checking for tautology is simplified for unate functions

– Positive unate (f = x fx + fx’ ) f 1 fx’ = 1

– Negative unate (f = fx + x’fx’) f 1 fx = 1

Theorem 2: Let A be a unate cover matrix.

Then A 1 if and only if A has a row of all “-”s.Proof:

If. A row of all “-”s is the tautology cube.

Only if. Assume no row of all “-”s. Without loss of generality, suppose function is positive unate. Then each row has at least one “1” in it. Consider the point (0,0,…,0). This is not contained in any row of A. Hence A¹1.

1 ( 1) ( 1)j jx x

F F F

Page 16: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

16

Recursive Tautology – termination rulesRecursive Tautology – termination rules

Page 17: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

17

Recursive Tautology - exampleRecursive Tautology - example

Page 18: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

18

Recursive Complement OperationRecursive Complement Operation

x xf x f x f= +

0

1

x x

x x

g x f x f

f x f x f

f gg f

f g

= + = +

= =+ =

Theorem:

Proof:

Page 19: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

19

COMPLEMENT OperationCOMPLEMENT Operation

Algorithm COMPLEMENT(List_of_Cubes C) {

if(C contains single cube c) {

Cres = complement_cube(c) // generate one cube per

return Cres // literal l in c with ^l

}

else {

xi = SELECT_VARIABLE(C)

C0 = COMPLEMENT(COFACTOR(C,^xi)) Ù ^xi

C1 = COMPLEMENT(COFACTOR(C,xi)) Ù xi

return OR(C0,C1)

}

}

Page 20: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

20

Recursive Complement – termination rulesRecursive Complement – termination rules

Page 21: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

21

Recursive Complement – example (split)Recursive Complement – example (split)

Page 22: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

22

Recursive Complement – example (merge)Recursive Complement – example (merge)

Page 23: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

23

Incompletely Specified Boolean FunctionsIncompletely Specified Boolean Functions

F = (f, d, r) : Bn {0, 1, *}where * represents a don’t care.

• f = onset function - f(x)=1 F(x)=1 • r = offset function - r(x)=1 F(x)=0 • d = don’t care function - d(x)=1 F(x)=*

(f,d,r) forms a partition of Bn, i.e.• f + d + r = Bn

• fd = fr = dr = (pairwise disjoint)

Page 24: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

24

A completely specified Boolean function g is a cover for F = (f,d,r) if

f g f+dNote: • g r = • if xd , then g(x) = 0 or 1 (don’t care)• if xf , then g(x)=1 • if xr , then g(x)=0.

Also: r = f’d’ g’ f’

Incompletely Specified Boolean FunctionsIncompletely Specified Boolean Functions

fd

r

Page 25: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

25

ESPRESSO – 2-level logic optimizerESPRESSO – 2-level logic optimizer

Page 26: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

26

Example: Logic Minimization (single output)Example: Logic Minimization (single output)

Consider F(a,b,c)=(f,d,r), where f={abc, abc, abc} and d ={abc, abc}, and the sequence of covers illustrated below:

abc is redundanta is prime F3= a+abc

Expand abc bc

Expand abc a

F2= a+abc + abc

F4= a+bc

off

on

Don’t care

F1= abc + abc+ abc

c

ba

Page 27: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

27

Two-level minimization (multiple-outputs)Two-level minimization (multiple-outputs)

Initial representation: a b c

0 – 0

0 1 –

– 1 1

1 – 1

f1 f2

0 1

0 1

1 0

1 0

000 100

110010

111011

001

000 100

110010

111011

001

f1f2

101 101

f1 f2

000 100

110010

111011

001

000 100

110010

111011

001101 101

a b c

0 – 0

0 1 1

1 – 1

f1 f2

0 1

1 1

1 0

Minimized cover:

c

ba

Page 28: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

28

ESPRESSO IllustratedESPRESSO Illustrated

REDUCE

EXPAND

IRREDUNDANT

minimum Local

minimum Local

Page 29: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

29

REDUCEREDUCE

Problem: Given a cover F and c F, find the smallest cube c c such that

F\{ c } + { c }

is still a cover. Cube c is called the maximally reduced cube of c.

offoff

onon

Don’t Don’t carecareGOODBAD

REDUCE isorder dependent

Page 30: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

30

Expand and Reduce Expand and Reduce

• Fundamental procedures of Espresso

Page 31: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

31

Validity of expansionValidity of expansion

• Containment check: is the expanded cube contained in F ?

Page 32: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

32

Expand - exampleExpand - example

• Validity of expansion

Page 33: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

33

ReduceReduce

Transform a cover of prime implicants:• Replace each prime implicant p, wherever possible, with a smaller,

non-prime implicant contained by p.• Purpose of Reduce: iterative improvement• Moves function away from local minimum

– The subsequent Expand may be able to find a better set of primes

• Similar to Expand, uses the same containment check

Page 34: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

34

Single output functionSingle output function

1. Expand input part: (0 0 0 | 1) (0 - 0 | 1)

Check if (f – a’b’c’)a'’bc’ = 1

2. Reduce output part:

(0 1 - | 1) (0 1 - | 0)

(remove the cube)

Check if (f – a’b)a'’b = 1

Page 35: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

35

Multiple output function - expandMultiple output function - expand

• Expand output part: (0 - 1 | 1 0) (0 - 1 | 1 1)

C = 0-1| 10, C~= 0-1|01 Check if (f – {0-1|10})0-1|01 = 1

Page 36: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

36

Multiple output function – remove redundancyMultiple output function – remove redundancy

• Remove redundant cube: (0 0 - | 0 1) (0 0 - | 0 0)

C = 00-|01 , C~= 00-|00 Check if (f – {00-|01})00-|01 = 1

Page 37: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

37

Multiple output function – summaryMultiple output function – summary

Page 38: 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Heuristic Logic Optimization (Espresso)

ECE 667- Espresso logic minimizer

38

How to Expand and ReduceHow to Expand and Reduce