chapter 2 – combinational logic circuitslogic circuitshoangtrang/lecture...
TRANSCRIPT
Computer Engineering 1 (ECE290)
Chapter 2 – Combinational Logic CircuitsLogic Circuits
Part 2 – Circuit Optimization
HOANG Trang
Reference: © 2008 Pearson Education IncReference: © 2008 Pearson Education, Inc.
Overview Part 1 – Gate Circuits and Boolean Equations
• Binary Logic and Gatesy g• Boolean Algebra• Standard Forms
Part 2 – Circuit OptimizationPart 2 Circuit Optimization• Two-Level Optimization• K-map• Map Manipulation• Map ManipulationPart 3 – Additional Gates and Circuits• Other Gate Types• Exclusive OR Operator and Gates• Exclusive-OR Operator and Gates• High-Impedance Outputs
Hoang Trang Reference: Chapter 2 - Part 2 2
Circuit Optimization
Goal: To obtain the simplest implementation for a given functionimplementation for a given function Optimization requires a cost criterion to
measure the simplicity of a circuitmeasure the simplicity of a circuit Distinct cost criteria we will use:
• Literal cost (L)• Literal cost (L)• Gate input cost (G)• Gate input cost with NOTs (GN)p ( )
Hoang Trang Reference: Chapter 2 - Part 2 3
Literal Cost
Literal – a variable or it complement Literal cost – the number of literal
appearances in a Boolean expression corresponding to the logic circuit diagram Examples:
• F = BD + A C + A L = 8DB C
D• F = BD + A C + A + AB L = • F = (A + B)(A + D)(B + C + )( + + D) L =
B B D CB C
Hoang Trang Reference: Chapter 2 - Part 2 4
( )( )( )( )• Which solution is best?
Gate Input Cost Gate input costs - the number of inputs to the gates in the
implementation corresponding exactly to the given equation or equations. (G - inverters not counted, GN - inverters counted)
For SOP and POS equations, it can be found from the equation(s) by finding the sum of:equation(s) by finding the sum of:• all literal appearances• the number of terms excluding single literal terms,(G) and• optionally, the number of distinct complemented single literals (GN).
Example: G=L+term, GN=L+term + complement!• F = BD + A C + A G = 8 GN = 11DB C• F = BD + A C + A G = 8, GN = 11• F = BD + A C + A + AB G = , GN = • F = (A + )(A + D)(B + C + )( + + D) G = , GN =
DB CB B D C
B D B C
Hoang Trang Reference: Chapter 2 - Part 2 5
F (A + )(A + D)(B + C + )( + + D) G , GN • Which solution is best?
B D B C
Cost Criteria (continued) Example 1:
F A + B C + B C L = 5GN = G + 2 = 9
F = A + B C +
BC
B C G = L + 2 = 7
AC
F
L (literal count) counts the AND inputs and the singleliteral OR input.
G (gate input count) adds the remaining OR gate inputs GN(gate input count with NOTs) adds the inverter inputs
Hoang Trang Reference: Chapter 2 - Part 2 6
GN(gate input count with NOTs) adds the inverter inputs
Cost Criteria (continued) Example 2:
F = A B C + BCABCA F = A B C +
L = 6 G = 8 GN = 11 F (A + )( + C)( + B)
BC
A
CF
C B
A
F = (A + )( + C)( + B) L = 6 G = 9 GN = 12
S f ti d
AC B
Same function and sameliteral cost
But first circuit has betterF
ABC
gate input count and bettergate input count with NOTsS l t it!
FG, GN: is proportional to the number
of transistors and wires used to implement a logic circuit
Hoang Trang Reference: Chapter 2 - Part 2 7
Select it!implement a logic circuit
=> G, GN: good measure to choose!
Boolean Function Optimization Minimizing the gate input (or literal) cost of a (a
set of) Boolean equation(s) reduces circuit cost.set of) Boolean equation(s) reduces circuit cost. We choose gate input costgate input cost. Boolean Algebra and graphical techniques areBoolean 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?
T t ti ti t f ti Treat optimum or near-optimum cost functionsfor two-level (SOP and POS) circuits first.
Introduce a graphical technique using Karnaugh
Hoang Trang Reference: Chapter 2 - Part 2 8
Introduce a graphical technique using Karnaugh maps (K-maps, for short)
Karnaugh Maps (K-map)
A K-map is a collection of squares• Each square represents a minterm• Each square represents a minterm• The collection of squares is a graphical representation
of a Boolean function• Adjacent squares differ in the value of only one variable
(Gray Code)• Alternative algebraic expressions for the same functionAlternative algebraic expressions for the same function
are derived by recognizing patterns of squares The K-map can be viewed as
• A reorganized version of the truth table• A topologically-warped Venn diagram as used to
visualize sets in algebra of sets
Hoang Trang Reference: Chapter 2 - Part 2 9
visualize sets in algebra of sets
Some Uses of K-Maps Provide a means for:
Fi di i i• Finding optimum or near optimum SOP and POS standard forms, and two-level AND/OR and OR/AND circuit two-level AND/OR and OR/AND circuit
implementationsfor functions with small numbers of variables
• Visualizing concepts related to manipulating Boolean expressionsBoolean expressions
• Demonstrating concepts used by computer-aided design (CAD) programs to simplify
Hoang Trang Reference: Chapter 2 - Part 2 10
aided design (CAD) programs to simplify large circuits
Two Variable Maps A 2-variable Karnaugh Map:
• Note that minterm m0 and y = 0 y = 1• Note that minterm m0 andminterm m1 are “adjacent”and differ in the value of the
x = 0 m0 = m1 =yx yxand differ in the value of the
variable y• Similarly, minterm m0 and
x = 1 m2 = m3 =yx yx
yx yxSimilarly, minterm m0 andminterm m2 differ in the x variable.
• Also, m1 and m3 differ in the x variable as
y
Also, m1 and m3 differ in the x variable as well.
• Finally, m2 and m3 differ in the value of the
Hoang Trang Reference: Chapter 2 - Part 2 11
yvariable y
K-Map and Truth Tables
The K-Map is just a different form of the truth table. Example Two variable function: Example – Two variable function:
• We choose a,b,c and d from the set {0,1} to implement a particular function, F(x,y).p e e t a pa t cu a u ct o , ( ,y).
Function Table K-MapInput Function y = 0 y = 1Values(x,y)
ValueF(x,y)
0 0 a
y yx = 0 a b
1 d0 0 a0 1 b1 0 c
x = 1 c dThe K-map:
Hoang Trang Reference: Chapter 2 - Part 2 12
1 1 d a reorganized version of the truth table
K-Map Function Representation
Example: G(x,y) = x + y G = x+y y = 0 y = 1
x = 0 0 1
x = 1 1 1
For G(x y) two pairs of adjacent cells containing
x 1 1 1
For G(x,y), two pairs of adjacent cells containing 1’s can be combined using the Minimization Minimization TheoremTheorem: yyyxyyyx x x
yxyxxyyxyx)y,x(G
D li t
Hoang Trang Reference: Chapter 2 - Part 2 13
Duplicate xy
Three Variable Maps
A three-variable K-map:yz=00 yz=01 yz=11 yz=10y y y y
x=0 m0 m1 m3 m2
x=1 m4 m5 m7 m6
Where each minterm corresponds to the product terms:
x 1 m4 m5 m7 m6
yz 00 yz 01 yz 11 yz 10yz=00 yz=01 yz=11 yz=10
x=0 zyx zyx zyx zyx
Note that if the binary value for an index differs in only one bit position the minterms are adjacent on the K-
x=1 zyx zyx zyx zyx
Hoang Trang Reference: Chapter 2 - Part 2 14
one bit position, the minterms are adjacent on the K-Map
Alternative Map Labeling
useful
y
useful
y10 23x
yyy z
10 23
x0
00 01 11 10
zx 4 5 67
x
zz4 5 67
0
1xz zz z
Hoang Trang Reference: Chapter 2 - Part 2 15
Example Functions
By convention, we represent the minterms of F by a "1" in the map and leave the minterms of blankFin the map and leave the minterms of blank
Example: y10 23 11(2,3,4,5) z)y,F(x, m
F
Example:
x 4 5 67
111
1
z Example:
Learn the locations of the 8
zy
10 231(3,4,6,7) c)b,G(a, m
indices based on the variable order shown (x, most significantand z least significant) on the
x 4 5 671 111
z
Hoang Trang Reference: Chapter 2 - Part 2 16
and z, least significant) on themap boundaries
z
Simplify? => Combining Squares
By combining squares
reduce number of literals in a product term,
reducing the literal cost, thereby reducing the other two cost criteria
Hoang Trang Reference: Chapter 2 - Part 2 17
Example: Combining Squares
Example: Let y10 23 11
m(2,3,6,7)F
x10 2
4
3
5 671 111
Applying the Minimization Theorem three times:
z
times:
zyyz zyxzyxzyxzyx)z,y,x(F
Thus the four terms that form a 2 × 2 square y
zyyz
Hoang Trang Reference: Chapter 2 - Part 2 18
correspond to the term "y".
Three-Variable Maps
Example Shapes of 2-cell Rectangles:yy
0 1 3 2
5 64 7xxzz
Hoang Trang Reference: Chapter 2 - Part 2 19
Three-Variable Maps
Example Shapes of 4-cell Rectangles:yy
0 1 3 2
5 64 7xxzz
Hoang Trang Reference: Chapter 2 - Part 2 20
Three Variable Maps K-Maps can be used to simplify Boolean functions by
systematic methods. Terms are selected to cover thesystematic methods. Terms are selected to cover the“1s”in the map.
Example: Simplify )(1,2,3,5,7z)y,F(x, m
yz yx)( , , , ,)y,( ,
11
x 1 1
1
x
z
1 1
Hoang Trang Reference: Chapter 2 - Part 2 21
z)y,F(x, z yx
Three-Variable Map Simplification Use a K-map to find an optimum SOP
i f 7)(0 1 2 4 6Z)YF(X equation for ,7)(0,1,2,4,6 Z)Y,F(X, m
Hoang Trang Reference: Chapter 2 - Part 2 22
Four Variable Maps
Map and location of minterms:
0 1 3 2Y
5 64 7
1011
12 13 1415 X
W8 9 1011W
Hoang Trang Reference: Chapter 2 - Part 2 23
Z
Four-Variable Maps
K-map: usefulYZ
0 1 3 2
YZWX 00 01 11 10
005 64 7
00
01
8 9 1011
12 13 141511
8 9 101110
Hoang Trang Reference: Chapter 2 - Part 2 24
Four-Variable Maps
Example of combining squares
0 1 3 2Y
5 64 7
8 9 1011
12 13 1415 X
W8 9 1011
Hoang Trang Reference: Chapter 2 - Part 2 25
Z
Four-Variable Maps
Example of combining squaresYY
0 1 3 2
5 64 7
X
9
12 13 1415W 8 9 1011W
Hoang Trang Reference: Chapter 2 - Part 2 26
Z
Four-Variable Map Simplification )8,10,13,152,4,5,6,7,(0,Z)Y,X,F(W, m
Hoang Trang Reference: Chapter 2 - Part 2 27
Four-Variable Map Simplification
3,14,15 )(3,4,5,7,9,1Z)Y,X,F(W, m
Hoang Trang Reference: Chapter 2 - Part 2 28
Systematic Simplification:prime implicant, essentialp p ,
A Prime Implicant (PI) => a product term obtained by bi i h i ibl b f djcombining the maximum possible number of adjacent squares
(the number of squares a power of 2)
A prime implicant: is called an Essential Prime ImplicantA prime implicant: is called an Essential Prime Implicant
IF it is the only prime implicant that covers (includes) one or more mintermsmore minterms.
Prime Implicants and Essential Prime Implicants can be determined by inspection of a K-Map.determined by inspection of a K Map.
A set of prime implicants "covers all minterms" if, for each minterm of the function, at least one prime implicant in the
Hoang Trang Reference: Chapter 2 - Part 2 29
p pset of prime implicants includes the minterm.
Example of Prime Implicants
Find ALL Prime ImplicantsCD
DBESSENTIAL Prime Implicants
CCD
DB C
1 1
1 1
1
BD BD
1 1
1 1
1
B
A1 1
B
A1 1
1 11 1
D
1 11 1
D
BA
Hoang Trang Reference: Chapter 2 - Part 2 30CB
DMinterms covered by single prime implicant
DAD
Prime Implicant Practice
Find all prime implicants for:p p13,14,15),10,11,12,(0,2,3,8,9D)C,B,F(A, m
Hoang Trang Reference: Chapter 2 - Part 2 31
Another Example
Find all prime implicants for:15)12 13 14(0 2 3 4 7D)CBG(A
• Hint: There are seven prime implicants!15),12,13,14,(0,2,3,4,7D)C,B,G(A, m
Hoang Trang Reference: Chapter 2 - Part 2 32
Five Variable or More K-Maps
5 variables => use two adjacent K-maps. It becomes harder to visualize adjacent minterms forIt becomes harder to visualize adjacent minterms for selecting PIs.
6 variables => use 4 K-Maps.p
YV = 0 V = 1
Y
X XX
W
X
W
Hoang Trang Reference: Chapter 2 - Part 2 33
Z Z
Don't Cares (X) in K-Maps
Sometimes a function table or map contains entries for which it is known:for which it is known:• the input values for the minterm will never occur, or• The output value for the minterm is not usedThe output value for the minterm is not used
=> the output value need not be defined Instead, the output value is defined as a “don't , p
care” (“X”): value “0” or “1”. Placing “X” in the function table or map=> the cost (L, G, GN) of the logic circuit may be
lowered.
Hoang Trang Reference: Chapter 2 - Part 2 34
X in K-Maps: example
Example 1: A logic function has:+ input: the binary codes for the BCD
digits.digits. Only the codes for 0 through 9 are
sed The si codes 1010 thro ghused. The six codes, 1010 through 1111 never occur,
=> output values for these codes are “X” to represent “don’t cares.”
Hoang Trang Reference: Chapter 2 - Part 2 35
p
Example: “X” BCD “5 or More”BCD 5 or MoreK-Map: Function F1(w,x,y,z) is defined as "5 or
more" over BCD inputsmore over BCD inputs. 1. “X” used for the 6 non-BCD combinations as “1”
F1 (w x y z) = w + x z + x y G = 7F1 (w,x,y,z) = w + x z + x y G = 72. “X” are treated as "0s."
G = 120 1 3 20 0 0 0
y
yxwyxwzxwz) y,x,F2(w, G 12=> F1 is lower in cost than F2 For this particular function, cost G for the
w
4 5 7 6
12 13 15 14
1 11
X X X X
0x
yy)y,,2( ,
POS solution for F1(w,x,y,z) is not changed by using the don't cares.
z
w8 9 11 10
11 X X
Placing “X” in the function table or map => the cost (L
Hoang Trang Reference: Chapter 2 - Part 2 36
Placing X in the function table or map => the cost (L, G, GN) of the logic circuit may be lowered
Optimization Algorithm
Find all prime implicants. Include all essential prime implicants in the
solutionS l t i i t t f ti l Select a minimum cost set of non-essential prime implicants to cover all minterms not yet covered:covered:• Obtaining an optimum solution: See Reading
Supplement - More on Optimization• Obtaining a good simplified solution: Use the
Selection Rule
Hoang Trang Reference: Chapter 2 - Part 2 37
Prime Implicant Selection Rule
Minimize the overlap among prime implicants as much as possible.
In particular, in the final solution, make sure that each prime implicant selectedsure that each prime implicant selected includes at least one minterm not included in any other prime implicantincluded in any other prime implicant selected.
Hoang Trang Reference: Chapter 2 - Part 2 38
Selection Rule Example
Simplify F(A, B, C, D) given on the K-E i lmap.
C CEssentialSelected
11 1
11
1 11 1
11
1
1B
A
1
1B
A
1
11
D
11
D
Hoang Trang Reference: Chapter 2 - Part 2 39
D DMinterms covered by essential prime implicants
Selection Rule Example with Don't Cares
Simplify F(A, B, C, D) given on the K-map. E ti lSelected
C CEssential
1
x
x x
1
1 1
x
x x
1
1x
xB
A
1 x
xB
A
1
1 x
D
1 1 x
D
1
Hoang Trang Reference: Chapter 2 - Part 2 40
Minterms covered by essential prime implicantsD D