You are on page 1of 16

WEEK 2.

3 KARNAUGH MAPS

1
Logic Minimization with Karnaugh Maps (KMaps)

 Boolean algebra can be used to find minimal SOP (POS) logic equations, but it
is hard to automate and not very systematic.

 For small logic functions (<=5 inputs), we can use Karnaugh Map (KMap).
KMaps allow us to minimize functions graphically.

 A KMap is simply an alternative representation to a truth table.

ECE124 Digital Circuits and Systems Page 2


Logic Minimization with Karnaugh Maps (KMaps)

 A KMap contains all the same information as a truth table, but in a different
form:
– While a truth table is “tabular”, the KMap is arranged as a grid of squares.
– The “coordinates” of a square depend on values of the inputs;
– The contents of any square is 0 or 1 and is the function’s output for the
corresponding input.
– In labeling the rows and columns of a KMap, it is important that only 1
variable changes between adjacent rows and columns (i.e., the rows and
columns are labeled with grey code counting).

 We will use examples to both illustrate KMaps and to see how they help us
minimize logic equations.

ECE124 Digital Circuits and Systems Page 3


KMaps (2-Variable Functions)
• Consider a logic function with two inputs.

• Canoncial SOP using minterms is:

• Consider presenting the information in the truth table via a 2-D matrix such that all the
same information is presented!

This is a 2-variable Karnaugh map.

ECE124 Digital Circuits and Systems Page 4


KMaps (2-Variable Functions)
• We can encompass groups of minterms via rectangles.

• Notice: in the first column (where x1 = 0), the function must output a logical 1. Further,
note that the value of x2 does not matter (it can be 0 or 1).
• Similar situation for the second row (where x2 = 1 and the value of x1 does not matter).
• Each of these rectangles represents a product term for the logic function f. We need to
“cover” all of the “1”s of the function so we can write a SOP using product terms.

• Minimum SOP using product terms is:

ECE124 Digital Circuits and Systems Page 5


KMaps (3-Variable Functions)
• Consider a logic function with three inputs. If represented as a canonical SOP,
this logic function would require 4 minterms in the expression.

• Represent the same information as a 2-D matrix. This is a 3-variable Karnaugh


map.
• Note: we always number such that only one
variable changes between adjacent columns or
rows (Gray codes).
• Note: columns (and rows) wrap around from
left-to-right (top-to-bottom).

ECE124 Digital Circuits and Systems Page 6


KMaps (3-Variable Functions)
• We can enclose “1”s for the logic function.
– In the 3-rd column, we see the function is “1” with x1=1 and x2=1 regardless of the value of
x3;
– In the 2-nd row, we see the function is “1” with x2=0 and x3 = 1 regardless of the value of x1.
– Each of the rectangles corresponds to a product term.
• Notice that, in adjacent squares, only 1 variable is changing its value.

• The SOP of the function using product terms is

ECE124 Digital Circuits and Systems Page 7


KMaps (More Examples of 3-Variable Functions)
• Example 1:

• Example 2:

ECE124 Digital Circuits and Systems Page 8


Some Comments
• To properly implement a function using K-Maps, we must make sure to select
enough rectangles (product terms) to cover all of the squares for which the
function outputs a “1”.

• Rectangles in the K-Map (product terms) are always powers of 2 in terms of


area.
– Minterms are rectangles of area 1 (1x1).
– Product terms are rectangles of area 2 (1x2,2x1), area 4 (2x2,1x4,4x1), area
8, area 16, etc…

• Every time we can expand a rectangle to enclose additional “1”s, we remove a


literal from the product term.

• Note that it is okay to cover an output “1” multiple times!

ECE124 Digital Circuits and Systems Page 9


KMaps (4-Variable Functions)
• Consider a function with 4-inputs (truth table not shown).

• Enclosing larger squares are better, as it implies fewer literals and product
terms.

ECE124 Digital Circuits and Systems Page 10


KMaps (More Examples of 4-Variable Functions)

• Sometimes there are multiple representations for a function that


are equally as good in terms of the number of literals and
product terms required.

ECE124 Digital Circuits and Systems Page 11


Watch Out for Corners!
• Important to make sure we see all rectangles, especially around the edges and
corners.

ECE124 Digital Circuits and Systems Page 12


KMaps (5-Variable Functions)
• Slightly harder to visualize, but still do-able by hand. View one of the 4-
variable Kmaps to be on top of the other 4-variable Kmap; i.e., we are using
the 3-rd axis.

x1x2
x1x2 x1x2
x3x4 00 01 11 10
x3x4 00 01 11 10 x3x4 00 01 11 10
00
x5=0
00 1 0 0 1 00 1 0 0 1 01
m0 m8 m24 m16 m1 m9 m25 m17
11
x1x2
01 0 1 1 0 01 0 1 1 0
m2 m10 m26 m18 m3 m11 m27 m19 10 x3x4 00 01 11 10

11 0 1 1 0 11 0 1 1 1 00
m6 m14 m30 m22 m7 m15 m31 m23 x5=1
01
10 0 1 0 0 10 0 1 0 1
m4 m12 m28 m20 m5 m13 m29 m21 11

10
x5=0 x5=1

ECE124 Digital Circuits and Systems Page 13


KMaps (5-Variable Functions)
• Slightly harder to visualize, but still do-able by hand.

ECE124 Digital Circuits and Systems Page 14


Some Comments
• So far we have used KMaps to find minimized SOP representations for
functions.

• Our general strategy is as follows:


– Find product terms with as few literals as possible (by finding larger
rectangles in the K-Map covering “1”s).
– Select as few rectangles (product terms) as possible, so that all of the “1”s
in the KMap are “covered”.
– It is okay is a “1” is covered by more than one product term.
– It is possible that there are multiple solutions that are equally as good.

ECE124 Digital Circuits and Systems Page 15


KMaps for Finding Minimized POS
• More or less the same thing as Sum-Of-Products minimization, except…
– We try to surround the “0”s in the K-Map, and…
– We AND together the resulting sum terms.
• An example with four inputs:

• A different way to think of enclosing the “0”s is that you are finding an SOP for !f, and
then taking the complement for get a POS expression for f.

ECE124 Digital Circuits and Systems Page 16

You might also like