









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










ECE 474a/575a Susan Lysecky
1 of 49
Lecture 7
Logic Optimization
ECE 474a/575a Susan Lysecky 2 of 49
Delay – the time from inputs changing to new correct stable output Size – the number of transistors
Every gate has delay of “1 gate-delay”
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
Circuit with only two levels (ORed AND gates)
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
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...
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
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
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
Goal: circuit with only two levels (ORed AND gates), with minimum transistors Though transistors getting cheaper (Moore’s Law), they still cost something
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
Which “rules” to use and when? Easy to miss “seeing” possible opportunities to combine terms
a
Digital Design Copyright © 2006Frank Vahid
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
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
ECE 474a/575a Susan Lysecky
13 of 49
Groups of 1, 2 or 4
We can remove a variable
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
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
Remember, edges are adjacent Minterms differ in one variable only
3/5/7 doesn’t correspond to algebraic transformations that combine terms to eliminate a variable
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
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’
ECE 474a/575a Susan Lysecky 21 of 49
Four-Variable K-Maple Example - Continued
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
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
5 and 6 variable maps exist, but hard to use
Is error prone
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
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
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
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
Finite set of instructions/steps to solve a problem Terminates in finite time at a known end state
Optimality – “best” quality solution found Efficiency – “good” quality solution found fast
Finds optimal solution May not be efficient
Efficient Finds good solution, but not necessarily optimal
ECE 474a/575a Susan Lysecky 30 of 49
Quine-McCluskey Overview
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
product term whose literals include every variable of the function exactly once in true or complemented form
All minterms that define when F=
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
Any product term (minterm or other) that when 1 causes F= On K-map, any legal (but not necessarily largest) circle
Maximally expanded implicant – any further expansion would cover 1s not in on-set
The only prime implicant that covers a particular minterm in a function’s on-set
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
ECE 474a/575a Susan Lysecky
37 of 49
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 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
Quine-McCluskey – Example 1
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
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
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
Quine-McCluskey – Example 2
ECE 474a/575a Susan Lysecky 42 of 49
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
(2,9)? N (4,3)? N (4,6)? (4,6) 01-
no new implicants are generated – end of step 1
(2,3)?
(0,2)? (0,4) 0-
(0,4)?
(2,6)?
(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
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
P
P
P
P
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
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
ECE 474a/575a Susan Lysecky
49 of 49
Quine-McCluskey
Row vs. Column Dominance