Computer Engineering (Logic Circuits) (Karnaugh Map) Lec. # 6 (Karnaugh Map) Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering Faculty of Engineering Zagazig University
Course Web Page http://www.tsgaafar.faculty.zu.edu.eg Email: tsgaafar@yahoo.com
Lec. # 6 Karnaugh Map (Contd.)
Truth Table to K-Map Mapping Karnaugh Mapping Truth Table to K-Map Mapping Digital Electronics 2.2 Intro to NAND & NOR Logic Four Variable K-Map W X Y Z FWXYZ Minterm – 0 Minterm – 1 1 Minterm – 2 Minterm – 3 Minterm – 4 Minterm – 5 Minterm – 6 Minterm – 7 Minterm – 8 Minterm – 9 Minterm – 10 Minterm – 11 Minterm – 12 Minterm – 13 Minterm – 14 Minterm – 15 1 V 1 3 2 4 5 7 6 12 13 15 14 8 9 11 10 1 1 1 Demonstrate how the minterms of a four variable truth table are mapped to a K-Map. Project Lead The Way, Inc. Copyright 2009
Four Variable K-Map Groupings Karnaugh Mapping Digital Electronics 2.2 Intro to NAND & NOR Logic Four Variable K-Map Groupings Groups of One – 16 (not shown) Groups of Two – 32 (not shown) Groups of Four – 24 (seven shown) 1 1 1 V 1 1 1 1 Four Variable K-Map: There are 16 groups of one that are not shown because they are obvious. There are 32 groups of two that are not shown because they are obvious. There are 24 groups of four. Seven are show, the other 17 are obvious. Project Lead The Way, Inc. Copyright 2009
Four Variable K-Map Groupings Karnaugh Mapping Digital Electronics 2.2 Intro to NAND & NOR Logic Four Variable K-Map Groupings Groups of Eight – 8 (two shown) 1 V 1 Four variable K-Map: There are 8 groups of eight. Two are shown, the other 6 are obvious. Project Lead The Way, Inc. Copyright 2009
Four Variable K-Map Groupings Karnaugh Mapping Digital Electronics 2.2 Intro to NAND & NOR Logic Four Variable K-Map Groupings Group of Sixteen – 1 V 1 Four variable K-Map, group of 16. Project Lead The Way, Inc. Copyright 2009
Example : 4 Variable K-Map Karnaugh Mapping Example : 4 Variable K-Map Digital Electronics 2.2 Intro to NAND & NOR Logic Example: After labeling and transferring the truth table data into the K-Map, write the simplified sum-of-products (SOP) logic expression for the logic function F3. R S T U F3 1 V Pause the presentation and allow students to complete the example. The solution is on the next slide. Project Lead The Way, Inc. Copyright 2009
Example : 4 Variable K-Map Karnaugh Mapping Digital Electronics 2.2 Intro to NAND & NOR Logic Example: After labeling and transferring the truth-table data into the K-Map, write the simplified sum-of-products (SOP) logic expression for the logic function F3. R S T U F3 1 V 1 Solution: Here is the solution. If you print handouts, do not print this page. Project Lead The Way, Inc. Copyright 2009
Steps of graphical method (continued): Combine adjacent 1’s into group of 2n each such that Each group contains only 1’s. The group is not completely a part of a larger group. Choose the minimum number of the largest sized groups needed to cover all the 1’s. Each group is represented by an expression which is an intersection of the minterm in the group. The simplified solution is a logical OR of the expressions of all the groups chosen in steps 3 above.
Definitions An implicant is a product term of a function Any group of 1’s in a K-Map A prime implicant is a product term obtained by combining the maximum possible number of adjacent 1’s in a k-map Biggest groups of 1’s Not all prime implicants are needed! If a minterm is covered by exactly one prime implicant then this prime implicant is called an essential prime implicant
Terminology An implicant is a product term in an SOP expression (or a sum term in POS expression) Implicants are always rectangular in shape and the # of 1's covered is a power of 2 A prime implicant is an implicant that is not fully contained in some other larger implicant B C A 00 01 11 10 1 red implicant (but not prime) many more are not shown blue prime implicants (only two)
Essential Prime Implicants An essential prime implicant is a prime implicant that contains a 1 not included in any other prime implicant The minimum Boolean expression must use this term A cover is a collection of implicants that accounts for all valuations in which the function is “on” (e.g. 1)
Example Y=1 Consider F(X,Y,Z) = Sm(1,3,4,5,6) List all implicants, prime implicants and essential prime implicants Solution: Implicants: XY’Z’, XZ’, XY’, XY’Z, X’Y’Z, Y’Z, … P.Is: XY’, XZ’, Y’Z, X’Z EPIs: X’Z, XZ’ YZ X 00 01 11 10 1 X=1 Z=1 Y=1 YZ X 00 01 11 10 1 X=1 The simplest expression is NOT unique! Z=1
Finding minimum SOP Find each essential prime implicant and include it in the solution If any minterms are not yet covered, find minimum number of prime implicants to cover them (minimize overlap).
Example Simplify F(A, B, C, D) = ∑ m(0, 1, 2, 4, 5, 10,11,13, 15) Note: Only A’C’ is E.P.I For the remaining minterms: Choose 1 and 2 (minimize overlap) For m2, choose either A’B’D’ or B’CD’ F = A’C’ + ABD + AB’C + A’B’D’
Examples to illustrate terms 0 0 1 1 1 0 D A 0 1 B C 5 prime implicants: BD, ABC', ACD, A'BC, A'C'D essential minimum cover: 4 essential implicants
4 Variable Maps f(A,B,C,D) = m(0,1,2,3,6,8,9,11,13,14) f = A C' D + B C D' + B' C ' + B' D + A'B' C D A B 00 01 11 10 1
These are not essential! Another 4 Variable Map f(A,B,C,D) = m(0,1,2,5,6,7,8,9,10,13,15) f = B D + A' B C + B' D' + B' C' or f = B D + A' B C + B' D' + C' D (there are 2 more) C D A B 00 01 11 10 1 These are not essential!
essential prime implicants Find the Essential Prime Implicants C D A B 00 01 11 10 1 C D A B 00 01 11 10 1 essential prime implicants f = C'D' + A'B + B'D' + ACD
1 square = a term with 4 literals 2 square = a term with 3 literal 16 square = a function equal to 1 Z WX Y 01 00 0 0 0 1 1 1 10 YZ 11 10 X W
Simplification of k-Map Generate all PIs Find EPIs If EPIs can cover all minterms, then it is answer. Otherwise choose some non-essential PIs (which has less cost) such that all minterms are cover.
Step 1 Generate PIs Blue circle are PIs They are the largest circle you can drawn on kmap
Step 2 Find EPIs Red circle are EPIs Minterm 5, 14, 11 can only be cover by these 3 red circle
Step 3 EPIs cannot cover minterm 7 Choose between green/blue circle to cover minterm 7 Green is chosen as it is larger Less cost
Final Final result is obtained x3x4’ + x2’x3 + x1’x3 + x2x3’x4
Filling The Map Given F= WX’ + YZ Required: 1) K-Map 2) Simplify F as POS Solution: 4 Variables K-Map
Filling The Map F= WX’ + YZ 0 0 0 1 1 1 10 1 1 1 1 1 Y YZ WX 00 01 X 0 0 0 1 1 1 10 YZ 11 10 X W 1 1 1 1 1
Filling The Map POS Z WX Y 01 00 0 0 0 1 1 1 10 YZ 11 10 X W 1 1 1 1 1
Filling The Map Z WX Y 01 00 0 0 0 1 1 1 10 YZ 11 10 X W 0 0 1 1 1 1 1
Karnaugh Mapping Don’t Care Conditions Digital Electronics 2.2 Intro to NAND & NOR Logic A don’t care condition, marked by (X) in the truth table, indicates a condition where the design doesn’t care if the output is a (0) or a (1). A don’t care condition can be treated as a (0) or a (1) in a K-Map. Treating a don’t care as a (0) means that you do not need to group it. Treating a don’t care as a (1) allows you to make a grouping larger, resulting in a simpler term in the SOP equation. Project Lead The Way, Inc. Copyright 2009
Don’t Cares In some cases, the output of the function (1 or 0) is not specified for certain input combinations either because The input combination never occurs (Example BCD codes), or We don’t care about the output of this particular combination Such functions are called incompletely specified functions Unspecified minterms for these functions are called don’t cares While minimizing a k-map with don’t care minterms, their values can be selected to be either 1 or 0 depending on what is needed for achieving a minimized output.
f(w,x,y,z) = m(0,2,4,5,8,14,15), d(w,x,y,z) = m(7,10,13) Practice K-map Find a MSOP (Minimal SOP) for f(w,x,y,z) = m(0,2,4,5,8,14,15), d(w,x,y,z) = m(7,10,13)
Solutions for Practice K-map Find a MSOP for: f(w,x,y,z) = m(0,2,4,5,8,14,15), d(w,x,y,z) = m(7,10,13) Z WX Y 01 00 0 0 0 1 1 1 10 YZ 11 10 X W 1 1 1 1 X X 1 1 1 X
Solutions for Practice K-map Find a MSOP for: f(w,x,y,z) = m(0,2,4,5,8,14,15), d(w,x,y,z) = m(7,10,13) Y 1 x X W Z f(w,x,y,z)= x’z’ + w’xy’ + wxy
Example: Don’t Care Conditions Karnaugh Mapping Example: Don’t Care Conditions Digital Electronics 2.2 Intro to NAND & NOR Logic Example: After labeling and transferring the truth table data into the K-Map, write the simplified sum-of-products (SOP) logic expression for the logic function F4. Be sure to take advantage of the don’t care conditions. R S T U F4 X 1 V Pause the presentation and allow students to complete the example. The solution is on the next slide. Project Lead The Way, Inc. Copyright 2009
Example: Don’t Care Conditions Karnaugh Mapping Example: Don’t Care Conditions Digital Electronics 2.2 Intro to NAND & NOR Logic Example: After labeling and transferring the truth table data into the K-Map, write the simplified sum-of-products (SOP) logic expression for the logic function F4. Be sure to take advantage of the don’t care conditions. R S T U F4 X 1 V X 1 Solution: Here is the solution. If you print handouts, do not print this page. Project Lead The Way, Inc. Copyright 2009
Example F = ∑m(1, 3, 7) + ∑d(0, 5) B B A 00 01 11 10 X 1 3 2 4 5 7 6 Circle the x’s that help get bigger groups of 1’s (or 0’s if POS). Don’t circle the x’s that don’t help. A C
Example F = C F = ∑m(1, 3, 7) + ∑d(0, 5) Circle the x’s that help get bigger groups of 1’s (or 0’s if POS). Don’t circle the x’s that don’t help. B B A 00 01 11 10 X 1 3 2 4 5 7 6 A F = C C
Example F(A, B, C, D) = ∑ m(1, 3, 7, 11, 15) + ∑ d(0, 2, 5) Two possible solutions! Both acceptable. All 1’s covered
Chapter – 4 – Combinational Logic Circuit
Combinational Circuits Output is function of input only i.e. no feedback When input changes, output may change (after a delay) Combinational Circuits n inputs m outputs • •
Combinational Circuits Analysis Given a circuit, find out its function Function may be expressed as: Boolean function Truth table Design Given a desired function, determine its circuit ? ?
(A’+B’)(A’+C’)(B’+C’) Analysis Procedure Boolean Expression Approach ABC A+B+C AB'C'+A'BC'+A'B'C (A’+B’)(A’+C’)(B’+C’) AB+AC+BC F1=AB'C'+A'BC'+A'B'C+ABC F2=AB+AC+BC
Analysis Procedure Truth Table Approach A B C F1 F2 0 0 0 0 0 = 0 1
Analysis Procedure Truth Table Approach 1 0 A B C F1 F2 0 0 0 0 0 1 0 0 0 0 0 1 = 0 = 1 1 1 1 0 1 1
Analysis Procedure Truth Table Approach 1 0 A B C F1 F2 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 = 0 = 1 1 1 1 0 1 1
Analysis Procedure Truth Table Approach 0 1 A B C F1 F2 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 1 = 0 = 1 1 0 1 1
Analysis Procedure Truth Table Approach 1 0 A B C F1 F2 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 = 1 = 0 1 1 1 1 0 1
Analysis Procedure Truth Table Approach 0 1 A B C F1 F2 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 1 0 1 = 1 = 0 1 0 1 1
Analysis Procedure Truth Table Approach 0 1 A B C F1 F2 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 = 1 = 0 1 0 1 1
Analysis Procedure Truth Table Approach F1=AB'C'+A'BC'+A'B'C+ABC 0 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 = 1 1 1 1 1 1 B 1 A C B 1 A C F1=AB'C'+A'BC'+A'B'C+ABC F2=AB+AC+BC
Design Procedure Given a problem statement: Example: ? Determine the number of inputs and outputs Derive the truth table Simplify the Boolean expression for each output Produce the required circuit Example: Design a circuit to convert a “BCD” code to “Excess 3” code ? 4-bits 0-9 values 4-bits Value+3
Design Procedure BCD-to-Excess 3 Converter C B A D C B A D w = A+BC+BD 1 B A x D C 1 B A x D A B C D w x y z 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 x x x x 1 1 0 1 1 1 1 0 1 1 1 1 w = A+BC+BD x = B’C+B’D+BC’D’ C 1 B A x D C 1 B A x D y = C’D’+CD z = D’
Design Procedure BCD-to-Excess 3 Converter w = A + B(C+D) w x y z 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 x x x x 1 1 0 1 1 1 1 0 1 1 1 1 w = A + B(C+D) y = (C+D)’ + CD x = B’(C+D) + B(C+D)’ z = D’
Example Design a combinational circuit that obtains the square for the numbers from 0 ---- > 7 Solution: # i/ps = 3 # o/ps = 6 ( 49 )
Continue K-Maps (A, B, C, D, E, F) Then Implement the Circuit