Karnaugh Map

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

1

1 Elec 326 KarnaughMaps


Karnaugh Maps
Objectives
This section presents a technique for simplifying logical
expressions. It will:
Define Karnaughand establish the correspondence between
Karnaughmaps and truth tables and logical expressions.
Show how to use Karnaughmaps to derive minimal sum-
of-products and product-of-sums expressions.
Introduce the concept of "don't care" entries and show how
to extend Karnaughmap techniques to include maps with
don't care entries.
Reading Assignment
Sections 2.6 and 2.7 from the text
2 Elec 326 KarnaughMaps
Karnaugh Map Definitions
A Karnaughmap 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 Karnaughmap.
Two-Variable Maps
Truth Table
0
0
1
1
0
1
0
1
0
1
1
0
A B Z
A
B
Z
Type 1 Map
0 1
1 0
B
Z
Type 2 Map
A
0 1
0
1
0 1
1 0
Three-Variable Maps
Type 2 Map
1 0
1
1
1
0
0
0
0 1
0 0
0 1
1 1
1 0
Z
B,C
A
C
Type 1 Map
A
B
Z
0 1
1
1
1
0
0
0
Truth Table
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
ABC
0
1
1
0
1
0
0
1
Z
2
3 Elec 326 Karnaugh Maps
Four-Variable Maps
Truth Table
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
A B C D
0
0
0
1
0
1
1
1
0
1
1
1
1
1
1
1
Z
Type 2 Map
Z
C,D 00 01 10 11
00
01
11
10
A,B
1 0
0 1 1 1
1 1
1 1
1 1
1 0
A
B
C
D
Z
1 0 0
0 1 1 1
1 1
1 1
1 1
1 0
Type 1 Map
0 0 0
4 Elec 326 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.
Numbering of Karnaugh Map Squares.
A = 1
region
C = 1
region
D = 1
region
B = 1
region
A
B
C
D
A
B
C
D
A
B
C
D
A
B
C
D
Z
C,D
00 01 10 11
00
01
10
11
A,B
0
1
3
2
4
5
7
12
13
15
14
8
9
10
11
6
0 1
00
01
10
11
Z
B,C
A
0
1
3
2
4
7
5
6
B
Z
A
0 1
0
1
0
1 3
2
3
5 Elec 326 Karnaugh Maps
Exercise: Plot the following expression on a Karnaugh map.
Z = (AB)(C+D)
A
C
B
D
Z = AB(C+D)' + (AB)'(C+D)
= ABC'D' + (A'+B')(C+D)
= ABC'D' + A'C + A'D + B'C + B'D
1
1
1
1
1
1
1 1
1
1
0 0
0 0
0
0
6 Elec 326 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).
4
7 Elec 326 Karnaugh Maps
Merging Adjacent Product Terms
Z = m
5
+ m
13
= A'BC'D + ABC'D
= (A'+A)BC'D
= 1BC'D
= BC'D
Example
A
B
C
D
Z
0 0 0 0
0 0 0 0
0 0 0 0
1 1 0 0
A'
B
C'
D
A
B
C'
D
Z
B
C'
D
Z
B
A
C
D
Z
1 0 0 0
0 0 0
0
0
0 1
1 0 0 0
1
A B C'
A' C D
8 Elec 326 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 = m
5
+ m
7
+ m
13
+ m
15
= A'BC'D + A'BCD + ABC'D + ABCD
= (A'C' + A'C + AC' + AC) (BD)
= (A'(C' + C) + A(C' + C)) (BD)
= (A' + A) (BD)
= BD
B
A
C
D
Z
1
0 0
0
0 0 0
0
0
0 1
1
0 0
0
1
5
9 Elec 326 Karnaugh Maps
Basic Karnaugh Map Groupings for Three-Variable
Maps.
B
A
C
Z3
1
1
B
A
C
Z5
1
1
1
1
B
A
C
Z4
1
1 1
1
B
C
Z6
1
1 1
1
A
B
A
C
Z1
1 1
B
A
C
Z2
1
1
10 Elec 326 Karnaugh Maps
Basic Karnaugh Map Groupings for Four-Variable
Maps.
D
B
A
C
Z7
1
1
B
A
C
D
Z14
1 1
1 1
B
A
C
D
1 1
Z8
C
D
1
1
A
B
Z9
B
A
C
Z10
1 1
D
B
A
C
D
Z11
1
1
1
1
B
A
C
Z12
1
1
1
1
D
C
D
Z13
1 1
1 1
A
B
6
11 Elec 326 Karnaugh Maps
B
A
C
D
Z15
1
1
1
1
B
A
C
D
Z18
1
1
1
1
1
1
1
1
B
A
C
D
1
Z16
1 1 1
B
A
C
D
Z17
1 1
1 1
1 1
1 1
C
D
Z19
1
1
1
1
1
1
1
1
A
B B
A
Z20
1 1
1 1
1 1
1 1
C
D
12 Elec 326 Karnaugh Maps
Rules for Grouping:
The number of squares in a grouping is 2
i
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.
7
13 Elec 326 Karnaugh Maps
Invalid Karnaugh Map Groupings.
B
A
C
D
Z
1
0
0 0
0
0
0 1
1
0
0
1
1
1 1
1
Violates Rule 1
B
A
C
D
Z
1
1
1
0
1
0 0
0
1
1
1
1
1
1
1
1
Violates Rule 2
loop 1
loop 2
14 Elec 326 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:
B
A
C
D
Z
1
0
0
0
1
1 0
0
1
1 1
1 1
1
1
1
#2
#3
#4
#1
8
15 Elec 326 Karnaugh Maps
a. Z = ABD+AB'C'+A'BC'+A'CD+A'B'D'
b. Z = BD+AB'C'+A'BC'+A'CD+A'B'D'
c. Z = BD+AB'C'+A'C'D'+A'B'C
B
A
C
D
Z
1
0
0
0
1
1 0
0
1 1
1
1
1
1 1
0
B
A
C
D
Z
1
0
0
0
1
1 0
0
1 1
1
1
1
1 1
0
B
A
C
D
Z
1
0
0
0
1
1 0
0
1 1
1
1
1
1 1
0
#5
#3 #2
#4
#1
a. Non-minimal
Product Terms
#1
#2
#3
#4
#5
#1
#2
#3
#4
b. Non-minimal Selection
of Prime Implicants
c. Minimal
Grouping
B
A
C
W3
1 0
0
0
1
1 0
1
1 1
1 1
1 1 1
1
D
B
A
C
D
W3
1 0
0
0
1
1 0
1
1 1
1 1
1 1 1
1
a. W3 = C'D+AC'+BC+A'B'D'
b. W3 = BD+AB+B'C'+A'CD'
16 Elec 326 Karnaugh Maps
Exercise: Derive minimal sum-of-products logical
expressions from the following Karnaugh maps.
A
C
B
D
A
C
B
D
1 1 1
1 1
1
1 1 0 0
0 0 0
0
0
0
1 1 1
1 1
1
1 1 0 0
0 0 0
0
0
0
X
Y
AB + A'B'D' + A'B'C + BCD' X =
A'C' + ACD' + ABC + BC'D' Y =
9
17 Elec 326 Karnaugh Maps
Minimal Product-Of-Sums Expressions
Merging Adjacent Product Terms.
A
C
Z
0 0
1
1
1 1
1
B
1
Karnaugh Map
A'
B'
C'
A
B'
C'
B'
C'
Z Z
OR-AND Networks
M3M7 = (A+B'+C')(A'+B'+C')
= (AA')+(B'+C')
= 0 + (B'+C')
= B' + C'
18 Elec 326 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.
10
19 Elec 326 Karnaugh Maps
Examples:
Z = (A+D')(B'+C+D)(A'+B+C'+D)
Z1 = (A+B'+D)(B+C+D')(A+B+D')
Z2 = D'(A+B')(B'+C')
B
A
C
Z
1 0
0
0
1
1 0
1
1
1 1
1
1
D
0
0 0
B'+C+D
A+D'
A'+B+C'+D
B
A
C
Z2
0 1 1
1
D
0 0
0
0
1
1
0 0
0 0 0
0
A
C
Z1
0 1
1
1
1 1
0 0
0
0
1
1 1
1 1
1
B
D
20 Elec 326 Karnaugh Maps
Comparison of Sum-of-Products and Product-of-
Sums Expressions.
A
C
Z1
0 1 1
1 1
0 0
0
0
1
1
B
D
0
0 0
0 0
C
Z1
0 1 1
1
D
0 0
0
0
1
1
0 0
0 0
0
1
A
B
Z1 = (A+B')(A+D')(B'+D')(A'+B+C)
Z1 = (ABD') + (AB'C) + (A'B'D')
11
21 Elec 326 Karnaugh Maps
A
C
B
D
A
C
B
D
1 1 1
0 1
0
0 0 1 1
1 0 0
1
1
0
1 1 1
0 1
0
0 0 1 1
1 0 0
1
1
0
X
X
+ AD' BD' + AC' + BC'
Exercise: Derive minimal SOP and POS expressions
from the following Karnaugh maps.
X = Y =
(B' + D') (A' + C')
22 Elec 326 Karnaugh Maps
Don't Care Entries
Assignment of Values to Don't Care Entries.
A
B
Z
C
0
1
d
1
1
d
0 0
A
B
Z
C
0
1 1
1
0 0
1
1
A
B
Z
C
0
1 1
1
0 0
0
0
0
A
B
Z
C
1 1
1
0 0
1
0
Z = B'+A'C Z = AB'+B'C' Z = B'
1 d 0
1
0
0
0
0
0
1
0 d
d
d
d
d
A
B
C
D
Z
1 d
1
0
0
0
1
0 d
d
d
d
A
C
D
Z
d 1
1
1
B
Z = BC + AD' Z = (C+D')(A'+B')
12
23 Elec 326 Karnaugh Maps
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)
24 Elec 326 Karnaugh Maps
Five- and Six-Variable Maps
Five-Variable Maps.
D
C
E
B
D
C
E
B
A
0 4 12 8
1 5 13 9
3 7 15 11
2 6 14 10
16 20 28 24
17 21 29 25
19 23 31
26 18 22 30
27
Five-Variable Map Structure
B
C
D
Z
0
1
B
C
E
3
2
4
5
7
6
8
9
11
12
13
15
14 10
16
17
19
18
20
21
23
22
28
29
31
30
24
25
27
26
A
Alternate Version of Five-Variable Map
D
E
13
25 Elec 326 Karnaugh Maps
Six-Variable Maps
E
D
F
C
E
D
F
C
0 4 12 8
1 5 13 9
3 7 15 11
2 6 14 10
16 20 28 24
17 21 29 25
19 23 31 27
18 22 30 26
E
D
F
C
E
D
F
C
48 52 60 56
49 53 61 57
51 55 63 59
50 54 62 58
32 36 44 40
33 37 45 41
35 39 47 43
34 38 46 42
Six Variable Map Structure
B
A
48
49
51
50
52
53
55
54
60
61
63
62
C
E
Z
0
1
C
F
3
2
4
5
7
6
8
9
11
12
13
15
14 10
16
17
19
18
20
21
23
22
28
29
31
30
24
25
27
26
Alternate Version of Six-Variable Map
D
E
D
F
56
57
59
58
B
A
32
33
35
34
36
37
39
38
44
45
47
46
40
41
43
42
D D
C C
F
F
E
E
26 Elec 326 Karnaugh Maps
Examples.
B
D
Z
0 1 0 0
0 0 1 1
0 0 1 1
0 1 0 0
C
B
E
0 1 0 0
0 0 1 1
0 0 1 1
0 1 0 0
C
A
BE
B' C' E'
Z = B'C'E'+BE
B
C
D
Z
B
C
E
A
0 1 0
0
1
1 1 0
0
0 0
1 1 1
1 1
0
0
0
0
0
1
1
0
0 1
1 1
1 1
1 1
A'B'D + CE + ABD + BD'E'
14
27 Elec 326 Karnaugh Maps
0
B
C
D
Z
B
C
E
A
1 0
0
0
0
0 0 1
1
1
1
1
1
1
0
1
0 0 0
0
0
0 1
1
1
1
1
1
1
0
0
d
1
B
C
D
Z
B
C
E
A
1
1
1
0
1
0
1
0
1
0
1
1
0
d
d
d
d
d
d d d d
0 0
1 1
d d d d
Z = (B+C)(B+E(A'+D+E)(A+C+E)
Z = BC + D
28 Elec 326 Karnaugh Maps
Exercise: Draw a timing diagram for the following
circuit assuming an equal unit delay for each gate.
Timing Hazards
A
B
X
Y
Y
A
B
X
15
29 Elec 326 Karnaugh Maps
Static 1 hazards
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.
A = 1
B = 1
S
Z
P
Q
NS
S
P
NS
Q
Z
0 spike, static 1 hazard
30 Elec 326 Karnaugh Maps
There is a simple way to prevent the hazards using
Karnaugh maps.
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.
1 0 0
0 1 1
1
0
S
A
B
Z
16
31 Elec 326 Karnaugh Maps
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.
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?
A
S
B
Z
32 Elec 326 Karnaugh Maps
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
A = 0
B = 0
S
Z
P
Q
1
0 0
0
1
1
1
0
A
B
Z
S
A
S
B
Z
S
P
NS
Q
Z
1 spike, static 0 hazard
17
33 Elec 326 Karnaugh Maps
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.

You might also like