Karnaugh Maps
Karnaugh Maps
Elec 326 5.3 Karnaugh Maps Elec 326 5.4 Karnaugh Maps
1
5.2. Minimal Sum-Of-Products Expressions
o Exercise: Plot the following expression on a Karnaugh map.
o Ordering of Squares
Z = (A•B)⊕(C+D) n 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.
u 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.
u The labels for the type 1 map must be chosen to guarantee this
property.
n 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 5.5 Karnaugh Maps Elec 326 5.6 Karnaugh Maps
o Merging Adjacent Product Terms o For k-variable maps, this reduction technique can also
Z = m 5 + m13 be applied to groupings of 4,8,16,...,2k rectangles all
Z A = A'•B•C'•D + A•B•C'•D of whose binary numbers agree in (k-2),(k-3),(k-
0 0 0 0 = (A'+A)•B•C'•D 4),...,0 positions, respectively.
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
Z = m5 + m7 + m13 + m 15
n Example = A'•B•C'•D + A'•B•C•D + A•B•C'•D + A•B•C•D
A • B • C'
Z A = (A'•C'!+ A'•C + A•C' + A•C) • (B•D)
0 0 1 0 = (A'•(C' + C) + A•(C' + C)) • (B•D)
A' • C • D
0 0 1 0
D
= (A' + A) •!(B•D)
C
1 1 0 0 = B•D
0 0 0 0
Elec 326 5.7 Karnaugh Maps Elec 326 5.8 Karnaugh Maps
2
o Basic Karnaugh Map Groupings for Three-Variable o Basic Karnaugh Map Groupings for Four-Variable
Maps. 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 5.9 Karnaugh Maps Elec 326 5.10 Karnaugh Maps
Elec 326 5.11 Karnaugh Maps Elec 326 5.12 Karnaugh Maps
3
o In order to minimize the resulting logical expression,
o Invalid Karnaugh Map Groupings. the groupings should be selected as follows:
n 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
Z A loop 1
prime implicants.
Z A
0 1 0 0 loop 2 u A distinguished 1-cell is a cell that is covered by only one prime
1 0 0 1
0 1 1 0 implicant.
D 1 1 0 1
D
C
1 1 1 0
1 1 1 1 u An essential prime implicant is one that covers a distiquished 1-
C
0 1 1 0
0 1 1 1 cell.
B
Violates Rule 1
B
n Use the fewest possible number of maximal groupings
Violates Rule 2
needed to cover all of the squares marked with a 1.
o Examples: Z #2
A
1 0 1 1
#1
0 1 1 0
D
0 1 1 1
C
1 0 1 1
#4
#3
B
Elec 326 5.13 Karnaugh Maps Elec 326 5.14 Karnaugh Maps
1 1 1 0 1 1 1 0
B
a. Z = A•B•D+A•B'•C'+A'•B•C'+A'•C•D+A'•B'•D' 1 1 0 0 1 1 0 0
b. Z = B•D+A•B'•C'+A'•B•C'+A'•C•D+A'•B'•D' D D
c. Z = B•D+A•B'•C'+A'•C'•D'+A'•B'•C 0 0 1 0 0 0 1 0
C
0 0 1 1 0 0 1 1
C B
X=
Y=
a. W3 = C'D+AC'+BC+A'B'D'
b. W3 = BD+AB+B'C'+A'CD'
Elec 326 5.15 Karnaugh Maps Elec 326 5.16 Karnaugh Maps
4
5.3. Minimal Product-Of-Sums Expressions
o Rules for Grouping:
o Merging Adjacent Product Terms. n Same as for sum-of-products, except that zero's are
grouped instead of ones.
o Resulting Sum Terms:
n If variable X has value 0 for all squares in the group, then
the literal X is in the sum term.
n If variable X has value 1 for all squares in the group, then
the literal X' is in the sum term.
n If variable X has value 0 for some squares in the group and
M3•M7 = (A+B'+C')•(A'+B'+C') value 1 for the others, then that variable does not appear in
= (A•A')+(B'+C') the sum term.
= 0 + (B'+C') o Prime Implicate:
= B' + C'
n Maximal grouping of zeros.
Elec 326 5.17 Karnaugh Maps Elec 326 5.18 Karnaugh Maps
o Examples:
o Comparison of Sum-of-Products and Product-of-
Sums Expressions.
Z1 A Z1 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
Z = (A+D')•(B'+C+D)•(A'+B+C'+D) 1 0 1 1 1 0 1 1
B B
Z1 A Z2 A
1 0 1 1 1 0 1 1 Z1 = (A+B')•(A+D')•(B'+D')•(A'+B+C)
0 1 1 0 0 0 0 0 Z1 = (A•B•D') + (A•B'•C) + (A'•B'•D')
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 5.19 Karnaugh Maps Elec 326 5.20 Karnaugh Maps
5
5.4. Don't Care Entries
o Exercise: Derive minimal SOP and POS expressions
from the following Karnaugh maps. o Assignment of Values to Don't Care Entries.
Z Z Z Z A
A A A
X X 1 1 1 1 1 1 1 1
A A d 1 1 1 0 1 1 1
C C C C
d 0 1 0 0 0 0 0
B B
1 1 1 1 1 1 1 1 B B
0 0 0 0 0 0
0 0
B
1 0 0 1 1 0 0 1 Z = B'+A'•C Z = A•B'+B'•C' Z = B'
D D
1 0 0 0 1 0 0 0 Z A Z A
C 0 0 d 1 1 d d 1
1 1 0 0 1 1 0 0 0 0 d 0 0 0 d 0
D D
0 1 d d 1 1 0 d
C C
C B 0 1 d d 1 d d 1
B B
Elec 326 5.21 Karnaugh Maps Elec 326 5.22 Karnaugh Maps
SA,B,C(6,7,8,d10,d11,d12,d13,d14,d15)
PA,B,C(0,1,2,3,4,5,9,d10,d11,d12,d13,d14,d15)
Elec 326 5.23 Karnaugh Maps Elec 326 5.24 Karnaugh Maps
6
o Six-Variable Maps o Examples.
C
0 4 12 8 Z B B
1 5 13 9
F Z 1 0 0 0 1 0 0 0
E 3 7 15 11 C C
2 6 14 10 B' •C' • E' 0 0 1 1 0 0 1 1
0 4 12 8 16 20 28 24 E
D 0 0 1 1 0 0 1 1
C 1 5 13 9 17 21 29 25 D
F F 1 0 0 0 1 0 0 0
16 20 28 24 3 7 15 11 19 23 31 27 B•E
E E C C
17 21 29 25 2 6 14 10 18 22 30 26
F A
E 19 23 31 27
D D
18 22 30 26 C C Z = B'•C'•E'+B•E
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
A'B'D + CE + ABD + BD'E'
D
Six Variable Map Structure
Elec 326 5.25 Karnaugh Maps Elec 326 5.26 Karnaugh Maps
Y
Z = B•C + D
Elec 326 5.27 Karnaugh Maps Elec 326 5.28 Karnaugh Maps
7
o Static 1 hazards o There is a simple way to prevent the hazards using
Karnaugh maps. Z A
A=1 P
S 0 1 1 0
NS Z
Q
S 0 0 1 1
B=1
B
S
n The hazard occurs when the output is 1 before and after the
P transition.
NS
n It happens because one of the AND gates is holding the
Q output 1 before the transition and the other AND gate holds
Z
it 1 after the transition. The spike occurs if it is possible for
0 spike, static 1 hazard the first to turn off before the second turns on.
n This can happen anytime there are to adjacent squares on
n Without the delay in the gates, the output Z would be the Karnaugh map that are both 1 and not both covered by
constant at 1. a common loop. The hazard occurs in making a transition
from one square to the other.
n 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. n 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 5.29 Karnaugh Maps Elec 326 5.30 Karnaugh Maps
o Static 0 hazard
n The loop added to prevent the hazard is redundant and not
S
needed to realize the logical expression. Its only purpose is A=0 P P
to prevent the hazard. S
Z NS
Q
B=0 Q 1 spike, static 0 hazard
A
S Z
Z
B
n 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
n The fix is to put in an extra OR gate to hold the output zero during the
transition
n This technique will avoid all static 1 hazards if only one
variable is changed at a time.
n It is not possible to get a 1 spike from a 2-level AND-OR Z A A
S
network by changing only one variable. Why? 0 0 1 1
Z
0 1 1 0
B
S
Elec 326 5.31 Karnaugh Maps Elec 326 5.32 Karnaugh Maps
8
5.6. Tips and Tricks
o Hazards can frequently be ignored. If the signal Z o Use type 2 maps to plot from a truth table
above is not used during the transition, then we don't
care if it has a spike. o Use type 1 maps to plot expressions and read
expressions from a map.
o When a signal is used as the input to a flip-flop, it is
only sampled with the clock makes a transition. 5.7. Pitfalls
Therefore, if we can make sure that any spikes occur
at some other time, they will not be a problem.
o Forgetting that K-maps "wrap around"
o Forgetting that the 4 corners are adjacent
o Getting the complements reversed in reading POS
expressions from a K-map
Elec 326 5.33 Karnaugh Maps Elec 326 5.34 Karnaugh Maps
5.8. Review