EE2504 Elec. Sys. : Karnaugh maps Course EE2504 – Lecturer: Dr F. Verdicchio 1 K-maps Truth-Table Example: FULL ADDER A B Cin Cout Sum Sum Cout 0 0 0 00 00 0 0 1 10 01 0 1 0 10 01 0 1 1 01 10 1 0 0 10 01 1 0 1 01 10 1 1 0 01 10 1 1 1 11 11 Sum = ( A’ * B’ * Cin ) + ( A’ * B * Cin’ ) + ( A * B’ * Cin’ ) + ( A * B * Cin ) Cout = ( A’ * B * Cin ) + ( A * B’ * Cin ) + ( A * B * Cin’ ) + ( A * B * Cin ) 2 K-maps K-map: example table structure for 3 boolean variables A, B, C 3 K-maps Aim: Map each output column (example: Cout ) to a matrix A AB A B Cin Cout Sum Sum Cout 0 0 0 00 00 0 0 1 10 01 0 1 0 10 01 00 01 11 10 0 1 1 01 10 0 . . . . 1 0 0 10 01 1 . . . . 1 0 1 01 10 1 1 0 01 10 1 1 1 11 11 Cin B 4 K-maps K-map: example table structure for 3 boolean variables A, B, C First: The map has 8 entries, one for each possible input combination. At most two variables can be associated with each row (or col). 5 K-maps K-map: example table structure for 3 boolean variables A, B, C First: The map has 8 entries, one for each possible input combination. At most two variables can be associated with each row (or col). So, let’s pick a 2x4 table AB C . . . . . . . . 6 K-maps K-map: example table structure for 3 boolean variables A, B, C First: The map has 8 entries, one for each possible input combination. At most two variables can be associated with each row (or col). Second: arrange variables along rows/cols following gray-code indexing AB 00 01 11 10 0 . . . . 1 . . . . C 7 K-maps K-map: example table structure for 3 boolean variables A, B, C First: The map has 8 entries, one for each possible input combination. At most two variables can be associated with each row (or col). Second: arrange variables along rows/cols following gray-code indexing Gray code indexing scheme AB 00 01 11 10 0 . . . . 1 . . . . C 8 K-maps K-map: example table structure for 3 boolean variables A, B, C First: The map has 8 entries, one for each possible input combination. At most two variables can be associated with each row (or col). Second: arrange variables along rows/cols following gray-code indexing A AB 00 01 11 10 0 . . . . 1 . . . . C B 9 K-maps K-map: example table structure for 3 boolean variables A, B, C First: The map has 8 entries, one for each possible input combination. At most two variables can be associated with each row (or col). Second: arrange variables along rows/cols following gray-code indexing A AB 00 01 11 10 0 . . . . 1 . . . . C C B 10 K-maps K-map: example table structure for 3 boolean variables A, B, C First: The map has 8 entries, one for each possible input combination. At most two variables can be associated with each row (or col). Second: arrange variables along rows/cols following gray-code indexing A’ A AB 00 01 11 10 0 . . . . 1 . . . . C C B 11 K-maps K-map: example table structure for 3 boolean variables A, B, C First: The map has 8 entries, one for each possible input combination. At most two variables can be associated with each row (or col). Second: arrange variables along rows/cols following gray-code indexing A’ A AB C 00 01 11 10 C’ 0 . . . . C 1 . . . . B 12 K-maps K-map: example table structure for 3 boolean variables A, B, C First: The map has 8 entries, one for each possible input combination. At most two variables can be associated with each row (or col). Second: arrange variables along rows/cols following gray-code indexing A’ A AB C 00 01 11 10 C’ 0 . . . . C 1 . . . . B’ B B’ 13 K-maps K-map: example table structure for 3 boolean variables A, B, C First: The map has 8 entries, one for each possible input combination. At most two variables can be associated with each row (or col). Second: arrange variables along rows/cols following gray-code indexing A AB 00 01 11 10 0 . . . . 1 . . . . C C B 14 K-maps K-map: example table structure for 3 boolean variables A, B, C First: The map has 8 entries, one for each possible input combination. At most two variables can be associated with each row (or col). Second: arrange variables along rows/cols following gray-code indexing Third: fill the table (with 0 and 1 from the truth table) A AB 00 01 11 10 0 . . . . 1 . . . . C C B 15 K-maps K-map example: Cout for Full adder. A AB B Cin Cout Sum Sum Cout 0 0 0 00 00 0 0 1 10 01 0 1 0 10 01 00 01 11 10 0 1 1 01 10 0 . . . . 1 0 0 10 01 1 . . . . 1 0 1 01 10 1 1 0 01 10 1 1 1 11 11 Cin Cin A B 16 K-maps K-map example: Cout for Full adder. A AB B Cin Cout Sum Sum Cout 0 0 0 00 00 0 0 1 10 01 0 1 0 10 01 00 01 11 10 0 1 1 01 10 0 . . . . 1 0 0 10 01 1 . . . . 1 0 1 01 10 1 1 0 01 10 1 1 1 11 11 Cin Cin A B 17 K-maps K-map example: Cout for Full adder. A AB B Cin Cout Sum Sum Cout 0 0 0 00 00 0 0 1 10 01 0 1 0 10 01 00 01 11 10 0 1 1 01 10 0 . . . . 1 0 0 10 01 1 . . . . 1 0 1 01 10 1 1 0 01 10 1 1 1 11 11 Cin Cin A B 18 K-maps K-map example: Cout for Full adder. A AB B Cin Cout Sum Sum Cout 0 0 0 00 00 0 0 1 10 01 0 1 0 10 01 00 01 11 10 0 1 1 01 10 0 . . . . 1 0 0 10 01 1 . 1 . . 1 0 1 01 10 1 1 0 01 10 1 1 1 11 11 Cin Cin A B 19 K-maps K-map example: Cout for Full adder. A AB B Cin Cout Sum Sum Cout 0 0 0 00 00 0 0 1 10 01 0 1 0 10 01 00 01 11 10 0 1 1 01 10 0 . . . . 1 0 0 10 01 1 . 1 . 1 1 0 1 01 10 1 1 0 01 10 1 1 1 11 11 Cin Cin A B 20 K-maps K-map example: Cout for Full adder. A AB B Cin Cout Sum Sum Cout 0 0 0 00 00 0 0 1 10 01 0 1 0 10 01 00 01 11 10 0 1 1 01 10 0 . . 1 . 1 0 0 10 01 1 . 1 . 1 1 0 1 01 10 1 1 0 01 10 1 1 1 11 11 Cin Cin A B 21 K-maps K-map example: Cout for Full adder. A AB B Cin Cout Sum Sum Cout 0 0 0 00 00 0 0 1 10 01 0 1 0 10 01 00 01 11 10 0 1 1 01 10 0 . . 1 . 1 0 0 10 01 1 . 1 1 1 1 0 1 01 10 1 1 0 01 10 1 1 1 11 11 Cin Cin A B 22 K-maps K-map example: Cout for Full adder. A AB B Cin Cout Sum Sum Cout 0 0 0 00 00 0 0 1 10 01 0 1 0 10 01 00 01 11 10 0 1 1 01 10 0 0 0 1 0 1 0 0 10 01 1 0 1 1 1 1 0 1 01 10 1 1 0 01 10 1 1 1 11 11 Cin Cin A B 23 K-maps Minimization using K-map example: Cout for Full adder. Sum of products: Each square in the K-map corresponds to a product of 3 literals. Cout = ( A*B*Cin’ ) + (A’*B*Cin) + (A*B*Cin) + (A*B’*Cin) A AB 00 01 11 10 0 0 0 1 0 1 0 1 1 1 Cin Cin B 24 K-maps Minimization using K-map example: Cout for Full adder. Sum of products: Each square in the K-map corresponds to a product of 3 literals. The objective is to group squares (of all 1s ) that are horizontally or vertically adjacent. A AB 00 01 11 10 0 0 0 1 0 1 0 1 1 1 Cin Cin B 25 K-maps Minimization using K-map example: Cout for Full adder. Sum of products: Each square in the K-map corresponds to a product of 3 literals. The objective is to group squares (of all 1s ) that are horizontally or vertically adjacent. A group of two adjacent blocks corresponds to the product of 2 literals. A AB 00 01 11 10 0 0 0 1 0 1 0 1 1 1 Cin Cin B 26 K-maps Minimization using K-map example: Cout for Full adder. Sum of products: Each square in the K-map corresponds to a product of 3 literals. The objective is to group squares (of all 1s ) that are horizontally or vertically adjacent. A group of two adjacent blocks corresponds to the product of 2 literals. Cout = ( B*Cin ) + ... A AB 00 01 11 10 0 0 0 1 0 1 0 1 1 1 Cin Cin B 27 K-maps Minimization using K-map example: Cout for Full adder. Sum of products: Each square in the K-map corresponds to a product of 3 literals. The objective is to group squares (of all 1s ) that are horizontally or vertically adjacent. A group of two adjacent blocks corresponds to the product of 2 literals. Cout = ( B*Cin ) + ( A*B ) +... A AB 00 01 11 10 0 0 0 1 0 1 0 1 1 1 Cin Cin B 28 K-maps Minimization using K-map example: Cout for Full adder. Sum of products: Each square in the K-map corresponds to a product of 3 literals. The objective is to group squares (of all 1s ) that are horizontally or vertically adjacent. A group of two adjacent blocks corresponds to the product of 2 literals. Cout = ( B*Cin ) + ( A*B ) + ( A*Cin ) A AB 00 01 11 10 0 0 0 1 0 1 0 1 1 1 Cin Cin B 29 K-maps Minimization using K-map example: Cout for Full adder. Sum of products: Each square in the K-map corresponds to a product of 3 literals. The objective is to group squares (of all 1s ) that are horizontally or vertically adjacent. A group of two adjacent blocks corresponds to the product of 2 literals. (Any leftover square needs to be included separately.) Cout = ( B*Cin ) + ( A*B ) + ( A*Cin ) A AB 00 01 11 10 0 0 0 1 0 1 0 1 1 1 Cin Cin B 30 K-maps Minimization using K-map example: Cout for Full adder. Sum of products: Each square in the K-map corresponds to a product of 3 literals. The objective is to group squares (of all 1s ) that are horizontally or vertically adjacent. A group of two adjacent blocks corresponds to the product of 2 literals. (Any leftover square needs to be included separately.) Cout = ( B*Cin ) + ( A*B ) + ( A*Cin ) Cout = ( A’ * B * Cin ) + ( A * B’ * Cin ) + ( A * B * Cin’ ) + ( A * B * Cin ) 31 K-maps Minimization using K-map example: Cout for Full adder. Product of sums: Each square (with a 0) in the K-map corresponds to a sum of 3 literals. The objective is to group squares (of all 0s ) that are horizontally or vertically adjacent. A group of two adjacent blocks corresponds to the sum of 2 literals. Mind the index (reversed compared to sum of products)!! Cout = ( A+Cin ) * ... A AB 00 01 11 10 0 0 0 1 0 1 0 1 1 1 Cin Cin B 32 K-maps Minimization using K-map example: Cout for Full adder. Product of sums: Each square (with a 0) in the K-map corresponds to a sum of 3 literals. The objective is to group squares (of all 0s ) that are horizontally or vertically adjacent. A group of two adjacent blocks corresponds to the sum of 2 literals. Mind the index (reversed compared to sum of products)!! Cout = ( A+Cin ) * (A+B) *... A AB 00 01 11 10 0 0 0 1 0 1 0 1 1 1 Cin Cin B 33 K-maps Minimization using K-map example: Cout for Full adder. Product of sums: Each square (with a 0) in the K-map corresponds to a sum of 3 literals. The objective is to group squares (of all 0s ) that are horizontally or vertically adjacent. A group of two adjacent blocks corresponds to the sum of 2 literals. Mind the index (reversed compared to sum of products)!! Cout = ( A+Cin ) * (A+B) *(Cin+B) A AB 00 01 11 10 0 0 0 1 0 1 0 1 1 1 Cin Cin B 34 K-maps Minimization using K-map : Where to stop. Once all the adjacent blocks have been grouped the form is minimal. 35 K-maps Minimization using K-map : Where to stop. Once all the adjacent blocks have been grouped the form is minimal. Note: when four adjacent square exists, for example in the following table, then a one-literal term product appears A Y=B AB 00 01 11 10 0 0 1 1 0 1 0 1 1 0 C Cin B 36 K-maps Minimization using K-map : Where to stop. Once all the adjacent blocks have been grouped the form is minimal. Note: when four adjacent square exists, for example in the following table, then a one-literal term product appears A Y=B AB 00 01 11 10 0 0 1 1 0 1 0 1 1 0 C Cin B 37 K-maps Minimization using K-map : Where to stop. Once all the adjacent blocks have been grouped the form is minimal. Note: when four adjacent square exists, for example in the following table, then a one-literal term product appears A Y= AB 00 01 11 10 0 0 1 1 0 1 0 1 1 1 C Cin B 38 K-maps Minimization using K-map : Where to stop. Once all the adjacent blocks have been grouped the form is minimal. Note: when four adjacent square exists, for example in the following table, then a one-literal term product appears A Y = B + ... AB 00 01 11 10 0 0 1 1 0 1 0 1 1 1 C Cin B 39 K-maps Minimization using K-map : Where to stop. Once all the adjacent blocks have been grouped the form is minimal. Note: when four adjacent square exists, for example in the following table, then a one-literal term product appears A Y = B + A B’ C AB 00 01 11 10 0 0 1 1 0 1 0 1 1 1 C Cin B 40 K-maps Minimization using K-map : Where to stop. Once all the adjacent blocks have been grouped the form is minimal. Note: when four adjacent square exists, for example in the following table, then a one-literal term product appears A Y = B + AC AB 00 01 11 10 0 0 1 1 0 1 0 1 1 1 C Cin B 41 Observation: • Up to 4 (input) variables can be arranged in a two-dimensional Kmap. If you try to place more than two variables along the rows (or the columns) of the matrix below, adjacent blocks of 1s or 0s loose their meaning − which makes a K-map pointless. A AB CD 00 11 01 10 00 01 C D 11 10 B 42 Observation: • Up to 4 (input) variables can be arranged in a two-dimensional Kmap. If you try to place more than two variables along the rows (or the columns) of the matrix below, adjacent blocks of 1s or 0s loose their meaning − which makes a K-map pointless. X A ABX CD 000 110 010 100 101 011 111 001 00 01 C D 11 10 B B 43 Observation: • Up to 4 (input) variables can be arranged in a two-dimensional Kmap. If you try to place more than two variables along the rows (or the columns) of the matrix below, adjacent blocks of 1s or 0s loose their meaning − which makes a K-map pointless. • For more than 4 variables you need tri-dimensional K-map (not discussed in this course): instead apply SoP (or PoS) to the truth table. A AB CD 00 11 01 10 00 01 C D 11 10 B 44 Questions?! (otherwise let’s move on) 45 Application ─ 1-bit multiplexer (MUX) Boolean function: 1 output, 3 inputs In0, In1 and Sel. When Sel=0 then out=In0; when Sel=1 then out=In1. In1 In0 Sel=1 out Sel=0 Sel Block scheme 46 Application ─ 1-bit multiplexer (MUX) Boolean function: 1 output, 3 inputs In0, In1 and Sel. When Sel=0 then out=In0; when Sel=1 then out=In1. In1 In0 Sel=1 out Sel=0 Sel Block scheme 47 Application ─ 1-bit multiplexer (MUX) Boolean function: 1 output, 3 inputs In0, In1 and Sel. When Sel=0 then out=In0; when Sel=1 then out=In1. In1 In0 Sel=1 Sel=0 Sel Block scheme out Sel In1 In0 out 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 Truth Table 48 Application ─ 1-bit multiplexer (MUX) Sel In1 In0 out 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 49 Application ─ 1-bit multiplexer (MUX) Sel In1 In0 out 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 Using Sum of Products (SoP): out = (Sel’ * In1’ * In0) + (Sel’ * In1 * In0) + (Sel * In1 * In0’) + (Sel * In1 * In0) 50 Application ─ 1-bit multiplexer (MUX) Sel In1 In0 out 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 Using Sum of Products (SoP): out = [(Sel’ * In1’ * In0) + (Sel’ * In1 * In0)] + [(Sel * In1 * In0’) + (Sel * In1 * In0)] 51 Application ─ 1-bit multiplexer (MUX) Sel In1 In0 out 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 Using Sum of Products (SoP) and a little Boolean Algebra: out = [ (Sel’ * In0)*(In1’ + In1) ] + [(Sel * In1)*(In0’ + In0) ] 52 Application ─ 1-bit multiplexer (MUX) Sel In1 In0 out 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 Using Sum of Products (SoP) and a little Boolean Algebra: out = [ (Sel’ * In0) ] + [ (Sel * In1) ] 53 Application ─ 1-bit multiplexer (MUX) Sel In1 In0 out 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 In0 Using the k-map: In0 In1 00 01 11 10 0 0 0 1 1 1 0 1 1 0 Sel Sel In1 54 Application ─ 1-bit multiplexer (MUX) out = ( Sel’ * In0 ) + ( Sel * In1 ) In0 Using the k-map: In0 In1 00 01 11 10 0 0 0 1 1 1 0 1 1 0 Sel Sel In1 55 Application of a MUX Function F(A) based on a conditional test Ctest(A) performed on A. The test can be either true or false (e.g A>0). If the test is true: F(A) performs FT(A), Otherwise: F(A) performs FF(A). FT(A) if Ctest (A) = true F(A) = FF(A) if Ctest (A) = false 56 Application of a MUX Function F(A) based on a conditional test Ctest(A) performed on A. The test can be either true or false (e.g A>0). If the test is true: F(A) performs FT(A), Otherwise: F(A) performs FF(A). FT(A) In1 A FF(A) In0 Out out Sel Ctest(A) F(A) 57