You are on page 1of 17

Karnaugh Maps

†Objectives
This section presents a technique for simplifying logical
expressions. It will:
„ Define Karnaugh and establish the correspondence between
Karnaugh maps and truth tables and logical expressions.
„ Show how to use Karnaugh maps to derive minimal sum-
of-products and product-of-sums expressions.
„ Introduce the concept of "don't care" entries and show how
to extend Karnaugh map techniques to include maps with
don't care entries.
†Reading Assignment
„ Sections 2.6 and 2.7 from the text

Elec 326 1 Karnaugh Maps

Karnaugh Map Definitions


†A Karnaugh map is a two-dimensional truth-table.
Unlike ordinary (i.e., one-dimensional) truth tables,
however, certain logical network simplifications can
be easily recognized from a Karnaugh map.
A B Z Z Z A
A 0 1
0 0 0 B
0 1 1 0 1 0 0 1
1 0 1
1 1 0 B 1 0 1 1 0
Truth Table Type 1 Map Type 2 Map
Two-Variable Maps
AB C Z Z Z A
A B,C 0 1
0 00 0
0 01 1 0 1 00 0 1
0 10 1
0 11 0 1 0 01 1 0
1 00 1 C
1 01 0 0 1 11 0 1
1 10 0 B
1 11 1 1 0 10 1 0
Truth Table Type 1 Map Type 2 Map
Three-Variable Maps
Elec 326 2 Karnaugh Maps

1
A B C D Z
0 0 0 0 0
0 0 0 1 0 Z A,B
0 0 1 0 0 Z A C,D 00 01 11 10
0 0 1 1 1
0 1 0 0 0 0 0 1 0 00 0 0 1 0
0 1 0 1 1
0 1 1 0 1 0 1 1 1 01 0 1 1 1
D
0 1 1 1 1 1 1 1 1 11 1 1 1 1
1 0 0 0 0 C
1 0 0 1 1 0 1 1 1 10 0 1 1 1
1 0 1 0 1
1 0 1 1 1 B
1 1 0 0 1 Type 1 Map Type 2 Map
1 1 0 1 1
1 1 1 0 1
1 1 1 1 1 Four-Variable Maps
Truth Table

Elec 326 3 Karnaugh Maps

†The interpretation of a type 1 map is that the rows or


columns labeled with a variable correspond to region
of the map where that variable has value 1.
A A A A

D D D D
C C C C
B B B B
A=1 B=1 C=1 D=1
region region region region

†Numbering of Karnaugh Map Squares.


Z A Z A,B
B,C 0 1 C,D 00 01 11 10
Z A
0 1 00 0 4 00 0 4 12 8
B
0 0 2 01 1 5 01 1 5 13 9
1 1 3 11 3 7 11 3 7 15 11
10 2 6 10 2 6 14 10

Elec 326 4 Karnaugh Maps

2
† Exercise: Plot the following expression on a Karnaugh map.

Z = (A•B)⊕(C+D)

1 0 1 0
Z = A•B•(C+D)' + (A•B)'•(C+D) B
= A•B•C'•D' + (A'+B')•(C+D) 0 0 1 1
D
= A•B•C'•D' + A'•C + A'•D + B'•C + B'•D
1 1 1 1
0 1 1 0
C

Elec 326 5 Karnaugh Maps

Minimal Sum-Of-Products Expressions


†Ordering of Squares
„ The important feature of the ordering of squares is that the
squares are numbered so that the binary representations for
the numbers of two adjacent squares differ in exactly one
position.
‹This is due to the use of a Gray code (one in which adjacent
numbers differ in only one position) to label the edges of a type 2
map.
‹The labels for the type 1 map must be chosen to guarantee this
property.
„ Note that squares at opposite ends of the same row or
column also have this property (i.e., their associated
numbers differ in exactly one position).

Elec 326 6 Karnaugh Maps

3
†Merging Adjacent Product Terms
Z = m5 + m13
Z A = A'•B•C'•D + A•B•C'•D
0 0 0 0 = (A'+A)•B•C'•D
0 1 1 0 = 1•B•C'•D
D
0 0 0 0 = B•C'•D
C
0 0 0 0
A'
B B
C'
D B
Z C' Z
A D
B
C'
D

„ Example
A • B • C'
Z A

0 0 1 0
A' • C • D
0 0 1 0
D
1 1 0 0
C
0 0 0 0

Elec 326 7 Karnaugh Maps

†For k-variable maps, this reduction technique can also


be applied to groupings of 4,8,16,...,2k rectangles all
of whose binary numbers agree in (k-2),(k-3),(k-
4),...,0 positions, respectively.
Z A
0 0 0 0
0 1 1 0
D
0 1 1 0
C
0 0 0 0

Z= m5 + m7 + m13 + m15
= A'•B•C'•D + A'•B•C•D + A•B•C'•D + A•B•C•D
= (A'•C' + A'•C + A•C' + A•C) • (B•D)
= (A'•(C' + C) + A•(C' + C)) • (B•D)
= (A' + A) • (B•D)
= B•D

Elec 326 8 Karnaugh Maps

4
†Basic Karnaugh Map Groupings for Three-Variable
Maps.

Z1 Z3 Z5
A A A

1 1
1 1 1
C C C
1
B B B
1 1

Z2 Z4 Z6
A A A
1 1
1 1 1
C C C
1 1 1
B B B
1 1

Elec 326 9 Karnaugh Maps

†Basic Karnaugh Map Groupings for Four-Variable


Maps.

Z7 Z8 Z9 Z10
A A A A
1

1 1 1 1 1
D D D D
1
C C C C
1

B B B B

Z11 Z12 Z13 Z14


A A A A
1 1 1 1 1 1
1 1 1 1
D D D D
1 1
C C C C
1 1 1 1

B B B B

Elec 326 10 Karnaugh Maps

5
Z15 Z16 Z17
A A A
1 1 1
1 1 1 1 1 1 1
D D D
1 1 1
C C C
1 1 1

B B B

Z18 Z19 Z20


A A A
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1
D D D
1 1
C C C
1 1 1 1 1 1

B B B

Elec 326 11 Karnaugh Maps

†Rules for Grouping:


„ The number of squares in a grouping is 2i for some i such
that 1 ≤ i ≤ k.
„ There are exactly k-i variables that have constant value for
all squares in the grouping.

†Resulting Product Terms:


„ If X is a variable that has value 0 in all of the squares in the
grouping, then the literal X' is in the product term.
„ If X is a variable that has value 1 in all of the squares in the
grouping, then the literal X is in the product term.
„ If X is a variable that has value 0 for some squares in the
grouping and value 1 for others, then neither X' nor X are
in the product term.

Elec 326 12 Karnaugh Maps

6
† Invalid Karnaugh Map Groupings.

Z A loop 1
Z A
0 1 0 0 loop 2
1 0 0 1
0 1 1 0
D 1 1 0 1
D
1 1 1 0 1 1 1 1
C
0 1 1 0 C
0 1 1 1
B
B
Violates Rule 1 Violates Rule 2

Elec 326 13 Karnaugh Maps

†In order to minimize the resulting logical expression,


the groupings should be selected as follows:
„ Identify those groupings that are maximal in the sense that
they are not contained in any other possible grouping. The
product terms obtained from such groupings are called
prime implicants.
‹A distinguished 1-cell is a cell that is covered by only one prime
implicant.
‹An essential prime implicant is one that covers a distiquished 1-
cell.
„ Use the fewest possible number of maximal groupings
needed to cover all of the squares marked with a 1.
†Examples: Z #2 A
1 0 1 1
#1
0 1 1 0
D
0 1 1 1
C
1 0 1 1
#4
B #3

Elec 326 14 Karnaugh Maps

7
Z #3 A #2 Z #3 A #2 Z #3 A #2
1 1 0 1 1 1 0 1 1 1 0 1
#4 0 1 1 1 #4 0 1 1 1 0 1 1 1
D D D
1 1 1 0 1 1 1 0 1 1 1 0
C C C
1 0 0 0 1 0 0 0 1 0 0 0
#1 #1 #1
#5 #5 #4
B B B
a. Non-minimal b. Non-minimal Selection c. Minimal
Product Terms of Prime Implicants Grouping

a. Z = A•B•D+A•B'•C'+A'•B•C'+A'•C•D+A'•B'•D'
b. Z = B•D+A•B'•C'+A'•B•C'+A'•C•D+A'•B'•D'
c. Z = B•D+A•B'•C'+A'•C'•D'+A'•B'•C

W3 W3
A A
1 0 1 1 1 0 1 1
1 1 1 1 1 1 1 1
D D
0 1 1 0 0 1 1 0
C C
1 1 1 0 1 1 1 0

B B

a. W3 = C'D+AC'+BC+A'B'D'
b. W3 = BD+AB+B'C'+A'CD'

Elec 326 15 Karnaugh Maps

†Exercise: Derive minimal sum-of-products logical


expressions from the following Karnaugh maps.
X Y
A A

1 1 1 0 1 1 1 0
B
1 1 0 0 1 1 0 0
D D
0 0 1 0 0 0 1 0
C
0 0 1 1 0 0 1 1
C B

X = A•B + A'•B'•D' + A'•B'•C + B•C•D'

Y = A'•C' + A•C•D' + A•B•C + B•C'•D'

Elec 326 16 Karnaugh Maps

8
Minimal Product-Of-Sums Expressions
†Merging Adjacent Product Terms.
Z A
A'
1 1
B'
1 1 C'
C Z B' Z
0 0 A C'
B B'
1 1
C'

Karnaugh Map OR-AND Networks

M3•M7 = (A+B'+C')•(A'+B'+C')
= (A•A')+(B'+C')
= 0 + (B'+C')
= B' + C'

Elec 326 17 Karnaugh Maps

†Rules for Grouping:


„ Same as for sum-of-products, except that zero's are
grouped instead of ones.
†Resulting Sum Terms:
„ If variable X has value 0 for all squares in the group, then
the literal X is in the sum term.
„ If variable X has value 1 for all squares in the group, then
the literal X' is in the sum term.
„ If variable X has value 0 for some squares in the group and
value 1 for the others, then that variable does not appear in
the sum term.
†Prime Implicate:
„ Maximal grouping of zeros.

Elec 326 18 Karnaugh Maps

9
†Examples:
Z B'+C+D A

A+D' 1 0 0 1
0 0 1 1
D
0 0 1 1
C
1 1 1 0

B A'+B+C'+D

Z = (A+D')•(B'+C+D)•(A'+B+C'+D)

Z1 Z2
A A
1 0 1 1 1 0 1 1
0 1 1 0 0 0 0 0
D D
0 1 1 1 0 0 0 0
C C
1 0 1 1 1 0 0 1

B B

Z1 = (A+B'+D)•(B+C+D')•(A+B+D')
Z2 = D'•(A+B')•(B'+C')

Elec 326 19 Karnaugh Maps

†Comparison of Sum-of-Products and Product-of-


Sums Expressions.
Z1 Z1
A A
1 0 1 0 1 0 1 0
0 0 0 0 0 0 0 0
D D
0 0 0 1 0 0 0 1
C C
1 0 1 1 1 0 1 1

B B

Z1 = (A+B')•(A+D')•(B'+D')•(A'+B+C)
Z1 = (A•B•D') + (A•B'•C) + (A'•B'•D')

Elec 326 20 Karnaugh Maps

10
†Exercise: Derive minimal SOP and POS expressions
from the following Karnaugh maps.

X X
A A

1 1 1 1 1 1 1 1
B
1 0 0 1 1 0 0 1
D D
1 0 0 0 1 0 0 0
C
1 1 0 0 1 1 0 0

C B

X = B•D' + A•C' + A•D' + B•C' Y = (B' + D') • (A' + C')

Elec 326 21 Karnaugh Maps

Don't Care Entries


†Assignment of Values to Don't Care Entries.
Z Z Z Z A
A A A

1 1 1 1 1 1 1 1
d 1 1 1 0 1 1 1
C C C C
d 0 1 0 0 0 0 0
B B B B
0 0 0 0 0 0 0 0

Z = B'+A'•C Z = A•B'+B'•C' Z = B'

Z A Z A
0 0 d 1
1 d d 1
0 0 d 0
D 0 0 d 0
D
0 1 d d
C 1 1 0 d
C
0 1 d d
1 d d 1
B
B

Z = B•C + A•D' Z = (C+D')•(A'+B')

Elec 326 22 Karnaugh Maps

11
†Minterm and Maxterm Lists with Don't Care Entries.

ΣA,B,C(0,d1,d3,4,5) and ΠA,B,C(d1,2,d3,6,7)

ΣA,B,C(6,7,8,d10,d11,d12,d13,d14,d15)

ΠA,B,C(0,1,2,3,4,5,9,d10,d11,d12,d13,d14,d15)

Elec 326 23 Karnaugh Maps

Five- and Six-Variable Maps


†Five-Variable Maps.

B
0 4 12 8
1 5 13 9 Z
E B B
D 3 7 15 11
0 4 12 8 16 20 28 24
2 6 14 10
C 1 5 13 9 17 21 29 25
B E E
3 7 15 11 19 23 31 27
16 20 28 24 D D
2 6 14 10 18 22 30 26
17 21 29 25
E A C C
D 19 23 31 27
18 22 30 26 A

C
Five-Variable Map Structure Alternate Version of Five-Variable Map

Elec 326 24 Karnaugh Maps

12
†Six-Variable Maps
C
0 12 8 4
1 5 13 9
F Z
E 3 7 15 11 C C
2 6 14 10 0 4 12 8 16 20 28 24
D 1 5 13 9 17 21 29 25
C F F
16 20 28 24 3 7 15 11 19 23 31 27
E E
17 21 29 25 2 6 14 10 18 22 30 26
F
E 19 23 31 27 D
D
18 22 30 26 C C
D 32 36 44 40 48 52 60 56
C
48 52 60 56 33 37 45 41 49 53 61 57
F F A
B 49 53 61 57 35 39 47 43 51 55 63 59
F E E
E 51 55 63 59 A 34 38 46 42 50 54 62 58
50 54 62 58 D D
D B
C
Alternate Version of Six-Variable Map
32 36 44 40
33 37 45 41
F
E 35 39 47 43
34 38 46 42
D
Six Variable Map Structure

Elec 326 25 Karnaugh Maps

†Examples.
Z B B
1 0 0 0 1 0 0 0
B' •C' • E' 0 0 1 1 0 0 1 1
E
0 0 1 1 0 0 1 1
D
1 0 0 0 1 0 0 0 B•E
C C
A

Z = B'•C'•E'+B•E

Z B B
0 0 1 1 0 0 1 1
0 1 1 0 0 1 1 0
E
1 1 1 0 0 1 1 1
D
1 1 0 0 0 0 1 1
C C
A

A'B'D + CE + ABD + BD'E'

Elec 326 26 Karnaugh Maps

13
Z B B
0 0 1 0 0 0 0 0
0 1 1 1 0 1 1 1
E
0 1 1 1 0 1 1 1
D
0 0 1 0 0 0 1 1
C C
A

Z = (B+C)•(B+E•(A'+D+E)•(A+C+E)

Z B B
0 d 1 0 d d d d
0 d 1 0 0 0 1 0
E
d d 1 1 d d d d
D
d d 1 1 1 1 1 1
C C
A

Z = B•C + D

Elec 326 27 Karnaugh Maps

Timing Hazards
†Exercise: Draw a timing diagram for the following
circuit assuming an equal unit delay for each gate.
A X
Y
B

Elec 326 28 Karnaugh Maps

14
†Static 1 hazards
A=1 P
S
NS Z
Q
B=1

S
P
NS
Q

Z
0 spike, static 1 hazard

„ Without the delay in the gates, the output Z would be


constant at 1.
„ The spike is due to the gate delay and the fact that not
every path from on input to the output is the same length.

Elec 326 29 Karnaugh Maps

†There is a simple way to prevent the hazards using


Karnaugh maps. Z A
0 1 1 0

S 0 0 1 1

„ The hazard occurs when the output is 1 before and after the
transition.
„ It happens because one of the AND gates is holding the
output 1 before the transition and the other AND gate holds
it 1 after the transition. The spike occurs if it is possible for
the first to turn off before the second turns on.
„ This can happen anytime there are to adjacent squares on
the Karnaugh map that are both 1 and not both covered by
a common loop. The hazard occurs in making a transition
from one square to the other.
„ The way to prevent it is to put in an extra product term that
is 1 on both sides of the transition. On the Karnaugh map
this is a loop covering the two adjacent one squares.
Elec 326 30 Karnaugh Maps

15
„ The loop added to prevent the hazard is redundant and not
needed to realize the logical expression. Its only purpose is
to prevent the hazard.

A
S
Z
B

„ This technique will avoid all static 1 hazards if only one


variable is changed at a time.
„ It is not possible to get a 1 spike from a 2-level AND-OR
network by changing only one variable. Why?

Elec 326 31 Karnaugh Maps

† Static 0 hazard
S
A=0 P P
S
Z NS
Q
B=0 Q 1 spike, static 0 hazard

„ The static 0 hazard is caused by two OR


gates where one holds the output zero before the transition and the other after the
transition, and it is possible for them to both be 1 during the transition
„ The fix is to put in an extra OR gate to hold the output zero during the
transition

Z A A
S
0 0 1 1
Z
B
S 0 1 1 0

Elec 326 32 Karnaugh Maps

16
†Hazards can frequently be ignored. If the signal Z
above is not used during the transition, then we don't
care if it has a spike.
†When a signal is used as the input to a flip-flop, it is
only sampled with the clock makes a transition.
Therefore, if we can make sure that any spikes occur
at some other time, they will not be a problem.

Elec 326 33 Karnaugh Maps

17

You might also like