1 cs 20 lecture 14 karnaugh maps professor ck cheng cse dept. uc san diego
Post on 20-Dec-2015
215 views
TRANSCRIPT
1
CS 20 Lecture 14Karnaugh Maps
Professor CK Cheng
CSE Dept.
UC San Diego
2
1. Introduction2. The Maps3. Boolean Optimization
Karnaugh Maps
3
Definitions:Literal: xi or xi’Product Term: x2x1’x0
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): ab’cd’, a’bc’d’ Maxterm of n variables: A sum of n literals in which every variable appears exactly once. f(a,b,c,d): (a’+b+c+d), (a’+b’+c+d)
Introduction
4
Introduction
Input: Boolean expression of n binary variablesGoal: Simplification of the expression.E.g. we want to minimize # terms and # literals.Applications:Logic: rule reductionHardware Design: cost and performance optimization. Cost (wires, gates): # literals, product terms,
sum terms Performance: speed, reliability
5
Introduction
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
6
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 havef(A,B) = A+B
7
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
8
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
9
On the K-map:
A = 0 A= 1
B= 0
B = 1
0 2
1 3
0 0
1 1
A’B AB
f(A,B)=B
10
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
The Maps: Representation of k-Variable Functions
• Boolean Expression• Truth Table• Cube• K Map• Binary Decision
Diagram
11
(1,1,1)(1,1,0)
(0,0,0) (0,0,1)
(0,1,0) (0,1,1)
(1,0,1)
A cube of 3 variables: (A,B,C)
C
B
A
Representation of k-Variable Func.
• Boolean Expression• Truth Table• Cube• K Map• Binary Decision
Diagram
12
(0,1,1,1)(0,1,1,0)
(0,0,0,0) (0,0,0,1) (1,0,0,1)
(1,1,1,1)
(1,1,0,1)(1,0,0,0)
(0,0,1,0)
(1,1,1,0)
(0,0,1,1) (1,0,1,1)
(0,1,0,1)
(1,0,1,0)
A cube of 4 variables: (A,B,C,D)
D
C
B
A
13
Three-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)
14
Three-Variable K-Map
Id a b c f (a,b,c)
0 0 0 0 1
1 0 0 1 02 0 1 0 13 0 1 1 04 1 0 0 15 1 0 1 06 1 1 0 17 1 1 1 0
15
Corresponding K-map
0 2 6 4
1 3 7 5
b = 1
c = 1
a = 1
1 1 1 1
0 0 0 0
(0,0) (0,1) (1,1) (1,0)
c = 0
Gray code
f(a,b,c) = c’
16
Karnaugh Maps (K-Maps)• Boolean expressions can be minimized by combining
terms• K-maps minimize equations graphically
C 00 01
0
1
Y
11 10AB
1
1
0
0
0
0
0
0
C 00 01
0
1
Y
11 10AB
ABC
ABC
ABC
ABC
ABC
ABC
ABC
ABC
B C0 00 11 01 1
A0000
0 00 11 01 1
1111
11000000
Y
17
• Find rectangles to cover 1’s in adjacent entries.• Rectangles can overlap but should not include 0’s.• Use the rectangle that corresponds to a product
term.
K-map
C 00 01
0
1
Y
11 10AB
1
0
0
0
0
0
0
1
B C0 00 11 01 1
A0000
0 00 11 01 1
1111
11000000
Y
y(A,B)=A’B’C’+A’B’C= A’B’(C’+C)=A’B’
18
Another 3-Input example
Id a b c f (a,b,c)
0 0 0 0 0
1 0 0 1 02 0 1 0 13 0 1 1 04 1 0 0 15 1 0 1 16 1 1 0 -7 1 1 1 1
Don’t 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.
19
Corresponding K-map
0 2 6 4
1 3 7 5
b = 1
c = 1
a = 1
0 1 - 1
0 0 1 1
(0,0) (0,1) (1,1) (1,0)
c = 0
f(a,b,c) = a + bc’
20
Yet another example
Id a b c f (a,b,c,d)
0 0 0 0 1
1 0 0 1 12 0 1 0 -3 0 1 1 04 1 0 0 15 1 0 1 16 1 1 0 07 1 1 1 0
21
Corresponding K-map
0 2 6 4
1 3 7 5
b = 1
c = 1
a = 1
1 - 0 1
1 0 0 1
(0,0) (0,1) (1,1) (1,0)
c = 0
f(a,b,c) = b’
22
Quiz
Given Boolean function, f(a,b,c)= a’b’+a’c’+bc’+ab+b’c1.Write the truth table2.Use Karnaugh map to derive the function in a minimal expression of sum of product form.
23
4-input K-map
01 11
01
11
10
00
00
10AB
CD
Y
0
C D0 00 11 01 1
B0000
0 00 11 01 1
1111
1
110111
YA00000000
0 00 11 01 1
0000
0 00 11 01 1
1111
11111111
11
100000
24
4-input K-map
01 11
1
0
0
1
0
0
1
101
1
1
1
1
0
0
0
1
11
10
00
00
10AB
CD
Y
0
C D0 00 11 01 1
B0000
0 00 11 01 1
1111
1
110111
YA00000000
0 00 11 01 1
0000
0 00 11 01 1
1111
11111111
11
100000
25
4-input K-map
01 11
1
0
0
1
0
0
1
101
1
1
1
1
0
0
0
1
11
10
00
00
10AB
CD
Y
Y = AC + ABD + ABC + BD
0
C D0 00 11 01 1
B0000
0 00 11 01 1
1111
1
110111
YA00000000
0 00 11 01 1
0000
0 00 11 01 1
1111
11111111
11
100000
26
K-maps with Don’t Cares
0
C D0 00 11 01 1
B0000
0 00 11 01 1
1111
1
110X11
YA00000000
0 00 11 01 1
0000
0 00 11 01 1
1111
11111111
11
XXXXXX
01 11
01
11
10
00
00
10AB
CD
Y
27
K-maps with Don’t Cares
0
C D0 00 11 01 1
B0000
0 00 11 01 1
1111
1
110X11
YA00000000
0 00 11 01 1
0000
0 00 11 01 1
1111
11111111
11
XXXXXX
01 11
1
0
0
X
X
X
1
101
1
1
1
1
X
X
X
X
11
10
00
00
10AB
CD
Y
28
K-maps with Don’t Cares
0
C D0 00 11 01 1
B0000
0 00 11 01 1
1111
1
110X11
YA00000000
0 00 11 01 1
0000
0 00 11 01 1
1111
11111111
11
XXXXXX
01 11
1
0
0
X
X
X
1
101
1
1
1
1
X
X
X
X
11
10
00
00
10AB
CD
Y
Y = A + BD + C