K-map (short for Karnaugh map) is a graphical method of simplifying a boolean equation. It contains boxes which are filled according to information contained in the truth table.
K-map is ideally suited for designing the combinational logic circuits using either a SOP or POS method. K-maps can be written for 2,3,4.. up to 6 variables as shown below. Beyond that K-map technique becomes very cumbersome.
The number of boxes in a K-map is decided by the number of variables and is equal to 2n, where n is number of variables. Thus for a 4 variable equation, the K-map will contain 16 boxes.
The K-map is filled as per grey code so that as we move along a row or column, only one variable will change its value.
The simplification of a boolean expression using K-map involves combining or grouping of two or more adjacent cells so as to form a group of pairs or quads or octets, etc.
If an expression is to be minimized in SOP form, the K-map is filled with 1s corresponding to the minterms. However, the expression is to be minimized in POS form, the K-map is filled with 0s corresponding to the maxterms. Don't care conditions are marked with an “X” and are grouped if required or else ignored.