Title: CS 20 Lecture 14 Karnaugh Maps
1CS 20 Lecture 14Karnaugh Maps
- Professor CK Cheng
- CSE Dept.
- UC San Diego
2Karnaugh Maps
- Introduction
- The Maps
- Boolean Optimization
3Introduction
Definitions Literal xi or xi Product
Term x2x1x0 Sum Term x2 x1 x0 Minterm of
n variables A product of n literals in
which every variable appears exactly once.
f(a,b,c,d) abcd, abcd Maxterm of n
variables A sum of n literals in which every
variable appears exactly once. f(a,b,c,d)
(abcd), (abcd)
4Introduction
Input Boolean expression of n binary
variables Goal Simplification of the
expression. E.g. we want to minimize terms and
literals. Applications Logic rule
reduction Hardware Design cost and performance
optimization. Cost (wires, gates) literals,
product terms, sum terms
Performance speed, reliability
5Introduction
An example of 2-variable function f(A,B)AB
ID A B f(A,B) minterm
0 0 0 0
1 0 1 1 AB
2 1 0 1 AB
3 1 1 1 AB
6Function can be represented by sum of
minterms f(A,B) ABABAB This is not
minimal however! We want to minimize the number
of literals and terms. We factor out common terms
ABABAB ABABABAB (AA)BA(BB)BA
Hence, we have f(A,B) AB
7K-Map Truth Table in 2 Dimensions
A 0 A 1
AB
0 2
0 1 1 1
B 0 B 1
1 3
AB
AB
f(A,B) A B
8Another Example f(A,B)B
ID A B f(A,B) minterm
0 0 0 0
1 0 1 1 AB
2 1 0 0
3 1 1 1 AB
f(A,B)ABAB(AA)BB
9On the K-map
A 0 A 1
0 2
0 0 1 1
B 0 B 1
1 3
AB
AB
f(A,B)B
10Using Maxterms
ID A B f(A,B) Maxterm
0 0 0 0 AB
1 0 1 1
2 1 0 0 AB
3 1 1 1
f(A,B)(AB)(AB)(AA)B0BB
11The Maps Representation of k-Variable Functions
- Boolean Expression
- Truth Table
- Cube
- K Map
- Binary Decision Diagram
(1,1,1)
(1,1,0)
A
(0,1,0)
(0,1,1)
B
(1,0,1)
C
(0,0,0)
(0,0,1)
A cube of 3 variables (A,B,C)
12Representation of k-Variable Func.
- Boolean Expression
- Truth Table
- Cube
- K Map
- Binary Decision Diagram
(0,1,1,1)
(0,1,1,0)
(1,1,1,1)
(1,1,1,0)
B
(0,0,1,1)
(0,0,1,0)
(1,0,1,0)
(1,0,1,1)
C
(0,1,0,1)
(1,1,0,1)
D
(0,0,0,0)
(0,0,0,1)
(1,0,0,1)
(1,0,0,0)
A
A cube of 4 variables (A,B,C,D)
13Three-Variable K-Map
Id a b c f (a,b,c) 0 0
0 0 f(0,0,0) 1 0 0 1
f(0,0,1) 2 0 1 0
f(0,1,0) 3 0 1 1 f(0,1,1) 4
1 0 0 f(1,0,0) 5 1 0
1 f(1,0,1) 6 1 1 0
f(1,1,0) 7 1 1 1 f(1,1,1)
14Three-Variable K-Map
Id a b c f (a,b,c) 0 0
0 0 1 1 0 0 1
0 2 0 1 0 1 3 0
1 1 0 4 1 0 0
1 5 1 0 1 0 6 1
1 0 1 7 1 1 1
0
15Corresponding K-map
b 1
Gray code
(0,0) (0,1) (1,1) (1,0)
0 2 6
4
c 0
1 1 1 1
1 3 7
5
c 1
0 0 0 0
a 1
f(a,b,c) c
16Karnaugh Maps (K-Maps)
- Boolean expressions can be minimized by combining
terms - K-maps minimize equations graphically
17K-map
- Find rectangles to cover 1s in adjacent entries.
- Rectangles can overlap but should not include
0s. - Use the rectangle that corresponds to a product
term.
y(A,B)ABCABC AB(CC)AB
18Another 3-Input example
Id a b c f (a,b,c) 0 0
0 0 0 1 0 0 1
0 2 0 1 0 1 3 0
1 1 0 4 1 0 0
1 5 1 0 1 1 6 1
1 0 - 7 1 1 1
1
Dont Care Entry - means the entry is not
relevant either at input or output. In other
words, we are free to assign either 0 or 1 to
reduce the Boolean expression.
19Corresponding K-map
b 1
(0,0) (0,1) (1,1) (1,0)
0 2 6
4
c 0
0 1 - 1
1 3 7
5
c 1
0 0 1 1
a 1
f(a,b,c) a bc
20Yet another example
Id a b c f (a,b,c,d) 0 0
0 0 1 1 0 0 1
1 2 0 1 0 - 3 0
1 1 0 4 1 0 0
1 5 1 0 1 1 6 1
1 0 0 7 1 1 1
0
21Corresponding K-map
b 1
(0,0) (0,1) (1,1) (1,0)
0 2 6
4
c 0
1 - 0 1
1 3 7
5
c 1
1 0 0 1
a 1
f(a,b,c) b
22Quiz
- Given Boolean function,
- f(a,b,c) abacbcabbc
- Write the truth table
- Use Karnaugh map to derive the function in a
minimal expression of sum of product form.
234-input K-map
244-input K-map
254-input K-map
26K-maps with Dont Cares
27K-maps with Dont Cares
28K-maps with Dont Cares