Minimization Methods 4-Variable Karnaugh Map (Review) f(a,b,c,d) ab c cd 00 01 11 a 10 00 01 11 10 m0 m1 m3 m2 m4 m5 m7 m6 m12 m13 m8 m9 m15 m11 b m14 m10 d Digital Logic Fundamentals 6 © ptb/dkb (January 19, 2024) 5 and 6 Variable Karnaugh Maps bc de a=0 00 01 11 10 8 00 01 11 10 0 1 3 2 5 13 9 00 10 24 28 00 16 01 11 10 6 12 8 ab=01 10 01 21 27 01 11 10 0 1 3 2 5 13 9 00 11 23 10 10 18 28 ab=11 00 01 16 21 10 26 cd ef 00 01 56 53 58 cd ef 00 01 10 Digital Logic Fundamentals 7 40 44 33 37 45 41 43 10 50 54 62 59 01 36 11 55 63 32 18 22 51 57 00 11 49 61 10 30 26 60 ab=10 23 31 48 11 19 27 00 11 17 29 6 14 10 01 52 30 15 25 24 22 7 11 01 20 19 31 00 4 cd ef 14 17 29 25 00 11 01 20 11 7 15 11 bc de a=1 ab=00 4 12 cd ef 11 35 39 47 10 34 38 46 42 © ptb/dkb (January 19, 2024) Karnaugh Map Based Minimization • The purpose of using K-maps is to aid in the simplification of logic expressions. • Use of 1’s in K-maps gives minterm SOP form directly. Use of 0’s in K-maps gives maxterm POS form directly. • Minterms (maxterms) that can be combined differ in exactly one bit position. • Minimization using K-maps is done by grouping “adjacent” minterms (maxterms). Digital Logic Fundamentals 16 © ptb/dkb (January 19, 2024) • Conditions for grouping: • Minterm (maxterm) groups are restricted to have size that is a power of 2, e.g., 1, 2, 4, 8, … • All K-map cells in a group must have a 1 as their K-map entry for grouping minterms (or 0 as their K-map entry for maxterm groups). • All minterms (maxterms) must be adjacent; they must differ in exactly i bits where, 2i is the size of the group. • To minimize a function, find the set of groups which include all the required minterms; the function is the sum of these groups (or if maxterms are used then the function is the product of the groups). • The larger the groups, the better. Why? Digital Logic Fundamentals 17 © ptb/dkb (January 19, 2024) Example: Grouping Minterms f(w,x,y,z) yz wx 00 01 11 1 1 1 1 00 10 0001 = m1 0011 = m3 1000 = m8 1001 = m9 1011 = m11 1100 = m12 01 Groupings: 11 1 10 1 {m1,m3} {m9,m11} {m1,m9} {m8,m9} {m3,m11} {m8,m12} Simplified Expression: Digital Logic Fundamentals Minterms: {m1,m3,m9,m11} f(w,x,y,z) = {m1,m3,m9,m11} + {m8,m12} x z wyz 18 © ptb/dkb (January 19, 2024) Example: Grouping Maxterms f(w,x,y,z) yz wx 00 01 11 10 00 0 1 1 0 01 0 0 0 0 11 1 0 0 0 10 1 1 1 0 Maxterms: Groupings (note: all groupings are not listed): 0000 = M0 0010 = M2 0100 = M4 0101 = M5 0110 = M6 0111 = M7 1010 = M10 1101 = M13 1110 = M14 1111 = M15 {M0,M2,M4,M6}, {M4,M5,M6,M7}, {M5,M7,M13,M15}, {M2,M6,M10,M14}, {M6,M7,M14,M15} Simplified Expression: f(w,x,y,z) = {M0,M2,M4,M6}{M5,M7,M13,M15} {M2,M6,M10,M14} w z x z y z Digital Logic Fundamentals 21 © ptb/dkb (January 19, 2024) Logic Minimization: Example 1 x yz 00 0 1 1 1 01 11 10 1 1 1 Sum of Products: x yz 00 01 11 10 0 1 0 1 1 1 1 0 0 1 Product of Sums: F(x,y,z) = y z x z F(x,y,z) = z x y # INV = 2 # AND2 = 1 # OR2 = 2 # INV = 2 # AND2 = 1 # OR2 = 1 For example 1 SOP is SMALLER © ptb/dkb (January 19, 2024) Digital Logic Fundamentals 22 Logic Minimization: Example 2 wx yz 00 01 11 10 00 0 1 0 0 01 0 1 1 0 11 1 1 1 1 10 1 1 0 0 POS: SOP: F w , x , y , z w x w y y z x z F w , x , y , z w z x y # INV = 1 # AND2 = 1 # OR2 = 2 # INV = 1 # AND2 = 4 # OR2 = 3 For example 2 POS is SMALLER © ptb/dkb (January 19, 2024) Digital Logic Fundamentals 23 5-Variable Minimization Minimize: F a, b, c, d , e 2,5,7,8,10,13,15,17,19, 21, 23, 24, 29,31 bc de a=0 1 1 1 bc de a=1 00 00 01 1 01 Digital Logic Fundamentals 10 1 1 11 11 1 1 11 10 01 00 01 10 00 1 1 11 F ce abe bcd e acd e 10 1 1 1 1 24 © ptb/dkb (January 19, 2024) Don’t Care Input Combinations • Sometimes functions are incompletely specified; the function is not defined for some minterms. outputs really don’t matter when these input combinations occur, or these input combinations never occur in normal operation. • These input combinations are known as don’t care conditions. • Don’t cares are entered as X’s in the K-map (sometimes D or d are also used). • During simplification, X’s can be treated as 1’s or 0’s. Digital Logic Fundamentals 25 © ptb/dkb (January 19, 2024) Don’t Care: Example G a , b , c , d 0,4,8,12 ,13 d 5 ,11 G cd 00 ab 01 00 1 01 1 X 11 1 1 10 1 11 10 X G a , b , c , d b c c d Digital Logic Fundamentals 26 © ptb/dkb (January 19, 2024) Example: Combinational Logic Design • Design a circuit that accepts binary numbers between 1 and 5 and generates an output equal to the number of 1’s in the input. Use only 2-input logic gates. • Determine the number of inputs and outputs • No. of inputs = 3 • No. of outputs = 2 © ptb/dkb (January 19, 2024) Digital Logic Fundamentals 27 2. K-maps and logic minimization 1. Create a truth table Inputs Outputs b2 b1 b0 z1 z0 0 0 0 X X 0 0 1 0 1 0 1 0 0 1 z0 b1 b0 00 b2 01 0 X 1 1 1 0 1 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 0 X X 1 1 1 X X Digital Logic Fundamentals 10 1 X X z 0 b0 b2 b1 z1 b1 b0 00 b2 © ptb/dkb (January 19, 2024) 11 1 or 01 X 11 10 1 1 X X z1 b2 b0 b1 b0 z1 b0 b2 b1 28 3. Gate level implementation z1 b0 b2 b1 z 0 b0 b2 b1 How fast can you run this circuit (or what is the throughput) ? (i.e., how often can you supply new inputs to this circuit) © ptb/dkb (January 19, 2024) Digital Logic Fundamentals 29 Example: • Design a circuit that will increment a BCD digit by 1 and produce an output BCD digit. X cd W cd ab 00 a b c d W X Y Z 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 1 0 1 0 0 11 X 0 1 0 0 0 1 0 1 10 1 0 1 0 1 0 1 1 0 0 1 1 0 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 0 1 0 X X X X X X X X X X X X … 1 1 1 1 01 11 10 00 01 1 01 X 1 X X 11 X X X 10 W ad bcd 10 1 X X X X X bc bd bcd Y cd ab 01 1 X 11 1 00 00 Z cd 00 01 11 10 ab 00 01 11 10 00 1 1 00 1 1 01 1 1 01 1 1 11 X X X X 11 X X X 10 1 10 Y a c d cd © ptb/dkb (January 19, 2024) ab Digital Logic Fundamentals X X X X X Z d 30 Do it yourself • Obtain minimum SOP and POS expressions for the following functions. For selected problems, implement circuits using NAND and NOR gates. F (W , X , Y , Z ) (0, 2,5, 7,8,10,13) d (1,9,11) F ( A, B, C ) (1, 2,3,5, 6) D(4) F (W , X , Y , Z ) (0,3, 4,5, 6, 7,11,12,13,14,15) F (W , X , Y , Z ) (2,3, 6, 7,8,9,12,13) F ( A, B, C ) (4, 6) F ( A, B, C ) (2,3) F ( A, B, C ) (1, 2,3,5, 7) © ptb/dkb (January 19, 2024) Digital Logic Fundamentals 31 Do it yourself • Using Boolean axioms and/or theorems manipulate the OR function F = X + Y so that it can be implemented with only AND elements and INVERTERS. Use parentheses to clearly indicate the order of intended operations. Draw circuit and verify that circuit satisfies the OR function (easy). Digital Logic Fundamentals 32 © ptb/dkb (January 19, 2024) Some Definitions • Implicant : A product term that evaluates a function to a ‘1’ is called an implicant of the function • Prime implicant is an implicant that cannot be combined into another implicant having fewer literals. • Cover : A collection of implicants that accounts for all valuations for which my function equals ‘1’ • Cost : Cost of the implementing a cover can be defined as the sum of the number of gates and number of inputs to the gates. Digital Logic Fundamentals 33 © ptb/dkb (January 19, 2024) Quine-McCluskey Minimization Method • It is a tabular method involving identification of prime implicants and minimal cover (minimum set of prime implicants) • Prime implicants are determined using an iterative procedure in which variables are eliminated by applying adjacency • Minimal cover is determined using a prime implicant chart from which the essential prime implicants and a minimal set of remaining prime implicants so that all minterms are covered • Suitable for use in logic minimization software Digital Logic Fundamentals 34 © ptb/dkb (January 19, 2024) Example 1 f a, b, c, d 4,5,6,8,9,10,13 d 0,7,15 • Minimize 1. List the minterms along with don’t cares and arrange them in groups according to the number of 1’s in the minterms (d) m0 0000 m4 0100 m5 0101 group 0 0000 group 1 1000 m6 0110 0101 (d) m7 0111 0110 m8 1000 group 2 m10 1010 m13 1101 (d) m15 1111 1001 1010 m9 1001 © ptb/dkb (January 19, 2024) 0100 group 3 0111 1101 group 4 1111 Digital Logic Fundamentals After grouping we only need to compare minterms from adjacent groups Don’t cares are included in this step. 35 Example 1 (contd…) 2. Compare and combine entries in adjacent groups in column 1 and fill up entries in column 2: Compare groups 0 and 1: mark those that can be combined by a check mark (√ ); If an entry cannot be combined, mark with a star. These are the prime implicants. Column 1 0 0000 √ 4 0100 √ 8 1000 5 0101 6 0110 9 1001 Column 2 (0,4) 0-00 10 1010 7 0111 13 1101 15 © ptb/dkb (January 19, 2024) 1111 Digital Logic Fundamentals 36 Example 1 (contd…) 2. Compare entries in adjacent groups in column 1 and fill up entries in column 2: compare groups 0 and 1 Column 1 Column 2 0 0000 √ (0,4) 0-00 4 0100 √ (0,8) -000 8 1000 √ 5 0101 6 0110 9 1001 10 1010 7 0111 13 1101 15 © ptb/dkb (January 19, 2024) 1111 Digital Logic Fundamentals 37 Example 1 (contd…) 2. Compare entries in adjacent groups in column 1 and fill up entries in column 2: compare groups 1 and 2 Column 1 Column 2 0 0000 √ (0,4) 0-00 4 0100 √ (0,8) -000 8 1000 √ (4,5) 010- 5 0101 √ 6 0110 9 1001 10 1010 7 0111 13 1101 15 © ptb/dkb (January 19, 2024) 1111 Digital Logic Fundamentals 38 Example 1 (contd…) 2. Compare entries in adjacent groups in column 1 and fill up entries in column 2: compare groups 1 and 2 Column 1 © ptb/dkb (January 19, 2024) Column 2 0 0000 √ (0,4) 0-00 4 0100 √ (0,8) -000 8 1000 √ (4,5) 010- 5 0101 √ (4,6) 01-0 6 0110 √ (8,9) 100- 9 1001 √ (8,10) 10-0 10 1010 √ 7 0111 13 1101 15 1111 Digital Logic Fundamentals 39 Example 1 (contd…) 2. Compare entries in adjacent groups in column 1 and fill up entries in column 2: Compare remaining groups and complete column 2 Divide column 2 into groups © ptb/dkb (January 19, 2024) Column 1 Column 2 0 0000 √ (0,4) 0-00 4 0100 √ (0,8) -000 8 1000 √ (4,5) 010- 5 0101 √ (4,6) 01-0 6 0110 √ (8,9) 100- 9 1001 √ (8,10) 10-0 10 1010 √ (5,7) 01-1 7 0111 √ (5,13) -101 13 1101 √ (6,7) 011- 15 1111 √ (9,13) 1-01 (7,15) -111 (13,15) 1-11 Digital Logic Fundamentals 40 Example 1 (contd…) 3. Compare entries in adjacent groups in column 2 and fill up entries in column 3. Repeat until nothing can be combined. Column 1 © ptb/dkb (January 19, 2024) Column 2 Column 3 0 0000 √ (0,4) 0-00 * (4,5,6,7) 01-- * 4 0100 √ (0,8) -000 * (5,7,13,15) -1-1 * 8 1000 √ (4,5) 010- √ 5 0101 √ (4,6) 01-0 √ 6 0110 √ (8,9) 100- * 9 1001 √ (8,10) 10-0 * 10 1010 √ (5,7) 01-1 √ 7 0111 √ (5,13) -101 √ 13 1101 √ (6,7) 011- √ 15 1111 √ (9,13) 1-01 * (7,15) -111 √ (13,15) 11-1 √ Digital Logic Fundamentals 41 Example 1 (contd…) • Prime Implicant Chart: It is the second part of the Quine-McCluskey algorithm. • It is used to select a minimum set of prime implicants. • Essential Prime implicants are listed along the vertical axis of the table (i.e., rows of the table). • The minterms are listed along the horizontal axis (i.e., columns of the table). • Entry (i, j) of the table is marked if the minterm at the head of column j is contained in (covered by) prime implicant in row i. • Similar to the Karnaugh map, we first select the essential prime implicants, and then we select enough prime implicants to cover all the minterms of the function. Digital Logic Fundamentals 42 © ptb/dkb (January 19, 2024) Example 1 (contd…) minterms prime implicants m4 m5 m6 m8 (0,4) 0-00 (0,8) -000 X (8,9) 100- X (8,10) 10-0 X (9,13) 1-01 (4,5,6,7) 01-- (5,7,13,15) -1-1 m9 m10 m13 X X X X X X X X X X Do not include don’t cares in this table. They need not be covered by the final expression • Look for minterms that are covered by a single prime implicant. The prime implicant which contains that minterm will be in the minimal expression. Mark as “covered” all minterms contained in such prime implicants • Choose the minimum number of additional (from non-essential) prime implicants required to cover the remaining minterms. F (a, b, c, d ) a b a b d a c d © ptb/dkb (January 19, 2024) Digital Logic Fundamentals 44 Minimize: F a, b, c, d , e 2,5,7,8,10,13,15,17,19, 21, 23, 24, 29,31 Example 2 2 8 5 10 17 24 7 13 19 21 15 23 29 31 © ptb/dkb (January 19, 2024) 00010 01000 00101 01010 10001 11000 00111 01101 10011 10101 01111 10111 11101 11111 √ √ √ √ √ √ √ √ √ √ √ √ √ √ 0-010 010-0 -1000 001-1 0-101 -0101 100-1 0-111 -0111 011-1 -1101 10-11 101-1 1-101 -1111 1-111 111-1 * * * √ √ √ √ √ √ √ √ √ √ √ √ √ √ Digital Logic Fundamentals 0-1-1 -01-1 0-1-1 --101 -01-1 --101 10--1 --111 -11-1 -11-1 1-1-1 1-1-1 * √ --1-1 * --1-1 √ * √ √ * 45 Example 2: m2 0-010 Prime Implicant Chart m5 m7 m8 X m19 X -1000 X m23 m24 m29 m31 X X X X X X 10--1 X 1-1-1 --1-1 m21 X 010-0 0-1-1 m10 m13 m15 m17 X X X X X X X X X X X X X X X F a, b, c, d , e a c d e b c d e a b e c e © ptb/dkb (January 19, 2024) Digital Logic Fundamentals 46