2. We can come close to our aim by using a graphical
notation named Karnaugh Map that will be defined in
next slides
3. Karnaugh Map Technique
• A K-Map is simply a folded truth table, where physical
adjacency implies logical adjacency
• K-Maps are most commonly used hand method for logic
minimization.
• K-Maps are a graphical technique used to simplify a logic
equation.
• K-Maps are procedural and much cleaner than Boolean
simplification.
• K-Maps can be used for any number of input variables, BUT
are only practical for two, three, and four variables.
3
4. Terminology
•Implicant : Product term that implies function
• Prime Implicant : An Implicant that is not completely covered by
any other Implicant but itself
• Essential prime Implicant : A prime Implicant that has a minter
not covered by any other prime Implicant
• Product term : An and expression
4
Terms
5. Terminology
•Minterm : We define a Minterm to be a product that contains all variables of
that particular switching function in either complemented or non-complemented
form
• Maxterm : We define a Maxterm to be a sum that contains all variables of
that particular switching function in either complemented or non-complemented
form
•Standard SOP(Sum Of Products) : In standard SOP, the products
are obtained directly from the Karnaugh map or truth table, so the SOP
contains all of the variables of the function
•Standard POS(Product Of Sums) : In standard POS, the products
are obtained directly from the Karnaugh map or truth table, so the POS
contains all of the variables of the function
5
Terms
6. 6
minterm
ID A B f(A,B) minterm
0 0 0 0
1 0 1 1 A’B
2 1 0 1 AB’
3 1 1 1 AB
An example of 2-variable function f(A,B)=A+B
7. Simplification Goals
• Goal -- minimize the cost of realizing a switching function
• Cost measures and other considerations
– Number of gates
– Number of levels
– Interconnection complexity
– Preventing hazards
• Two-level realizations
– Minimize the number of gates (terms in switching function)
8. Minimization of Boolean expressions
• The minimization will result in reduction of the number of gates
(resulting from less number of terms) and the number of inputs
per gate (resulting from less number of variables per term)
• The minimization will reduce cost, efficiency and power
consumption.
•y(x+x`)=y.1=y
•y+xx`=y+0=y
•(x`y+xy`)=x⊕y
•(x`y`+xy)=(x⊕y)`
9. Karnaugh Maps
• Boolean algebra helps us simplify expressions and circuits
• Karnaugh Map: A graphical technique for simplifying a Boolean expression
into either form:
– sum of products (SOP)
– product of sums (POS)
• 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
10. Minimum SOP
• f= (xyz +x`yz+ xy`z+ …..)
Is called sum of products.
The + is sum operator which is an OR gate.
The product such as xy is an AND gate for the two inputs x and y.
15. Three Variable K-Map Groupings
V
0 0
0 0
0 0
0 0
C C
BA
BA
BA
BA
BA
1 1
BA
1 1
BA
1 1
BA
1 1
1
CA
1
1
CA
1
1
CA
1
1
CB
1
1
CB
1
1
CA
11
CB
1
1
CB
1
Groups of One – 8 (not shown)
Groups of Two – 12
15
16. Groups of Four – 6
Three Variable K-Map Groupings
V
0 0
0 0
0 0
0 0
C C
BA
BA
BA
BA
1
C
1
1
1
1
C
1
1
1
A
1 1
1 1
B
1 1
1 1
A
1 1
1 1
B
1 1
1 1
16
17. Group of Eight - 1
Three Variable K-Map Groupings
V
1 1
1 1
1 1
1 1
C C
BA
BA
BA
BA
1
17
18. Three variable map
• f(A,B,C) = ∑m(0,3,5)=
A`B`C`+A`BC+AB`C
1
1
A`BC
1
AB`C
A`B`
0 0
A`B
0 1
A B
1 1
A B`
1 0
C`
0
C
1
A`B`C`
19. 19
minterm
ID A B f(A,B) minterm
0 0 0 0
1 0 1 1 A’B
2 1 0 1 AB’
3 1 1 1 AB
An example of 2-variable function f(A,B)=A+B
20. 20
Function can be represented by sum of minterms:
f(A,B) = A’B+AB’+AB
This is not minimal however!
We want to minimize the number of literals and terms.
We factor out common terms –
A’B+AB’+AB= A’B+AB’+AB+AB
=(A’+A)B+A(B’+B)=B+A
Hence, we have
f(A,B) = A+B
21. 21
K-Map: Truth Table in 2 Dimensions
A = 0 A = 1
B = 0
B = 1
0 2
1 3
0 1
1 1
A’B
AB’
AB
f(A,B) = A + B
22. 22
ID A B f(A,B) minterm
0 0 0 0
1 0 1 1 A’B
2 1 0 0
3 1 1 1 AB
Another Example f(A,B)=B
f(A,B)=A’B+AB=(A’+A)B=B
24. 24
ID A B f(A,B) Maxterm
0 0 0 0 A+B
1 0 1 1
2 1 0 0 A’+B
3 1 1 1
Using Maxterms
f(A,B)=(A+B)(A’+B)=(AA’)+B=0+B=B
25. Maxterm example
f(A,B,C) = ∏M(1,2,4,6,7)
=(A+B+C`)(A+B`+C)(A`+B+C) )(A`+B`+C) (A`+B`+C`)
Note that the complements are (0,3,5) which are the minterms of the previous example
0 0 0
0 0
A`B` A`B AB AB`
C`
C
(A+B) (A+B`) (A`+B`) (A`+B)
C
C`
26. 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
x y minterm
0 0 x’y’
0 1 x’y
1 0 xy’
1 1 xy
Y
0 1
0 x’y’ x’y
X
1 xy’ xy
Y
0 1
0 x’y’ x’y
X
1 xy’ xy
Y’ Y
X’ x’y’ x’y
X xy’ xy
27. Karnaugh Map Simplifications
• Imagine a two-variable sum of minterms:
x’y’ + x’y
• 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?
x’y’ + x’y = x’(y’ + y) [ Distributive ]
= x’ • 1 [ y + y’ = 1 ]
= x’ [ x • 1 = x ]
Y
x’y’ x’y
X xy’ xy
28. More Two-Variable Examples
• Another example expression is x’y + xy
– Both minterms appear in the right side, where y is uncomplemented
– Thus, we can reduce x’y + xy to just y
• How about x’y’ + x’y + xy?
– We have x’y’ + x’y in the top row, corresponding to x’
– There’s also x’y + xy in the right side, corresponding to y
– This whole expression can be reduced to x’ + y
Y
x’y’ x’y
X xy’ xy
Y
x’y’ x’y
X xy’ xy
29. A Three-Variable Karnaugh Map
• For a three-variable expression with inputs x, y, z, the arrangement of
minterms is more tricky:
YZ
00 01 11 10
0 x’y’z’ x’y’z x’yz x’yz’
X
1 xy’z’ xy’z xyz xyz’
YZ
00 01 11 10
0 m0 m1 m3 m2
X
1 m4 m5 m7 m6
31. Figure K-map illustrating implicants
1
C
A B
0 0 0 1 1 1 1 0
0 2 6 4
3 7 5
0
1
B
1 1
1 1 1
A
C
Minterms: {A′B′ C, A′ BC′, A′ BC, ABC′, ABC}
Groups of two minterms: {A′ B, AB, A′ C, BC′, BC}
Groups of four minterms: {B}
Prime implicants: {A′ C, B}
Cover = {A′ C, B}
MSOP = A′ C + B
32. Generating and Selecting Prime Implicants
1. Count the number of adjacencies for each minterm on the K-map.
2. Select an uncovered minterm with the fewest number of adjacencies. Make
an arbitrary choice if more than one choice is possible.
3. Generate a prime implicant for this minterm and put it in the cover. If this
minterm is covered by more than one prime implicant, select the one that
covers the most uncovered minterms.
4. Repeat steps 2 and 3 until all minterms have been covered.
33. Generating and Selecting Prime Implicants (Revisited)
1. Circle all prime implicants on the K-map.
2. Identify and select all essential prime implicants for the cover.
3. Select a minimum subset of the remaining prime implicants to complete the
cover, that is, to cover those minterms not covered by the essential prime
implicants.
36. Proper ordering ?
• 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:
• We’ll use this property of adjacent squares to do our simplifications.
x’y’z + x’yz
= x’z(y’ + y)
= x’z • 1
= x’z
x’y’z’ + xy’z’ + x’yz’ + xyz’
= z’(x’y’ + xy’ + x’y + xy)
= z’(y’(x’ + x) + y(x’ + x))
= z’(y’+y)
= z’
Y
x’y’z’ x’y’z x’yz x’yz’
X xy’z’ xy’z xyz xyz’
Z
Y
x’y’z’ x’y’z x’yz x’yz’
X xy’z’ xy’z xyz xyz’
Z
38. Four Variable K-Map Groupings
V
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
BA
BA
BA
BA
DC DC DC DC
Groups of One – 16 (not shown)
Groups of Two – 32 (not shown)
Groups of Four – 24 (seven shown)
CB
1 1
1 1
DB
1 1
1 1
DA
1
1
1
1
CB
1 1
1 1
DB
1
1
1
1
DA
1
1
1
1 DB11
11
38
39. Four Variable K-Map Groupings
V
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
BA
BA
BA
BA
DC DC DC DC
Groups of Eight – 8 (two shown)
B
1 1 1 1
1 1 1 1
D
1
1
1
1
1
1
1
1
39
40. Four Variable K-Map Groupings
V
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
BA
BA
BA
BA
DC DC DC DC
Group of Sixteen – 1
1
40
42. Four-Variable K-Maps
CD
00
00
01
01
11
11
10
10
AB
0 0 0 0
1 1 1 1
0 0 0 0
0 0 0 0
CD
00
00
01
01
11
11
10
10
AB
0 0 1 0
0 0 1 0
0 0 1 0
0 0 1 0
CD
00
00
01
01
11
11
10
10
AB
1 0 1 0
0 1 0 1
1 0 1 0
0 1 0 1
CD
00
00
01
01
11
11
10
10
AB
0 1 0 1
1 0 1 0
0 1 0 1
1 0 1 0
CD
00
00
01
01
11
11
10
10
AB
0 1 1 0
0 1 1 0
0 1 1 0
0 1 1 0
CD
00
00
01
01
11
11
10
10
AB
1 0 0 1
1 0 0 1
1 0 0 1
1 0 0 1
CD
00
00
01
01
11
11
10
10
AB
0 0 0 0
1 1 1 1
1 1 1 1
0 0 0 0
CD
00
00
01
01
11
11
10
10
AB
1 1 1 1
0 0 0 0
0 0 0 0
1 1 1 1
f (4,5,6,7) A B= = •∑ f (3,7,11,15) C D= = •∑
f (0,3,5,6,9,10,12,15)= ∑ f (1,2,4,7,8,11,13,14)= ∑
f A B C D= ⊗ ⊗ ⊗ f A B C D= ⊕ ⊕ ⊕
f (1,3,5,7,9,11,13,15)= ∑ f (0,2,4,6,8,10,12,14)= ∑ f (4,5,6,7,12,13,14,15)= ∑ f (0,1,2,3,8,9,10,11)= ∑
f D= f D= f B= f B=
43. • 4 Variable Maps
– f(A,B,C,D) = Σm(0,1,2,3,6,8,9,11,13,14)
– f = A C' D + B C D' + B' C ' + B' D + A'B'
C D
A B
00 01 11 10
00 1 1 1 1
01 0 0 0 1
11 0 1 0 1
10 1 1 1 0
44. • Another 4 Variable Map
– f(A,B,C,D) = Σm(0,1,2,5,6,7,8,9,10,13,15)
C D
A B
00 01 11 10
00 1 1 0 1
01 0 1 1 1
11 0 1 1 0
10 1 1 0 1
These are not
essential!
45. 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.
46. K-map Simplification @ SoP Expressions
• Let’s consider simplifying f(x,y,z) = xy + y’z + xz
• 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:
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) = x’y’z + xy’z + xyz’+ xyz
= m1 + m5 + m6 + m7
47. 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 it’s occasionally useful.
• In both cases, we’re 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
xy + y’z + xz = (xy • 1) + (y’z • 1) + (xz • 1)
= (xy • (z’ + z)) + (y’z • (x’ + x)) + (xz • (y’ + y))
= (xyz’ + xyz) + (x’y’z + xy’z) + (xy’z + xyz)
= xyz’ + xyz + x’y’z + xy’z
= m1 + m5 + m6 + m7
48. Minimum product of sums (POS)
• The minimum product of sums (POS) of a
function, f, is a POS representation of f that
contains the fewest number of sum terms and the
fewest number of literals of any POS
representation of f.
• The zeros are considered exactly the same as
ones in the case of sum of product (SOP)
50. PoS Optimization
• Maxterms are grouped to find minimal PoS expression
x +y+z x+y+z’ x+y’+z’ x+y’+z
x’ +y+z x’+y+z’ x’+y’+z’ x’+y’+z
00 01 11 10
0
1
x
yz
51. PoS Optimization
• F(W,X,Y,Z)= ∏ M(0,1,2,4,5)
x +y+z x+y+z’ x+y’+z’ x+y’+z
x’ +y+z x’+y+z’ x’+y’+z’ x’+y’+z
00 01 11 10
0
1
x
yz
0 0 1 0
0 0 1 1
00 01 11 10
0
1
x
yz
F(W,X,Y,Z)= Y . (X + Z)
52. Terminology ( cont. )
•Sometimes writing an expression in a POS form is easier as
seen in the following example:
0 1 1 0
1 1 1 1
00 01 11 10
0
1
Karnaugh Map
1 3 2
5 7 64
0
AB
C
52
53. • POS Minimization
– K-maps can be used for POS minimization, too
– f(A,B,C) = Σm(2,3,6)
• Minimum POS is f = (B)(A' + C') cost = 2 + 4 = 6
• Minimum SOP is f = A'B + BC' cost = 3 + 6 = 9
B C
A
00 01 11 10
0 0 0 1 1
1 0 0 0 1
54. I don’t care!
• You don’t always need all 2n
input combinations in an n-variable function
– If you can guarantee that certain input combinations never occur
– If some outputs aren’t used in the rest of the circuit
• We mark don’t-care outputs in truth tables and K-maps with Xs.
x y z f(x,y,z)
0 0 0 0
0 0 1 1
0 1 0 X
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 X
1 1 1 1
55. – Many times there are incompletely specified conditions
• Valuations that can never occur, or for which we “don’t care what
the device does”
– Modeling such a device requires us to specify don’t care conditions in
those instances
• Use X as a value to indicate we don't care what happens
– Don't care situations are often called incompletely specified functions
Don’t Care Conditions
56. • Example Using Don't Cares
– f(A,B,C,D) = Σm(1,5,8,9,10) + d(3,7,11,15)
– f = A B' + A' D
C D
A B
00 01 11 10
00 0 1 X 0
01 0 1 X 0
11 0 0 X 0
10 1 1 X 1
57. 1. Choose an element from the “on” set
2. Find all maximal groups (prime implicants) of “on” elements and X
elements adjacent to that element
Note 1: prime implicants are always a power of 2 in size
Note 2: do not feel compelled to include X’s – use them only
when they provide a larger implicant
3. Repeat steps 1-2 for all elements in the “on” set
4. Select all essential prime implicants
5. For all elements of the “on” set not covered by the essential prime
implicants, select the smallest number of prime implicants that cover
them
Karnaugh Map Method Restated
58. K-map Summary
• K-maps are an alternative to algebra for simplifying expressions
– The result is a MSP/MPS, which leads to a minimal two-level circuit
– It’s easy to handle don’t-care conditions
– K-maps are really only good for manual simplification of small
expressions...
• Things to keep in mind:
– Remember the correct order of minterms/maxterms on the K-map
– When grouping, you can wrap around all sides of the K-map, and your
groups can overlap
– Make as few rectangles as possible, but make each of them as large as
possible. This leads to fewer, but simpler, product terms
– There may be more than one valid solution
59. Timing Hazards in Combinational Logic Circuits
• Hazards are undesirable changes in the output of a
combinational logic circuit caused by unequal gate
propagation delays.
• Static hazard (glitch) -- the output momentarily changes from
the correct or static state
– Static 1 hazard -- the output changes from 1 to 0 and back
to 1
– Static 0 hazard -- the output changes from 0 to 1 and back
to 0
• Dynamic hazard (bounce) -- the output changes multiple times
during a change of state
– Dynamic 0 to 1 hazard -- the output changes from 0 to 1 to
0 to 1
– Dynamic 1 to 0 hazard -- the output changes from 1 to 0 to
1 to 0
60. Illustration of a static hazard.
x 1
x 2
x 3
x 1
y 1
y 2
G 1
G 2
G 3I 1
z ( x 1
, x 2
, x 3
)
( a ) ( b )
x 1
x 2
x 3
y 1
y 2
G 1
G 2
G 3
z ( x 1
, x 2
, x 3
)
x 1
61. Illustration of a static hazard (con’t)
x 1
x 2
x 3
y 1
y 2
z
T i m e
( c )
t 1
t 2
t 3
t 4
t 5
t 6
D t
D t
D t
62. Illustration of a static hazard (con’t).
x 1
x 2
x 3
y 1
y 2
z
T i m e
( d )
t 1
t 2
t 3
t 4
t 5
t 6
t 7
t 8
t 9
D t 2
D t 3
D t 1 D t 3
D t 2
D t 3
68. Quine-McCluskey Minimization Method
• Advantages over K-maps
– Can be computerized
– Can handle functions of more than six variables
• Overview of the method
– Given the minterms of a function
– Find all prime implicants (steps 1 and 2)
• Partition minterms into groups according to the number of 1’s
• Exhaustively search for prime implicants
– Find a minimum prime implicant cover (steps 3 and 4)
• Construct a prime implicant chart
• Select the minimum number of prime implicants
69. Use the Q-M method to find the
MSOP of the function
f(A,B,C,D) = ∏m(2,4,6,8,9,10,12,13,15)
C D
A B
1
0 0 0 1 1 1 1 0
0 4 1 2 8
1 5 1 3 9
3 7 1 5 1 1
2 6 1 4 1 0
0 0
0 1
1 1
1 0
B
D
1 1
1
1 1 1
A
C
1 1
Figure K-map for example 3.30.
72. Step 3 -- Prime Implicant Chart
642 8 1 0 1 2 1 3 1 5
×
⊗
√
P I 2
P I 3
P I 4
P I 5
P I 6
* * P I 7
* * P I 1
×
×
× ×
×
×
×
×
×
×
× × ×
9
√ √ √ √
⊗
73. Step 4 -- Reduced Prime Implicant Chart
642 1 0
×
√
P I 2
* P I 3
* P I 4
P I 5
P I 6
×
×
×
√√ √
× ×
×
×
74. The Resulting Minimal Realization of f
f(A,B,C,D) = PI1 + PI3 + PI4 + PI7
= 1-0- + -010 + 01-0 + 11-1
= AC′ + B′ CD′ + A′ BD′ + ABD
75. How the Q-M Results Look on a K-map
C D
A B
0 0 0 1 1 1 1 0
0 4 1 2 8
1 5 1 3 9
3 7 1 5 1 1
2 6 1 4 1 0
0 0
0 1
1 1
1 0
B
1
A
C
1 1
1
D
1
1
1
1 1
Figure 3.33 Grouping of terms.
76. Covering Procedure
Step 1 -- Identify any minterms covered by only one PI. Select
these PIs for the cover.
Step 2 -- Remove rows covered by the PIs identified in step 1.
Remove minterms covered by the removed rows.
Step 3 -- If a cyclic chart results from step 2, go to step 5.
Otherwise, apply the reduction procedure of steps 1 and 2.
Step 4 -- If a cyclic chart results from step 3, go to step 5.
Otherwise return to step 1.
Step 5 -- Apply the cyclic chart procedure. Repeat step 5 until a
void chart or noncyclic chart chart is produced. In the latter
case, return to step 1.
77. Coverage Example
f(A,B,C,D) = ∑m(0,1,5,6,7,8,9,10,11,13,14,15)
510 6 8 9 1 0 1 1
×
⊗
√
* * P I 1
P I 2
P I 3
P I 4
P I 5
P I 6
* * P I 7
×
×
×
×
×
× × ×
7
√ √ √ √ √
1 3 1 4 1 5
√ √
⊗
× ×
×
×
×
×
× × ×
× ×
×
×
×
×
×
×
78. Reduced PI Charts
1 11 05 1 3
×
P I 2
P I 3
P I 4
P I 5
P I 6
×
× ×
×
×
× ×
× ×
×
√ √
×
1 05
* P I 2
* P I 4
79. Cyclic PI Charts
1. No essential PIs.
2. No row or column coverage.
321 4
×
* P I 1
P I 2
P I 3
P I 4
P I 5
P I 6
× ×
√√
× ×
×
5 6
××
× ×
××
542 6
×
P I 2
P I 3
P I 4
P I 5
P I 6
×
×
×
×
×
×
×
542 6
×
√
* P I 3
P I 4
* P I 5
×
√√ √
× ×
×
×
80. Using the Q-M Procedure with Incompletely Specified Functions
1. Use minterms and don’t cares when generating prime implicants
2. Use only minterms when finding a minimal cover
Example 3.25 -- Find a minimal sum of products of the following function
using the Quine-McCluskey procedure.
85. Half Adder 85
Half Adder (1/2)
Half-Adder is a circuit which adds two single bits (called X,Y) together, to produce a
result of two bits (called C, S).
A black-box representation of this circuit is:
Truth table representation is:
X Y C S
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
Half
adder
X
Y
(X+Y)
S
C
86. Half Adder 86
Half Adder (2/2)
In sum-of-minterms forms:
C = X.Y
S = X'.Y + X.Y'
Algebraic simplification could simplify S to:
S = X'.Y + X.Y'
= X⊕Y
Giving:
X Y C S
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
X
Y
S
C
Notes de l'éditeur
Explain what K-Maps are, why we use them, and the advantages of using K-Maps over Boolean algebra.
Two variable K-Map, groups of one.
Two variable K-Map, groups of two.
Two variable K-Map, group of four.
Three Variable K-Map:
8 groups of one are not shown because they are obvious.
12 groups of two; all are shown.
Three Variable K-Map:
6 groups of four; all are shown.
Three Variable K-Map, Group of Eight.
Four Variable K-Map:
There are 16 groups of one that are not shown because they are obvious.
There are 32 groups of two that are not shown because they are obvious.
There are 24 groups of four. Seven are show, the other 17 are obvious.
Four variable K-Map: There are 8 groups of eight. Two are shown, the other 6 are obvious.