910 likes | 1.09k Views
CMPUT329 - Fall 2003. Topic 4: Cost of Logic Circuits and Karnaugh Maps José Nelson Amaral. Reading Assignment. Chapter 4: Section 4.3.4, 4.3.5, 4.3.6, 4.3.7, 4.3.8. The cost of a boolean equation represented in a sum-of-products form is given by:.
E N D
CMPUT329 - Fall 2003 Topic 4: Cost of Logic Circuits and Karnaugh Maps José Nelson Amaral CMPUT 329 - Computer Organization and Architecture II
Reading Assignment Chapter 4: Section 4.3.4, 4.3.5, 4.3.6, 4.3.7, 4.3.8 CMPUT 329 - Computer Organization and Architecture II
The cost of a boolean equation represented in a sum-of-products form is given by: Cost of Implementing a Logic Circuit The cost of implementing a logic circuit is related to the number of gates used and with the number of inputs in each gate. A literal is a boolean variable or its complement. CMPUT 329 - Computer Organization and Architecture II
Cost of Implementing a Logic Circuit CMPUT 329 - Computer Organization and Architecture II
f2(w,x,y,z) = w’ + x’ + yz + y’z’ C(f2) = 0+0+2+2+4=8 g1(XYZ) = XY + X’Z + YZ C(g1) = 2+2+2+3=9 g2(XYZ) = XY + X’Z C(g2) = 2+2+2=6 h1(a,b) = ab C(h1) = 2 + 0 = 2 h2(a,b) = b’ C(h2) = 0 + 0 = 0 Cost of a Logic CircuitExamples What is the cost of the following boolean equations? f1(w,x,y,z) = wxy’z + wxyz’ C(f1) = 4+4+2=10 CMPUT 329 - Computer Organization and Architecture II
Karnaugh Maps M. Karnaugh, “The Map Method for Synthesis of Combinatorial Logic Circuits”, Transactions of the American Institute of Electrical Engineers, Communications and Electronics, Vol. 72, pp. 593-599, November 1953. and A Karnaugh Map is a graphical tool to assist on the minimization of logic equations. Similar to a truth table, a Karnaugh Map specifies a value for each combination of inputs. CMPUT 329 - Computer Organization and Architecture II
A A A=0,B=0 A=1,B=0 A=0 A=1 A=0,B=1 A=1,B=1 B A=0,B=0,C=1 A=1,B=0,C=1 A A=0,B=0,C=0 A=1,B=0,C=0 A=0,B=1,C=0 B A=1,B=1,C=0 C A=0,B=1,C=1 A=1,B=1,C=1 Anatomy of Karnaugh Maps CMPUT 329 - Computer Organization and Architecture II
A 0000 0 0100 4 1000 8 1100 12 0001 1 0101 5 1001 9 1101 13 D D 1111 15 0111 7 0011 3 1011 11 C C 1110 14 0010 2 0110 6 1010 10 B Anatomy of Karnaugh Maps A Karnaugh Map for four variables. ABCD A B CMPUT 329 - Computer Organization and Architecture II
Cin Adder S = A’B’Cin + A’BCin’ + AB’Cin’ + ABCin S Cout = A’BCin + A B’Cin + ABCin’ + ABCin B A = A’BCin + ABCin + AB’Cin + ABCin + ABCin’ + ABCin = (A’ + A)BCin + (B’ + B)ACin + (Cin’ + Cin)AB Cout = 1·BCin + 1· ACin + 1· AB = BCin + ACin + AB Application of Karnaugh Maps: The One-bit Adder How to use a Karnaugh Map instead of the Algebraic simplification? CMPUT 329 - Computer Organization and Architecture II
Cin A Adder S B B A Cin Cout Application of Karnaugh Maps: The One-bit Adder 0 0 1 0 Now we have to cover all the 1s in the Karnaugh Map using the largest rectangles and as few rectangles as we can. 0 1 1 1 Karnaugh Map for Cout CMPUT 329 - Computer Organization and Architecture II
Cin A Adder 1 0 S 1 1 B B A Cin Cout Application of Karnaugh Maps: The One-bit Adder Now we have to cover all the 1s in the Karnaugh Map using the largest rectangles and as few rectangles as we can. 0 0 0 1 Cout = Karnaugh Map for Cout CMPUT 329 - Computer Organization and Architecture II
Cin A Adder 1 0 S 1 1 B A B Cin Cout Application of Karnaugh Maps: The One-bit Adder Now we have to cover all the 1s in the Karnaugh Map using the largest rectangles and as few rectangles as we can. 0 0 0 1 Cout = AB Karnaugh Map for Cout CMPUT 329 - Computer Organization and Architecture II
Cin A Adder 1 0 S 1 1 B B A Cin Cout Application of Karnaugh Maps: The One-bit Adder Now we have to cover all the 1s in the Karnaugh Map using the largest rectangles and as few rectangles as we can. 0 0 0 1 Cout = AB + ACin Karnaugh Map for Cout CMPUT 329 - Computer Organization and Architecture II
Cin A Adder 1 0 S 1 1 B B A Cin Cout Application of Karnaugh Maps: The One-bit Adder Now we have to cover all the 1s in the Karnaugh Map using the largest rectangles and as few rectangles as we can. 0 0 0 1 Cout = AB + ACin + BCin Karnaugh Map for Cout CMPUT 329 - Computer Organization and Architecture II
Cin A Adder S B B A Cin Cout Application of Karnaugh Maps: The One-bit Adder 0 1 0 1 1 0 1 0 S = Karnaugh Map for S CMPUT 329 - Computer Organization and Architecture II
Cin A Adder S B B A Cin Cout Application of Karnaugh Maps: The One-bit Adder 0 1 0 1 1 0 1 0 S = A’BCin’ Karnaugh Map for S CMPUT 329 - Computer Organization and Architecture II
Cin A Adder S B B A Cin Cout Application of Karnaugh Maps: The One-bit Adder 0 1 0 1 1 0 1 0 S = A’BCin’ + A’B’Cin Karnaugh Map for S CMPUT 329 - Computer Organization and Architecture II
Cin A Adder S B B A Cin Cout Application of Karnaugh Maps: The One-bit Adder 0 1 0 1 1 0 1 0 S = A’BCin’ + A’B’Cin + ABCin Karnaugh Map for S CMPUT 329 - Computer Organization and Architecture II
Cin A Adder S B B A Cin Cout Application of Karnaugh Maps: The One-bit Adder 0 1 0 1 1 0 1 0 S = A’BCin’ + A’B’Cin + ABCin + AB’Cin’ Karnaugh Map for S CMPUT 329 - Computer Organization and Architecture II
If a function F is represented by this Karnaugh Map. Which of the following terms are implicants of F, and which ones are prime implicants of F? A 1 1 1 Example: D 1 1 (a) AC’D’ (b) BD (c) A’B’C’D’ (d) AC’ (e) B’C’D’ C 1 1 1 B Prime Implicants Any single 1 or group of 1s in the Karnaugh map of a function F is an implicant of F. A product term is called a prime implicant of F if it cannot be combined with another term to eliminate a variable. Implicant Not an Implicant Implicant Prime Implicant Prime Implicant CMPUT 329 - Computer Organization and Architecture II
Essential Prime Implicants A product term is an essential prime implicant of F if there is a minterm that is only covered by that prime implicant. The minimal sum-of-products form of F must include all the essential prime implicants of F. Theorem: If a minterm mj of F and all its adjacent minterms are covered by a single term pi, then pi is an essential prime implicant of F. CMPUT 329 - Computer Organization and Architecture II
f’(w,x,y,z) = w’ + x’ + (y’z +yz’)’ In Topic 2 we used the following algebraic transformations to solve this problem. Could it be easier with Karnaugh Maps? = w’ + x’ + (y’z)’(yz’)’ = w’ + x’ + (y + z’)(y’ + z) = w’ + x’ + yy’ + yz + z’y’ + z’z = w’ + x’ + 0 + yz + z’y’ + 0 = w’ + x’ + yz + y’z’ Example Express the complement f’(w,x,y,z) of the following expression as a sum of minterms f(w,x,y,z) = wx(y’z + yz’) CMPUT 329 - Computer Organization and Architecture II
z x Example Express the complement f’(w,x,y,z) of the following expression as a sum of minterms f(w,x,y,z) = wx(y’z + yz’) w = wxy’z + wxyz’ y CMPUT 329 - Computer Organization and Architecture II
z 1 1 1 x Example Express the complement f’(w,x,y,z) of the following expression as a sum of minterms f(w,x,y,z) = wx(y’z + yz’) w = wxy’z + wxyz’ y CMPUT 329 - Computer Organization and Architecture II
z x Example Express the complement f’(w,x,y,z) of the following expression as a sum of minterms f(w,x,y,z) = wx(y’z + yz’) w = wxy’z + wxyz’ This is the Karnaugh Map for f(w,x,y,z). 1 How do we build the Karnaugh Map for f’(w,x,y,z)? 1 y CMPUT 329 - Computer Organization and Architecture II
Now we can write the minimized form for f’(w,x,y,z) from its Karnaugh map. w 1 1 1 1 1 1 1 1 f’(w,x,y,z) = z 1 1 1 0 x 1 1 0 1 y Example If we reverse the value in each position of the Karnaugh map of f(w,x,y,z), we obtain the Karnaugh map for f’(w,x,y,z). CMPUT 329 - Computer Organization and Architecture II
1 1 1 1 1 1 1 z 1 1 1 0 x 1 1 0 1 Example If we reverse the value in each position of the Karnaugh map of f(w,x,y,z), we obtain the Karnaugh map for f’(w,x,y,z). Now we can write the minimized form for f’(w,x,y,z) from its Karnaugh map. w 1 f’(w,x,y,z) = x’ y CMPUT 329 - Computer Organization and Architecture II
1 1 1 1 1 1 1 z 1 1 1 0 x 1 1 0 1 Example If we reverse the value in each position of the Karnaugh map of f(w,x,y,z), we obtain the Karnaugh map for f’(w,x,y,z). Now we can write the minimized form for f’(w,x,y,z) from its Karnaugh map. w 1 f’(w,x,y,z) = x’ + w’ y CMPUT 329 - Computer Organization and Architecture II
1 1 1 1 1 1 1 z 1 1 1 0 x 1 1 0 1 Example If we reverse the value in each position of the Karnaugh map of f(w,x,y,z), we obtain the Karnaugh map for f’(w,x,y,z). Now we can write the minimized form for f’(w,x,y,z) from its Karnaugh map. w 1 f’(w,x,y,z) = x’ + w’ + yz y CMPUT 329 - Computer Organization and Architecture II
1 1 1 1 1 1 1 z 1 1 1 0 x 1 1 0 1 Example If we reverse the value in each position of the Karnaugh map of f(w,x,y,z), we obtain the Karnaugh map for f’(w,x,y,z). Now we can write the minimized form for f’(w,x,y,z) from its Karnaugh map. w 1 f’(w,x,y,z) = x’ + w’ + yz + y’z’ y CMPUT 329 - Computer Organization and Architecture II
XY + X’Z + YZ = XY + X’Z XY + X’Z + YZ = XY + X’Z + 1·YZ = XY + X’Z + (X + X’)YZ = XY + X’Z + XYZ + X’YZ = XY + XYZ + X’Z + X’YZ = XY(1 + Z) + X’Z(1 + Y) = XY·1 + X’Z·1 = XY + X’Z Examples In Topic 2 we used the following algebraic transformations to prove the consensus theorem. Could we use Karnaugh maps to obtain such a proof? CMPUT 329 - Computer Organization and Architecture II
Y 1 1 X 1 1 Z Examples First we need to build the Karnaugh map for the expression: XY + X’Z + YZ Now we need to write the simplified expression from the Karnaugh map. XY + X’Z CMPUT 329 - Computer Organization and Architecture II
D C Minimum Sum-of-products The minimum sum-of-products of a function F is formed by some, but not necessarily all, of the prime implicants of the function. Write all the prime implicants for the function g expressed as this Karnaugh Map. A 1 1 Example: AB AD’ BD AC 1 1 1 1 1 1 1 B CMPUT 329 - Computer Organization and Architecture II
D g = AC + AD’ + BD C Minimum Sum-of-products The minimum sum-of-products of a function F is formed by some, but not necessarily all, of the prime implicants of the function. Now write the minimum sum-of-products of g. A 1 1 Example: AB AD’ BD AC 1 1 1 1 1 1 1 B CMPUT 329 - Computer Organization and Architecture II
Because F is given as a product-of-sums, it is easier to build the Karnaugh map for F’ and then complement it. F’ = [(b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’)]’ = (b + c + d’)’ + (a + b’ + d)’ + (a’ + b + d’)’ + (a’ + b’ + c’)’ = b’c’d + a’bd’ + ab’d + abc Karnaugh Maps of Product-of-sums Find the minimum sum-of-minterms form for the following function F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) CMPUT 329 - Computer Organization and Architecture II
d c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc Now we can easily build the Karnaugh map for F’. a b CMPUT 329 - Computer Organization and Architecture II
1 1 d c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc Now we can easily build the Karnaugh map for F’. a b CMPUT 329 - Computer Organization and Architecture II
1 d c 1 Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc Now we can easily build the Karnaugh map for F’. a 1 1 b CMPUT 329 - Computer Organization and Architecture II
1 d 1 c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc Now we can easily build the Karnaugh map for F’. a 1 1 1 b CMPUT 329 - Computer Organization and Architecture II
d 1 c 1 Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc Now we can easily build the Karnaugh map for F’. a 1 1 1 1 1 b CMPUT 329 - Computer Organization and Architecture II
d d c c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc Now we can easily build the Karnaugh map for F’. a a 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 b b F’ F CMPUT 329 - Computer Organization and Architecture II
b’d’ d c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc What is the set of prime implicants of F? a 1 1 1 1 1 1 1 1 1 b F CMPUT 329 - Computer Organization and Architecture II
d c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc What is the set of prime implicants of F? a b’d’ a’cb’ 1 1 1 1 1 1 1 1 1 b F CMPUT 329 - Computer Organization and Architecture II
d c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc What is the set of prime implicants of F? a b’d’ a’cb’ 1 1 1 a’cd 1 1 1 1 1 1 b F CMPUT 329 - Computer Organization and Architecture II
d c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc What is the set of prime implicants of F? a b’d’ a’cb’ 1 1 1 a’cd 1 1 a’bd 1 1 1 1 b F CMPUT 329 - Computer Organization and Architecture II
d c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc What is the set of prime implicants of F? a b’d’ a’cb’ 1 1 1 a’cd 1 1 a’bd bc’d 1 1 1 1 b F CMPUT 329 - Computer Organization and Architecture II
d c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc What is the set of prime implicants of F? a b’d’ a’cb’ 1 1 1 a’cd 1 1 a’bd bc’d 1 1 abc’ 1 1 b F CMPUT 329 - Computer Organization and Architecture II
d c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc What is the set of prime implicants of F? a b’d’ Which prime implicants are essential for F? a’cb’ 1 1 1 a’cd 1 1 a’bd bc’d 1 1 abc’ ac’d’ 1 1 b F CMPUT 329 - Computer Organization and Architecture II
d c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc What is the set of prime implicants of F? a b’d’ Which prime implicants are essential for F? a’cb’ 1 1 1 a’cd 1 1 a’bd Only b’d’ is essential. bc’d 1 1 abc’ ac’d’ 1 1 Does the set of all essential prime implicants completely define F? b F CMPUT 329 - Computer Organization and Architecture II
F = b’d’ d c Karnaugh Maps of Product-of-sums F = (b + c + d’)(a + b’ + d)(a’ + b + d’)(a’ + b’ + c’) F’ = b’c’d + a’bd’ + ab’d + abc Now we can write the minimized form for F. a 1 1 1 1 1 1 1 1 1 b F CMPUT 329 - Computer Organization and Architecture II