You are on page 1of 26

CHAPT E R 4.

0 : KARNAUGH MAPS

ITC 2223 COMPUTER
ORG. & ARCHITECTURE
POINTS ADDRESSED IN THIS LECTURE
Standard form of Boolean Expressions
Sum-of-Products (SOP), Product-of-Sums (POS)
Canonical form
Boolean simplification with Boolean Algebra
Boolean simplification using Karnaugh Maps
KARNAUGH MAPS
Boolean algebra helps us simplify expressions and circuits
Karnaugh Map: A graphical technique for simplifying a
Boolean expression into either form:
minimal sum of products (MSP)
minimal product of sums (MPS)
Goal of the simplification.
There are a minimal number of product/sum terms
Each term has a minimal number of literals
Circuit-wise, this leads to a minimal two-level implementation
3
Karnaugh Maps (cont)
Also called K-Map.
Convenient way of representing a Boolean function
of a small number (up to four) of variables.
It is essential for later purpose to list the combination
in order 00, 01, 10, 11.
FORMS OF BOOLEAN EXPRESSIONS
Sum-of-products form (SOP)
first the product (AND) terms are formed then these
are summed (OR)
eg: ABC + DEF + GHI
Product-of-sum form (POS)
first the sum (OR) terms are formed then the
products are taken (AND)
eg: (A+B+C) (D+E+F) (G+H+I)

It is possible to convert between these two forms
using Boolean algebra (DeMorgans)
Forms of Boolean Expressions (cont)
Canonical Form
Canonical form is not efficient but sometimes useful
in analysis and design
In an expression in canonical form, every variable
appears in every term

f(A, B,C,D) = ABCD +ABCD +ABCD

note that the dot (meaning AND) is often omitted
Forms of Boolean Expressions (cont)
An SOP expression can be forced into canonical
form by ANDing the incomplete terms with terms of
the form where X is the name of the missing variable
eg:
f ( A, B, C ) = AB + BC
= AB (C + C) + (A + A) BC
= ABC + ABC + ABC + ABC
= ABC + ABC + ABC
The product term in a canonical SOP expression is
called a 'minterm'
Forms of Boolean Expressions (cont)
A Notation using Canonical Form
Previous example:
Construct the truth table for this function
use a 0 when the variable is complemented, 1 otherwise
f ( A, B, C ) = ABC + ABC + ABC







f can be written as the sum of row numbers having TRUE minterms
f = (3,6,7)
Row Number A B C f
0 0 0 0 0
1 0 0 1 0
2 0 1 0 0
3 0 1 1 1
4 1 0 0 0
5 1 0 1 0
6 1 1 0 1
7 1 1 1 1

TERMINOLOGY : MINTERMS
A minterm is a special product of literals, in which each input variable
appears exactly once.
A function with n variables has 2
n
minterms (since each variable can
appear complemented or not)
A three-variable function, such as f(x,y,z), has 2
3
= 8 minterms:
xyz xyz xyz xyz
xyz xyz xyz xyz
Each minterm is true for exactly one combination of inputs:
Minterm Is true when.. Shorthand
xyz x=0,y=0,z=0 m
0
xyz x=0,y=0,z=1 m
1
xyz x=0,y=1,z=0 m
2
xyz x=0,y=1,z=1 m
3
xyz x=1,y=0,z=0 m
4
xyz x=1,y=0,z=1 m
5
xyz x=1,y=1,z=0 m
6
xyz x=1,y=1,z=1 m
7
RE-ARRANGING THE TRUTH TABLE
A two-variable function has four possible minterms. We can re-
arrange these minterms into a Karnaugh map





Now we can easily see which minterms contain common literals
Minterms on the left and right sides contain y and y respectively
Minterms in the top and bottom rows contain x and x respectively
10
x y minterm
0 0 xy
0 1 xy
1 0 xy
1 1 xy
Y
0 1
0 xy xy
X
1 xy xy
Y
0 1
0 xy xy
X
1 xy xy
Y Y
X xy xy
X xy xy
KARNAUGH MAP SIMPLIFICATIONS
Imagine a two-variable sum of minterms:
xy + xy
Both of these minterms appear in the top row of a Karnaugh
map, which means that they both contain the literal x



What happens if you simplify this expression using Boolean
algebra?
11
xy + xy = x(y + y) [ Distributive ]
= x 1 [ y + y = 1 ]
= x [ x 1 = x ]
Y
xy xy
X xy xy
TWO-VARIABLE EXAMPLES
Another example expression is xy + xy
Both minterms appear in the right side, where y is
uncomplemented
Thus, we can reduce xy + xy to just y



How about xy + xy + xy?
We have xy + xy in the top row, corresponding to x
Theres also xy + xy in the right side, corresponding to y
This whole expression can be reduced to x + y
12
Y
xy xy
X xy xy
Y
xy xy
X xy xy
A THREE-VARIABLE KARNAUGH MAP
For a three-variable expression with inputs x, y, z, the
arrangement of minterms is more tricky:



Another way to label the K-map (use whichever you
like):
13
Y
xyz xyz xyz xyz
X xyz xyz xyz xyz
Z
Y
m
0
m
1
m
3
m
2
X m
4
m
5
m
7
m
6
Z
YZ
00 01 11 10
0 xyz xyz xyz xyz
X
1 xyz xyz xyz xyz
YZ
00 01 11 10
0 m
0
m
1
m
3
m
2
X
1 m
4
m
5
m
7
m
6
CONT..
With this ordering, any group of 2, 4 or 8 adjacent squares on the
map contains common literals that can be factored out




Adjacency includes wrapping around the left and right sides:





Well use this property of adjacent squares to do our simplifications.
14
xyz + xyz
= xz(y + y)
= xz 1
= xz
xyz + xyz + xyz + xyz
= z(xy + xy + xy + xy)
= z(y(x + x) + y(x + x))
= z(y+y)
= z
Y
xyz xyz xyz xyz
X xyz xyz xyz xyz
Z
Y
xyz xyz xyz xyz
X xyz xyz xyz xyz
Z
K-MAP SIMPLIFICATION OF SOP
EXPRESSIONS
Lets consider simplifying f(x,y,z) = xy + yz + xz
First, you should convert the expression into a sum of minterms form,
The easiest way to do this is to make a truth table for the function,
and then read off the minterms
You can either write out the literals or use the minterm shorthand
Here is the truth table and sum of minterms for our example:
15
x y z f(x,y,z)
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
f(x,y,z) = xyz + xyz + xyz + xyz
= m
1
+ m
5
+ m
6
+ m
7
UNSIMPLIFYING EXPRESSIONS
You can also convert the expression to a sum of minterms with
Boolean algebra
Apply the distributive law in reverse to add in missing variables.
Very few people actually do this, but its occasionally useful.






In both cases, were actually unsimplifying our example expression
The resulting expression is larger than the original one!
But having all the individual minterms makes it easy to combine
them together with the K-map
16
xy + yz + xz = (xy 1) + (yz 1) + (xz 1)
= (xy (z + z)) + (yz (x + x)) + (xz (y + y))
= (xyz + xyz) + (xyz + xyz) + (xyz + xyz)
= xyz + xyz + xyz + xyz
= m
1
+ m
5
+ m
6
+ m
7
MAKING THE EXAMPLE K-MAP
In our example, we can write f(x,y,z) in two equivalent
ways





In either case, the resulting K-map is shown below



17
Y
xyz xyz xyz xyz
X xyz xyz xyz xyz
Z
f(x,y,z) = xyz + xyz + xyz + xyz
Y
m
0
m
1
m
3
m
2
X m
4
m
5
m
7
m
6
Z
f(x,y,z) = m
1
+ m
5
+ m
6
+ m
7
Y
0 1 0 0
X 0 1 1 1
Z
K-MAPS FROM TRUTH TABLES
We can fill in the K-map directly from a truth table
The output in row i of the table goes into square m
i
of the K-map
Remember that the rightmost columns of the K-map are switched
18
Y
m
0
m
1
m
3
m
2
X m
4
m
5
m
7
m
6
Z
x y z f(x,y,z)
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
Y
0 1 0 0
X 0 1 1 1
Z
GROUPING THE MINTERMS TOGETHER
The most difficult step is grouping together all the 1s in the K-map
Make rectangles around groups of one, two, four or eight 1s
All of the 1s in the map should be included in at least one
rectangle
Do not include any of the 0s



Each group corresponds to one product term. For the simplest result:
Make as few rectangles as possible, to minimize the number of
products in the final expression.
Make each rectangle as large as possible, to minimize the number
of literals in each term.
Rectangles can be overlapped, if that makes them larger.
19
Y
0 1 0 0
X 0 1 1 1
Z
READING THE MSP FROM THE K-MAP
Finally, you can find the minimal SoP expression
Each rectangle corresponds to one product term
The product is determined by finding the common literals in
that rectangle
20
Y
xyz xyz xyz xyz
X xyz xyz xyz xyz
Z
Y
0 1 0 0
X 0 1 1 1
Z
xy yz
F(x,y,z)= yz + xy
PRACTICE K-MAP 1
Simplify the sum of minterms m
1
+ m
3
+ m
5
+ m
6

21
Y
X
Z
Y
m
0
m
1
m
3
m
2
X m
4
m
5
m
7
m
6
Z
SOLUTIONS FOR PRACTICE K-MAP 1
Here is the filled in K-map, with all groups shown
The magenta and green groups overlap, which makes
each of them as large as possible
Minterm m
6
is in a group all by its lonesome






The final MSP here is xz + yz + xyz

22
Y
0 1 1 0
X 0 1 0 1
Z
FOUR-VARIABLE K-MAPS F(W,X,Y,Z)
We can do four-variable expressions too!
The minterms in the third and fourth columns, and in the third and
fourth rows, are switched around.
Again, this ensures that adjacent squares have common literals







Grouping minterms is similar to the three-variable case, but:
You can have rectangular groups of 1, 2, 4, 8 or 16 minterms
You can wrap around all four sides
23
Y
wxyz wxyz wxyz wxyz
wxyz wxyz wxyz wxyz
wxyz wxyz wxyz wxyz
X
W
wxyz wxyz wxyz wxyz
Z
Y
m
0
m
1
m
3
m
2
m
4
m
5
m
7
m
6
m
12
m
13
m
15
m
14
X
W
m
8
m
9
m
11
m
10
Z
EXAMPLE: SIMPLIFY M
0
+M
2
+M
5
+M
8
+M
10
+M
13

The expression is already a sum of minterms, so heres the K-map:






We can make the following groups, resulting in the MSP xz + xyz
24
Y
1 0 0 1
0 1 0 0
0 1 0 0
X
W
1 0 0 1
Z
Y
m
0
m
1
m
3
m
2
m
4
m
5
m
7
m
6
m
12
m
13
m
15
m
14
X
W
m
8
m
9
m
11
m
10
Z
Y
1 0 0 1
0 1 0 0
0 1 0 0
X
W
1 0 0 1
Z
Y
wxyz wxyz wxyz wxyz
wxyz wxyz wxyz wxyz
wxyz wxyz wxyz wxyz
X
W
wxyz wxyz wxyz wxyz
Z
K-MAPS CAN BE TRICKY!
There may not necessarily be a unique MSP. The K-map below yields two
valid and equivalent MSPs, because there are two possible ways to
include minterm m
7













Remember that overlapping groups is possible, as shown above
25
Y
0 1 0 1
X 0 1 1 1
Z
yz + yz + xy yz + yz + xz
Y
0 1 0 1
X 0 1 1 1
Z
Y
0 1 0 1
X 0 1 1 1
Z
THE END!

You might also like