Karnaugh Maps Kiril Solovey Tel-Aviv University, Israel April 8, 2013 Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 1 / 22
Reminder: Canonical Representation Sum of Products Function described for the inputs for which it returns 1 f (x, y, z) Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 2 / 22
Reminder: Canonical Representation Sum of Products Function described for the inputs for which it returns 1 f (x, y, z) = (2, 3, 4, 6) = x yz + x yz + xy z + xyz Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 2 / 22
Reminder: Canonical Representation Product of Sums Function described for the inputs for which it returns 0 f (x, y, z) = (0, 1, 5, 7) = (x +y +z) (x +y +z ) (x +y +z ) (x +y +z ) Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 3 / 22
Canonical Representation is Wasteful The function will be written in SOP as f (x, y) = 1 f (x, y) = x y + x y + xy + xy Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 4 / 22
Karnaugh Maps Provide a geometric visualisation of boolean functions Simplify SOP/POS representation Reduce number of variables in boolean expression Reduce number of minterms in expression Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 5 / 22
K-maps for 3-variable functions Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 6 / 22
K-maps for 4-variable functions Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 7 / 22
Properties of K-maps SOP Every two neighbors (horizontal or vertical) differ in one bit Elements from first and last column (or row) are neighbors too If the value of two neighbors is 1 then their minterms can be merged xy + xy = x(y + y) = x 1 = x Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 8 / 22
Properties of K-maps SOP Every two neighbors (horizontal or vertical) differ in one bit Elements from first and last column (or row) are neighbors too If the value of two neighbors is 1 then their minterms can be merged xy + xy = x(y + y) = x 1 = x x 1 x 2 x 3 x 4 x 1 x 2x 3 x 4 Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 8 / 22
Properties of K-maps SOP Every two neighbors (horizontal or vertical) differ in one bit Elements from first and last column (or row) are neighbors too If the value of two neighbors is 1 then their minterms can be merged xy + xy = x(y + y) = x 1 = x x 1 x 3 x 4 Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 8 / 22
Properties of K-maps POS Similarly, for neighbors with value 0: (x + y)(x + y ) = xx + yx + y x + yy = x + x(y + y ) + 0 = x (x 1 + x 2 + x 3 + x 4 )(x 1 + x 2 + x 3 + x 4 ) Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 9 / 22
Properties of K-maps POS Similarly, for neighbors with value 0: (x + y)(x + y ) = xx + yx + y x + yy = x + x(y + y ) + 0 = x (x 1 + x 3 + x 4 ) Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 9 / 22
Properties of K-maps Similarly, clusters of 4,8,16 can be merged Cluster: Collection of cells that form a rectangle All cells in cluster have the same number of neighbors (> 0) Notice that variables whose value changes in the cluster vanish x 1 x 4 Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 10 / 22
K-maps Goal: cover all 1 s using a minimal number of clusters or all 0 s This results in the simplified representation of function (SOP/POS) Example: Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 11 / 22
Cluster-finding algorithm Put isolated 1 s (without neighbors) in separate clusters of size 1 Find 1 s for which there is only one cluster of size 2 that contains them Add the respective clusters of size 2 Find 1 s for which there is only one cluster of size 4 that contains them Add the respective clusters of size 4 Repeat for clusters of 8 and 16 * Use minimal number of clusters to cover leftover 1 s Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 12 / 22
Example Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 13 / 22
Example Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 13 / 22
Example Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 13 / 22
Example Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 13 / 22
Example Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 13 / 22
Unnecessary clusters Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 14 / 22
Examples (valid solution) Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 15 / 22
Don t cares The output of some functions is not defined for certain inputs For instance: circuit that implements a digital decimal digit Input is 4 bits (required to represent the number 9) Output of circuit for input > 9 is not defined Simplifying a function with don t cares ( ) Assign to every a value (0,1) Goal: Increase size of existing clusters with real 1 s Never add new clusters Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 16 / 22
Don t cares Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 17 / 22
Implementing a Full-Adder FA computes the addition of 3 input bits Has two output bits: S i for result, C i+1 for carry Task: implement FA with logical circuit Steps for solution: Find truth tables of Si and C i+1 Find minimal expression for Si, C i+1 using K-maps Draw circuits for minimal expressions Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 18 / 22
Implementing a Full-Adder Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 19 / 22
Implementing a Full-Adder Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 20 / 22
Beyond K-maps K-maps applicable to functions with few variables (3-5) How to implement more complex functions? Example: Implement adder of two 4-digit numbers 8 inputs 5 outputs Use more complex building blocks Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 21 / 22
Exercise: number of 1 s Input: 6 bits of input ABCDEF Output: number of 1 s in input Inventory: 3 FA, 1 HA Solution: Solve separately for ABC, DEF Combine the two results Result is represented by S 2 S 1 S 0 Kiril Solovey (TAU) Karnaugh Maps April 8, 2013 22 / 22