Lecture 5
Lecture 5
Circuit Optimization
Chapter 3
Circuit Optimization
3
3
Literal Cost
Example 1:
F = A + BC + BC L=5
G = L+ 2= 7
B GN = G + 2 = 9
C
A F
Example 2: A
B
F = A B C + AB C C
L = 6 G = 8 GN = 11 F
F = (A + C)( B + C)( A + B)
L = 6 G = 9 GN = 12
Same function and same A
literal cost B
But first circuit has better C
gate input count and better F
gate input count with NOTs
Select it!
7
7
Boolean Function Optimization
Minimizing the gate input (or literal) cost of a (a
set of) Boolean equation(s) reduces circuit cost.
We choose gate input cost.
Boolean Algebra and graphical techniques are
tools to minimize cost criteria values.
Some important questions:
• When do we stop trying to reduce the cost?
• Do we know when we have a minimum cost?
Methods
• Karnaugh Maps (K-map)
• Quine-McCluskey
8
8
Optimization Example
f(x1,x2,x3,x4)=m(1,3,5,6,7,8,12,14,15)
f(x1,x2,x3,x4)=x1x2x3x4+x1x2x3x4+
x1x2x3x4+x1x2x3x4+x1x2x3x4+x1x2x3x4
+x1x2x3x4+x1x2x3x4+x1x2x3x4
10
Two variable: x ve y
• 4 minterms:
m0 = x’y’ 00
m1 = x’y 01
m2 = xy’ 10
m3 = xy 11
y y
x 0 1 x 0 1
0 m0 m1 0 x’y’ x’y
1 m2 m3 1 xy’ xy
12
12
F( x, y ) = x y + x y = x
14
14
15
15
3-Variable Karnaugh Map
yz
x 00 01 11 10
0 m0 m1 m3 m2
1 m4 m5 m7 m6
16
16
yz y
x y y yz
x 00 01 11 10
x 0 1 3 2
0 0 1 3 2
x 4 5 7 6
x 1 4 5 7 6
z z z
z
17
17
Combining Squares
• By combining squares, we reduce number of literals in a
product term, reducing the literal cost, thereby reducing the
other two cost criteria
• On a 3-variable K-Map:
– One square represents a minterm with three variables
– Two adjacent squares represent a product term with two
variables
– Four “adjacent” terms represent a product term with one
variable
– Eight “adjacent” terms is the function of all ones (no variables)
= 1.
18
18
4 5 7 6
1
19
19
3-Variable Karnaugh Map
Example Shapes of 4-cell Rectangles:
yz
x 00
0
01
1
11
3
10
2
0
4 5 7 6
x
1
20
20
F = m(2,3,6,7) y
0 1 3 2
1 1
• Example: Let
x 4 5 7
1 6
1
z
• Applying the Minimization Theorem three times:
F( x, y , z ) = x y z + x y z + x y z + x y z
= yz + y z
=y
• Thus the four terms that form a 2 × 2 square
correspond to the term "y".
21
21
Example: 3-Variable Karnaugh Map
F1(x, y, z) = (2, 3, 4, 5)
yz
x 00 01 11 10
0 0 0 1 1
1 1 1 0 0
F1(x, y, z) = (0, 2, 4, 5, 6) y
yz
x 00 01 11 10
0 1 0 0 1
x 1 1 1 0 1
z
F1(x, y, z) =z+yx
23
23
3-Variable Map Simplification
F = Z’ + X’ Y’ + X Y
24
24
4 variables: w, x, y, z
• 16 minterms
y
yz
wx 00 01 11 10
00 m0 m1 m3 m2
01 m4 m5 m7 m6
x
11 m12 m13 m15 m14
w
10 m8 m9 m11 m10
z
25
25
4-Variable Terms
26
26
4-Variable Maps
4 5 7 6
12 13 15 14 X
W
8 9 11 10
Z
27
27
4-Variable Maps
yz Y
wx
0 1 3 2
4 5 7 6
X
12 13 15 14
W
8 9 11 10
Z
28
28
Example:
F(w,x,y,z) = (0, 1, 2, 4, 5, 6, 8, 9, 12, 13, 14)
yz
wx 00 01 11 10
00 1 1 0 1
01 1 1 0 1
11 1 1 0 1
10 1 1 0 0
29
29
Example:
F(w,x,y,z)=w’x’y’+x’yz’+w’xyz’+wx’y’
yz
wx 00 01 11 10
00 1 1 0 1
01 0 0 0 1
11 0 0 0 0
10 1 1 0 1
• F(w,x,y,z) =x’z’+y’x’+w’yz’
30
30
Example: f(w,x,y,z)=M(1,4,5,8,11,12,14)
yz
wx 00 01 11 10
00 1 0 1 1
01 0 0 1 1
11 0 1 1 0
10 0 1 0 1
32
32
Systematic Simplification
33
33
Example of Prime Implicants
BD 1 1 BD 1 1
B B
1 1 1 1
A A
1 1 1 1 1 1 1 1
AB
D D
AD Minterms covered by single prime implicant
BC
34
34
Prime Implicants
Find all essential prime implicants for
F(A, B, C, D) = m(0,2,3,8,9,10,11,12,13,14,15)
CD C
AB
0 1 3 2
1 1 1
4 5 7 6
B
12 13 115 1 14
1 1
A
8 9 11 10
1 1 1 1
D
35
35
Five Variable or More K-Maps
For five variable problems, we use two adjacent K-maps.
It becomes harder to visualize adjacent minterms for selecting
PIs.
You can extend the problem to six variables by using four K-
Maps
5 variable 32 cells
xyz
vw 000 001 011 010 110 111 101 100
00 m0 m4 m12 m8 m24 m28 m20 m16
01 m1 m5 m13 m9 m25 m29 m21 m17
11 m3 m7 m15 m11 m27 m31 m23 m19
10 m2 m6 m14 m10 m26 m30 m22 m18
36
36
5-Variable K-Maps
Adjacent:
• A cell in v = 0 map is adjacent to the same cell in v = 1
map.
• Example, m4 m20 and m15 m31 are adjacent.
yz yz
wx 00 01 11 10 wx 00 01 11 10
00 m0 m1 m3 m2 00 m16 m17 m19 m18
01 m4 m5 m7 m6 01 m20 m21 m23 m22
11 m12 m13 m15 m14 11 m28 m29 m31 m30
10 m8 m9 m11 m10 10 m24 m25 m27 m26
v=0 v=1
37
37
Example: 5-Variable K-Maps
yz yz
wx 00 01 11 10 wx 00 01 11 10
00 1 1 00
01 1 1 01 1 1
11 1 11 1 1
10 1 10 1
v=0 v=1
• F(v,w,x,y,z) = v’w’z’+wy’z+vxz
38
38
39
39
Don't Cares in K-Maps
Example 2: A circuit that represents a very common situation that
occurs in computer design has two distinct sets of input variables:
• A, B, and C which take on all possible combinations, and
• Y which takes on values 0 or 1.
and a single output Z. The circuit that receives the output Z observes
it only for combinations of A, B, and C such that A = 1 and B = 1 or C
= 0, otherwise ignoring it. Thus, Z is specified only for those
combinations, and for all other combinations of A, B, and C, Z is a
don’t care. Specifically, Z must be specified for AB + C = 1, and is a
don’t care for :
AB + C = (A + B)C = AC + BC
Ultimately, each don’t care “x” entry may take on either a 0 or 1
value in resulting solutions
For example, an “x” may take on value “0” in an SOP solution and
value “1” in a POS solution, or vice-versa.
Any minterm with value “x” need not be covered by a prime
implicant.
40
40
41
41
Product of Sums Example
42
42
Optimization Algorithm
1 2 3
Find all prime Include all essential Select a minimum cost
implicants. prime implicants in the set of non-essential
solution prime implicants to
cover all minterms not
yet covered:
43
43
Prime Implicant Selection Rule
44
44
1 1 1 1
1 1 1 1 1 1 1 1
B B
1 1
A A
1 1 1 1
D D
Minterms covered by essential prime implicants
45
45
Selection Rule Example with Don’t Cares
1 x 1 x
1 x x 1 1 x x 1
B B
x x
A A
1 1 x 1 1 x
D D
Minterms covered by essential prime implicants
46
46
Quine-McCluskey Method
47
47
Optimization of SOP Representation By Quine-McCluskey Method
1st Phase : Finding the prime implicants
Example: f(x1,x2,x3,x4)=m(1,3,5,6,7,8,12,14,15)
x 1 x 2 x3 x 4 x1 x 2 x 3 x 4 x1 x 2 x 3 x4
10 0 0 1 1,3 0 0 - 1 1,3,5,7 0 - - 1 C
81 0 0 0 1,5 0 - 0 1 1,5,3,7 0 - - 1
30 0 1 1 8,12 A 1 - 0 0
6,7,14,15 - 1 1 - D
50 1 0 1 3,7 0 - 1 1
60 1 1 0 5,7 0 1 - 1 6,14,7,15 - 1 1 -
12 1 1 0 0 6,7 0 1 1 -
6,14 - 1 1 0
70 1 1 1
12,14 B1 1 - 0
14 1 1 1 0
7,15 - 1 1 1
15 1 1 1 1 14,15 1 1 1 -
48
48
Optimal Representation:
f(x1,x2,x3,x4)=x1x3x4+x1x4+x2x3
49
49
Optimization of SOP Representation By Quine-McCluskey Method
2nd Phase : Finding optimal representation
Petrick Method
A 8,12 P=C C C D (C+D) A (A+B) (B+D) D
B 12,14 X+XY=X and (X+Y)(X+Z)=X+YZ
D 6,7,14,15
Optimal Representation:
f(x1,x2,x3,x4)=x1x3x4+x1x4+x2x3
50
50
Example: f(x1,x2,x3,x4)=m(1,4,5,7,8,9,11,12,14,15)
x 1 x 2 x3 x4 x1 x2 x3 x4
10 0 0 1 1,5 0 - 0 1 A
40 1 0 0 1,9 - 0 0 1 B
81 0 0 0 4,5 0 1 0 - C
50 1 0 1 4,12 - 1 0 0 D
91 0 0 1 8,9 1 0 0 - E
12 1 1 0 0 8,12 1 - 0 0 F
70 1 1 1 5,7 0 1 - 1 G
11 1 0 1 1 9,11 1 0 - 1 H
14 1 1 1 0 12,14 1 1 - 0 I
15 1 1 1 1 7,15 - 1 1 1 J
11,15 1 - 1 1 K
14,15 1 1 1 - L
1 4 5 7 8 9 111214 15 (B+E+H)(H+K)(D+F+I)(I+L)(J+K+L)
A X X There is no essential prime implicant.
B X X None of the rows cover another row.
C X X None of the columns cover another column.
X Let A=1
D X
P= (C+D)(G+J)(E+F)(B+E+H)(H+K)
E X X
F X X (D+F+I)(I+L)(J+K+L)
G X X There is no essential prime implicant.
H X X E covers B. D covers C. J covers G.
I X X B=0, C=0, G=0
J X X P= D J (E+F)(E+H)(H+K)(D+F+I)(I+L)
K X X (J+K+L)
L X X D and J are essential prime implicants.
D=1, J=1
E and H essential prime implicant.
E=1, H=1 P= (E+F)(E+H)(H+K)(I+L)
Example: f(x1,x2,x3,x4)=m(1,4,5,7,8,9,11,12,14,15)
Optimal Representation:
A D J E H I or L
f(x1,x2,x3,x4)=x1x3x4+x2x3x4+x2x3x4+x1x2x3+x1x2x4+x1x2x4
or x1x2x3
53
53
Optimization of POS Representation By
Quine-McCluskey Method
Example: f(x1,x2,x3,x4)=M(1,4,5,8,11,12,14)
x1 x 2 x 3 x 4 x 1 x2 x3 x4
1 4 8 5 12 1114
1 0 0 0 1 1,5 0 - 0 1 B
A X EPI
4 0 1 0 0 4,5 0 1 0 - C
B X X EPI
8 1 0 0 0 4,12 - 1 0 0 D
C X X
5 0 1 0 1 8,12 1 - 0 0 E
D X X
12 1 1 0 0 12,14 1 1 - 0 F
E X X EPI
A 11 1 0 1 1
F X X EPI
14 1 1 1 0
f(x1,x2,x3,x4)=(x1+x2+x3+x4) f(x1,x2,x3,x4)=(x1+x2+x3+x4)(x1+x3+x4)
(x1+x3+x4)(x1+x2+x3)(x2+x3+x4) (x1+x3+x4)(x1+x2+x4)
(x1+x3+x4)(x1+x2+x4) (x1+x2+x3) or (x2+x3+x4)
54
54
55
55
Example: F(x,y,z)=m(1,2,3,5,7)
x’y 1. sütun 2. sütun 3. sütun
y z
xyz xyz xyz
x 00 01 11 10
001 0 - 1 B - - 1
0 0 1 1 1
010 -01
011 A 01-
1 0 1 1 0
101 - 1 1
111 1 - 1
z
P=AB
F=x’y+z
A=B=1
A=x’y
B=z
F=A+B=x’y+z
56
56
https://everycircuit.com/circuit/6711990626287616/binary-to-7-segment-display-
decoder
57
57
58
58