Docsity

Logic Optimization in Digital Design: Quine-McCluskey and Petrick's Method - Prof. Susan L, Study notes of Electrical and Electronics Engineering

Toggle sidebar
bg1
1
ECE 474a/575a
Susan Lysecky 1of 49
ECE 474A/57A
Computer-Aided Logic Design
Lecture 7
Logic Optimization
ECE 474a/575a
Susan Lysecky 2of 49
We now know how to build digital
circuits
How can we build
better
circuits?
Let’s consider two important design
criteria
Delay – the time from inputs changing
to new correct stable output
Size – the number of transistors
Assumption
Every gate has delay of “1 gate-delay”
Every gate
input
requires 2 transistors
Ignore inverters
16 transistors
2 gate-delays
F1
w
x
y
w
x
y
F1 = wxy+ wxy’
4 transistors
1 gate-delay
F2 = wx
F2
w
x
= wx(y+y’) = wx
Transforming F1 to F2 represents an
optimization: Better in all criteria of interest
20
15
10
5
F1
F2
1234
delay (gate-delays)
size
(transistors)
Digital Design
Copyright ©2006
Frank Vahid
Logic Optimization
ECE 474a/575a
Susan Lysecky 3of 49
Two-level logic
Circuit with only two levels (ORed AND
gates)
Basically sum-of-products form
An equation written as an ORing of
product terms F = xy+ x’y’
F
x
y
x’
y’
F = a’bc+ c’ + de
F
a’
c
d
e
b
c’
F = ((jk) + l) + mn’
F
j
k
m
n’
l
Are these two-level logic?
F = (rs) • (tu)
F
r
s
t
u
technically yes, but not what we mean
in terms of logic minimization
Two-level Logic Optimization
Digital Design
Copyright ©2006
Frank Vahid
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Logic Optimization in Digital Design: Quine-McCluskey and Petrick's Method - Prof. Susan L and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

ECE 474a/575a Susan Lysecky

1 of 49

ECE 474A/57A

Computer-Aided Logic Design

Lecture 7

Logic Optimization

ECE 474a/575a Susan Lysecky 2 of 49

ƒ We now know how to build digital

circuits

ƒ How can we buildbetter circuits?

ƒ Let’s consider two important design

criteria

ƒ Delay – the time from inputs changing to new correct stable output ƒ Size – the number of transistors

ƒ Assumption

ƒ Every gate has delay of “1 gate-delay”

ƒ Every gateinput requires 2 transistors

ƒ Ignore inverters

16 transistors 2 gate-delays F

wx y wx y F1 = wxy + wxy’

4 transistors 1 gate-delay

F2 = wx

F w x

= wx(y+y’) = wx

Transforming F1 to F2 represents an optimization : Better in all criteria of interest

20 15 10 5

F

F 1 2 3 4 delay (gate-delays)

size (transistors)

Digital Design Copyright © 2006Frank Vahid

Logic Optimization

ECE 474a/575a Susan Lysecky 3 of 49

ƒ Two-level logic

ƒ Circuit with only two levels (ORed AND gates)

ƒ Basically sum-of-products form

ƒ An equation written as an ORing of product terms (^) F = xy + x’y’

F

x y x’ y’

F = a’bc + c’ + de

F

a’ c d e

b c’

F = ((jk) + l) + mn’

F

j k m n’

l

Are these two-level logic?

F = (rs) • (tu)

F

r s t u

technically yes, but not what we mean in terms of logic minimization

Two-level Logic Optimization

Digital DesignCopyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

4 of 49

ƒ Optimization - Defined as better in all criteria of interest

ƒ Delay and size - we consider size minimization only (2-level logic only) ƒ In reality requires a balance of many criteria metrics ƒ Cost, reliability, time-to-market, etc...

ƒ Tradeoff - Improves some, but worsens other, criteria of interest

F = xy + x’y’

F

x y x’ y’

F = xyz + xyz’ + x’y’z’ + x’y’z

F

x

x’ x’

x’

y

y’ y’

y’

z

z’ z’

z’

Optimization vs. Tradeoff

14 transistors 2 gate-delays

12 transistors 3 gate-delays G

w x y z

G2 = w(x+y) + z

G

w x

w y z G1 = wx + wy + z

32 transistors 2 gate-delays

12 transistors 2 gate-delays

ƒ Reduced number of gates ƒ Reduced size of gate (i.e. number of inputs)

ƒ Reduced number of gates ƒ Increased delay

Digital Design Copyright © 2006Frank Vahid

ECE 474a/575a Susan Lysecky 5 of 49

Pareto Points

Optimizations

Tradeoffs

All criteria of interest are improved (or at least kept the same)

Some criteria of interest are improved, while others are worsened

delay

size

Digital Design Copyright © 2006Frank Vahid

size

delay

delay

ƒ We obviously prefer optimizations, but

often must accept tradeoffs

ƒ You can’t build a car that is the most comfortable, and has the best fuel efficiency, and is the fastest – you have to give up something to gain other things

ƒ Many options in solution space

ƒ Pareto point ƒ Point in solution space in which no other point better in all metrics ƒ Shown in red ƒ Pareto points yield the trade-off curve

size

ECE 474a/575a Susan Lysecky 6 of 49

ƒ Two-level size optimization using algebraic

methods

ƒ Goal: circuit with only two levels (ORed AND gates), with minimum transistors ƒ Though transistors getting cheaper (Moore’s Law), they still cost something

ƒ Define problem algebraically

ƒ Sum-of-products yields two levels ƒ F = abc + abc’ is sum-of-products; G = w(xy + z) is not. ƒ Transform sum-of-products equation to have fewest literals and terms ƒ Each literal and term translates to a gate input, each of which translates to about 2 transistors ƒ Ignore inverters for simplicity

F = xyz + xyz’ + x’y’z’ + x’y’z F = xy(z + z’) + x’y’(z + z’) F = xy1 + x’y’ F = xy + x’y’**

F

x y x’ y’

m

n

= 6 gate inputs * 2 transistor/input = 12 transistors

Example

Combinational Logic Optimization and Tradeoffs

Digital DesignCopyright © 2006 Frank Vahid

ECE 474a/575a Susan Lysecky

10 of 49

Algebraic Two-Level Size Minimization Complex and Error Prone

ƒ Algebraic Manipulation

ƒ Which “rules” to use and when? ƒ Easy to miss “seeing” possible opportunities to combine terms

a

Digital Design Copyright © 2006Frank Vahid

F(a, b, c, d) = a’b’cd + c’d + ab’d + acd + a’bcd + a’c’d

F(a, b, c, d) = d

F(a, b, c) = b’c’ + bc + a’b’ + a’b

F(a, b, c) = b’c’ + bc + a’b’

F(a, b, c, d, e, f, g) = a’b’c + d’e’f + fa + eg + a’bcd’e’f’g + a’bc’efg + c

F(a, b, c, d, e, f, g) =?

ECE 474a/575a Susan Lysecky 11 of 49

0 0 0 0

00 01 11 10

1 1

0 1 0 0

F yz x

xy’

0 1 1 0

00 01 11 10

0 1

0 1 1 0

G yz x

z

0 0 1 0

00 01 11 10

1 1

00 01 1 0 0 0 1 0 0 0

11 10 1 0

H yz wx

yz

w’xy’

K-maps (Karnaugh Maps)

ƒ Graphical method to help us find

opportunities to combine terms

ƒ Graphical method to help us find opportunities to combine terms

ƒ Create map whereadjacent minterms

differ in one variable ƒ Can clearly see opportunities to combine terms – look for adjacent 1s

ECE 474a/575a Susan Lysecky 12 of 49

Example: Minimize G = a + a’b’c’ + b*(c’ + bc’)

Step 3 - Cover 1s

Step 4 - OR terms

Step 1 - Convert to sum-of-products

Step 2 - Place 1’s in the appropriate cells

G = a + a’b’c’ + bc’ + bc’

G = a + c’

a

bc’ 1 a’b’c’ 1 1 1 1

G (^) bc a

1 0 0 1

00 01 11 10

1 1

0

1 1 1

G (^) bc a

a

c’

Two-Level Size Minimization Using K-maps

General K-map method

  1. Convert the function’s equation into sum- of-products form
  2. Place 1s in the appropriate K-map cells for each term
  3. Cover all 1s by drawing the fewest largest circles, with every 1 included at least once; write the corresponding term for each circle
  4. OR all the resulting terms to create the minimized function.

ECE 474a/575a Susan Lysecky

13 of 49

ƒ Fill in each cell with corresponding value of F

ƒ Draw circles around adjacent 1’s

ƒ Groups of 1, 2 or 4

ƒ Circle indicates optimization opportunity

ƒ We can remove a variable

ƒ To obtain function OR all product terms contained in

circles

ƒ Make sure all 1’s are in at least one circle

x1 x2 F 0 0 0 1 1 0 1 1

x

x

x1’x2’ + x1x2’ x2’(x1’ + x1) x2’(1) x2’

x1x2’ + x1x x1(x2’ + x2) x1(1) x

F = x1 + x2’

Two-Variable K-Maple Example

ECE 474a/575a Susan Lysecky 14 of 49

Generalized Three-Variable K-Map

ƒ Three-Variable Map

a b F

Truth table

c m m m m m m m m

Truth table

a

bc

m0 m m4m

m3 m m6m

m1 cannot be placed next to m2 (a’b’c, a’bc’)

REMEMBER: K-map graphically place minterms next to each other when they differ by one variable

m1 can be placed next to m3 (a’b’c, a’bc) m2 can be placed next to m3 (a’bc’, a’bc)

ECE 474a/575a Susan Lysecky 15 of 49

Three-Variable K-Map Optimization Guidelines

ƒ Circles can cross left/right sides

ƒ Remember, edges are adjacent ƒ Minterms differ in one variable only

ƒ Circles must have 1, 2, 4, or 8 cells – 3, 5, or 7

not allowed

ƒ 3/5/7 doesn’t correspond to algebraic transformations that combine terms to eliminate a variable

ƒ Circling all the cells is OK

ƒ Function just equals 1

(^1 1 1 1 )

E (^) yz x

K (^) yz x

xz’

x’y’z

L (^) yz x

ECE 474a/575a Susan Lysecky

19 of 49

Four-Variable K-Maple Example

c 00 01 11 10 00

01

11

10

H d ab

ƒ Minimize: H = a’b’(cd’ + c’d’) + ab’c’d’ + ab’cd’ + a’bd + a’bcd’

1. Convert to sum-of-products

H = a’b’cd’ + a’b’c’d’ + ab’c’d’ +

ab’cd’ + a’bd + a’bcd’

ECE 474a/575a Susan Lysecky 20 of 49

Four-Variable K-Maple Example - Continued

c 00 01 11 10 00

01

11

10

H (^) d ab

0 0

0

0 0 0 0

0 0

a’b’c’d’

ab’c’d’

a’bd

a’b’cd’

(^1) ab’cd’

a’bcd’

ƒ Minimize: H = a’b’(cd’ + c’d’) + ab’c’d’ + ab’cd’ + a’bd + a’bcd’

1. Convert to sum-of-products

H = a’b’cd’ + a’b’c’d’ + ab’c’d’ +

ab’cd’ + a’bd + a’bcd’

2. Place 1s in K-map cells

ECE 474a/575a Susan Lysecky 21 of 49

Four-Variable K-Maple Example - Continued

ƒ Minimize: H = a’b’(cd’ + c’d’) + ab’c’d’ + ab’cd’ + a’bd + a’bcd’

1. Convert to sum-of-products

H = a’b’cd’ + a’b’c’d’ + ab’c’d’ +

ab’cd’ + a’bd + a’bcd’

2. Place 1s in K-map cells

3. Cover 1s

a’bd

a’bc

c 00 01 11 10 00

01

11

10

H d ab

0 0

0

0 0 0 0

0 0

Funny-looking circle, but remember that left/right adjacent, and top/bottom adjacent

b’d’

ECE 474a/575a Susan Lysecky

22 of 49

Four-Variable K-Maple Example - Continued

H = b’d’ + a’bc + a’bd

ƒ Minimize: H = a’b’(cd’ + c’d’) + ab’c’d’ + ab’cd’ + a’bd + a’bcd’

1. Convert to sum-of-products

H = a’b’cd’ + a’b’c’d’ + ab’c’d’ +

ab’cd’ + a’bd + a’bcd’

2. Place 1s in K-map cells

3. Cover 1s

4. OR resulting terms

a’bd

a’bc

c 00 01 11 10 00

01

11

10

H d ab

0 0

0

0 0 0 0

0 0

b’d’

ECE 474a/575a Susan Lysecky 23 of 49

Larger N-Variable K-Maps

ƒ Graphical minimizing by hand

ƒ 5 and 6 variable maps exist, but hard to use

ƒ May not yield minimum cover depending on

order we choose

ƒ Is error prone

ƒ Minimization thus typically done by automated

tools

ab

cd 00 01 11 10 00 01

m0 m m4m

m3 m m7m 11 10

m12 m m8m

m15 m m11m

ab

cd 00 01 11 10 00 01

m16 m m20m

m19 m m23m 11 10

m28 m m24m

m31 m m27m

e = 0 e = 1

Five-variable Map

Six-variable Map

ab

cd 00 01 11 10 00 01

m0 m m4m

m3 m m7m 11 10

m12 m m8m

m15 m m11m

ab

cd 00 01 11 10 00 01

m16 m m20m

m19 m m23m 11 10

m28 m m24m

m31 m m27m ef = 00 ef = 01

ab

cd 00 01 11 10 00 01

m32 m m36m

m35 m m39m 11 10

m44 m m40m

m47 m m43m

ab

cd 00 01 11 10 00 01

m48 m m52m

m51 m m55m 11 10

m60 m m56m

m63 m m59m ef = 10 ef = 11

ECE 474a/575a Susan Lysecky 24 of 49

Don’t Care Input Combinations

x 0 0 0

00 01 11 10

1 1

0

1 x 1

G (^) bc a

a

a b c Z 0 0 0 x 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 x

abc = 000 and abc = 111 are unused inputs

including this term doesn’t help us

including this term enables better minimization

ƒ Don’t Care Input

ƒ Input combination that the designer doesn’t care what the output is ƒ i.e. input condition can never occur ƒ Thus, make output be 1 or 0 for those cases in a way that best minimizes the equation ƒ Represented as X s in K-map

ECE 474a/575a Susan Lysecky

28 of 49

Four-Variable K-Maple Example

ƒ F(a, b, c, d) = ∑m(4, 5, 11, 15)

ƒ Don’t forget in 4-variable K-map, columns and rows are out of sequence too (00, 01, 11, 10)

c

00 01 11 10

00

H d ab

c d F 0 1 0 1 0 1 0 1

b 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

a 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

8 9 11 10

12 13 15 14

4 5 7 6

0 1 3 2

ECE 474a/575a Susan Lysecky 29 of 49

Exact Algorithms vs. Heuristic

ƒ Algorithm

ƒ Finite set of instructions/steps to solve a problem ƒ Terminates in finite time at a known end state

ƒ Many algorithms can exist that solve the same problem

ƒ What makes one algorithm better than another?

ƒ Optimality – “best” quality solution found ƒ Efficiency – “good” quality solution found fast

ƒ Exact Algorithm

ƒ Finds optimal solution ƒ May not be efficient

ƒ Heuristic

ƒ Efficient ƒ Finds good solution, but not necessarily optimal

ECE 474a/575a Susan Lysecky 30 of 49

Quine-McCluskey Overview

ƒ Exact Algorithm

ƒ Developed in the mid-50’s

ƒ Finds the minimized representation of a Boolean function

ƒ Provides systematic way of generating all prime implicants then extracting a minimum set

of primes covering the on-set

ƒ Accomplishes this by repeatedly applying the Uniting theorem

ƒ Uniting theorem: ab + ab’ = a(b+b’) = a*1 = a

ECE 474a/575a Susan Lysecky

31 of 49

F(a, b, c) = a’b’c + ab

literals: a, b, c

on-set: a’b’c, abc’, abc

minterms: a’b’c

off-set: a’b’c’, a’bc’, a’bc, ab’c’, ab’c

ab abc abc’

Review Definitions

ƒ Minterm

ƒ product term whose literals include every variable of the function exactly once in true or complemented form

ƒ On-set

ƒ All minterms that define when F=

ƒ Off-set

ƒ All minterms that define when F=

ECE 474a/575a Susan Lysecky 32 of 49

Note: We use K-maps are for illustration purposes only

G bc a

a’b’ ab

4 prime implicants 2 essential prime implicants

F bc a

ab

abc’

abc

a’b’c (^) 4 implicants

F bc a

ab

a’b’c (^) 2 prime Implicants

Review Definitions

ƒ Implicant

ƒ Any product term (minterm or other) that when 1 causes F= ƒ On K-map, any legal (but not necessarily largest) circle

ƒ Prime implicant

ƒ Maximally expanded implicant – any further expansion would cover 1s not in on-set

ƒ Essential prime implicant

ƒ The only prime implicant that covers a particular minterm in a function’s on-set

ƒ Importance: We must include all essential PIs

in a function’s cover ƒ In contrast, some, but not all, non-essential PIs will be included

ECE 474a/575a Susan Lysecky 33 of 49

Quine-McCluskey Algorithm

1. Find all the prime implicants

2. Find all the essential prime implicants

3. Select a minimal set of remaining prime implicants that covers the on-set of the

function

ECE 474a/575a Susan Lysecky

37 of 49

Step 2: Find all essential prime implicants (cont’)

ƒ Place “X” in a row if the prime implicant covers the minterm ƒ Essential prime implicants are found by looking for rows with a single “X” ƒ If minterm is covered by one and only one prime implicant – it’s an essential prime implicant ƒ Add essential prime implicants to the cover

essential prime implicants Cover: F = a’b’ + ab

Quine-McCluskey – Example 1

ECE 474a/575a Susan Lysecky 38 of 49

Cover: F = a’b’ + ab

Quine-McCluskey – Example 1

Step 3: Select a minimal set of remaining prime implicants that covers the on

set of the function

ƒ Step 2 determined essential prime implicants, and added to cover ƒ Essential prime implicants may cover other minterms, cross out all minterms covered by the prime implicants ƒ Minterm only needs to be covered once

ECE 474a/575a Susan Lysecky 39 of 49

Cover: F = a’b’ + ab

Only minterm 5 remains – either prime implicant (1,5) or (5,7) will work

  • b’c

Quine-McCluskey – Example 1

Step 3: Select a minimal set of remaining prime implicants that covers the on

set of the function (cont’)

ƒ Based on which minterms are left, add minimal set of prime implicants to cover

ECE 474a/575a Susan Lysecky

40 of 49

Quine-McCluskey – Example 1

ƒ Summary

ƒ Is this an optimal solution? ƒ YES. ƒ We generate all the minterms and make sure they are all covered by the prime implicants

ƒ Is the solution unique? ƒ NOT NECESSARILY. ƒ There could be different sets of minimum covers.

ECE 474a/575a Susan Lysecky 41 of 49

Minimize F = w’x’y’z’ + w’x’yz + w’x’yz’ + w’xy’z’ + w’xyz + w’xyz’ + wxy’z + wxyz + wx’y’z +

wx’yz

Step 1: Find all the prime implicants

ƒ List all elements of on-set and don’t care set, represented as a binary number ƒ Group minterms according to the number of 1’s in the minterm

w’xyz’ (6) 0110 wxy’z (13) 1101 wxyz (^) (15) 1111 wx’y’z (^) (9) 1001 wx’yz (^) (11) 1011

w’x’y’z’ (0) 0000 w’x’yz (3) 0011 w’x’yz’ (^) (2) 0010 w’xy’z’ (^) (4) 0100 w’xyz (^) (7) 0111

G

G

G

G

G

Quine-McCluskey – Example 2

ECE 474a/575a Susan Lysecky 42 of 49

Step 1: Find all the prime implicants (cont’)

ƒ Compare each entry in Gi to each entry in Gi+ ƒ If they differ by 1 bit, we can apply the uniting theorem and eliminate a literal ƒ Add check to minterm/implicant to remind us that it is not a prime implicant

G

G

G

G

G

(2,9)? N (4,3)? N (4,6)? (4,6) 01-

no new implicants are generated – end of step 1

G1 (2,3) 001-

(2,3)?

G0 (0,2) 00-

(0,2)? (0,4) 0-

(0,4)?

(2,6)?

G

G

G

G

G2 (3,7) 0-

(4,9)? N (3,7)? (3,11)? (3,13)? N (6,7)? (6,11)? N (6,13)? N (9,7)? N (9,11)? (9,13)? (7,15)? (11,15)? (13,15)?

Quine-McCluskey – Example 2

ECE 474a/575a Susan Lysecky

46 of 49

Cover: F = w’yz’ + x’y’z

Quine-McCluskey – Example 3 Petrick’s Method

ƒ Example 3 (cont’)

ƒ Remove minterms covered by prime implicants ƒ Leaves 3 minters – m7, m13, and m ƒ Which remaining prime implicants should we use to obtain the minimum cover?

ECE 474a/575a Susan Lysecky 47 of 49

  1. Reduce prime implicant chart by eliminating prime implicant rows and corresponding columns
  2. Label rows of reduced prime implicant chart P1, P2 …
  3. Form logical equation which is true when all columns are covered
  4. Reduce to minimum sum of products by multiplying out and applying X + XY = X
  5. Each term in solution represents a covering solution
    • Count number of terms in each, choose one corresponding to the minimum number

P

P

P

P

Petrick’s Method – used to determine minimum cover

P = (P1 + P3)(P2 + P4)(P3 + P4)

P = (P1 + P3)(P2P3 +P2P4 +P4P3 + P4P4)

P = (P1 + P3)(P2P3 +P2P4 +P4P3 + P4)

P4P4 = P

P4 + P4P3 = P

P = (P1 + P3)(P2P3 +P2P4 +P4)

P = (P1 + P3)(P2P3 + P4)

P4 + P2P4 = P

P3P2P3 = P2P

P = P1P2P3 + P1P4 + P3P2P3 + P3P

P = P1P2P3 + P1P4 + P2P3 + P3P

Any of these provide minimum cover

more terms than other solutions

(2,6) 0-

(9, 13) 10-

(8,9) - (6,7) 011-

(13, 15) 1-

(7, 15) -

Quine-McCluskey – Example 3

Petrick’s Method

Actually - P1P2P3 + P2P3 = P2P3, so we can eliminate term altogether

ECE 474a/575a Susan Lysecky 48 of 49

(2,6) 0-

P2 (9, 13) 10-

(8,9) - P1 (6,7) 011-

P4 (13, 15) 1-

P3 (7, 15) - Minimum prime implicant cover list: (option 1 - P1P4) w’xy,wyz (option 2 - P2P3) wx’z, xyz (option 3 - P3P4) xyz, wyz

Minimized Equation F = w’yz’ + x’y’z + xyz + wyz

P = P1P4 + P2P3 + P3P

Any of these provide minimum cover (equal number of “circles”)

w’yz’, x’y’z

Essential Prime Implicants

Quine-McCluskey – Example 3

Petrick’s Method

ƒ Final cover = essential prime implicants +

minimum prime implicant cover

ECE 474a/575a Susan Lysecky

49 of 49

Quine-McCluskey

ƒ What about don’t cares?

ƒ Alternative methods to determine Minimum Cover

ƒ Row vs. Column Dominance