Kmap
Kmap
Kmap
Circuit Minimization
Karnaugh maps (K-maps) provide an easy and visual technique for finding the minimum cost SOP (or POS) form for a Boolean expression
This technique has limitations. i.e. works for # inputs < 7 Not good for CAD tools, but good for teaching the idea of simplification
x y + x y'
x (y + y')
=x
Example:
m0 and m2 can be combined to get x1'x3' Reduced fan in and reduced number of gates
f(x1,x2) = m(0,1,3)
x1 x2 0 1 0 1 F 1 1 0 1
Canonical SOP:
0 0 1 1
0
1 0
1
1 1 minimum form: f = x1'+x2
3 Variable Map
f(A,B,C) = m(1,2,6,7)
BC A 0 00 0 01 1 11 0
Gray Code: any two consecutive numbers differ in only a single bit
10 1
CD AB 00 01 11 10
00 m0 m4
01 m1 m5
11 m3 m7
10 m2 m6
Full-Adder Carry-Out
Cout(A,B,Cin) = m(3,5,6,7)
B Cin A 0 00 0 01 0 11 1 10 0
00
01
11
10
(A B)
BC A 0 1
00 1 0
01 1 0
11 1 1
10 1 1
f = A' + B
00
01
11
10
(A C)
BC A 0 1
00 1 1
01 0 0
11 0 1
10 1 1
f = C' + A B
Full-Adder Sum
S(A,B,Cin) = m(1,2,4,7)
B Cin A 0 1 00 0 1 01 1 0 11 0 1 10 1 0
Minimum is S = A B' Cin' + A' B' Cin + A B Cin + A'B Cin' Can't reduce anything and stay in SOP form!
A binary Gray code is a binary sequence such that no two consecutive numbers differ by more that a single bit Gray codes have many uses in CS
2 bit Gray code: 00, 01, 11, 10 Note that this is circular 10, 00 again differs in only 1 bit These are called binary reflected Gray codes 3 bit Gray code: 000, 001, 011, 010, 110, 111, 101, 100
If s0, s1, s2, , s2n is a n bit Gray code, then we can construct an n+1 bit Gray code as follows: 0s0, 0s1, 0s2, , 0s2n, 1s2n, 1s2n-1, 1s2n-2, , 1s1 ,1s0 Example:
00, 01, 11, 10 00, 01, 11, 10 followed by 10, 11, 01, 00 000, 001, 011, 010 followed by 110, 111, 101, 100 Result is 000, 001, 011, 010, 110, 111, 101, 100
Choose a 1 element Find all maximal groups of 1's adjacent to that element
3.
4.
Repeat steps 1-2 for all 1 elements Select all boxes for which a 1 is covered by only that box
5.
For all 1's not covered by the essential boxes, select the smallest number of other boxes that cover them
4 Variable Maps
f(A,B,C,D) = m(0,1,2,3,6,8,9,11,13,14)
CD AB 00 01 11 10 00 1 0 0 1 01 1 0 1 1 11 1 0 0 1 10 1 1 1 0
f(A,B,C,D) = m(0,1,2,5,6,7,8,9,10,13,15)
CD AB 00 00 1 0 0 1 01 1 1 1 1 11 0 1 1 0 10 1 1 0 1
01 11 10
Terminology
An implicant is a product term in an SOP expression (or a sum term in POS expression)
Implicants are always rectangular in shape and the # of 1's covered is a power of 2
A prime implicant is an implicant that is not fully contained in some other larger implicant
BC 00 1 0 01 1 0 11 1 1 10 1 1
A
red implicant (but not prime) many more are not shown blue prime implicants (only two)
0 1
An essential prime implicant is a prime implicant that contains a 1 not included in any other prime implicant
A cover is a collection of implicants that accounts for all valuations in which the function is on (e.g. 1)
01
11 10
1
1 1
1
0 0
1
1 1
1
0 1 CD AB 00 01 00 1 1 1 1 01 0 1 0 0 11 0 1 1 1 10 1 1 0 1
11 10
Valuations that can never occur, or for which we dont care what the device does
Modeling such a device requires us to specify dont care conditions in those instances
f = A B' + A' D
Choose an element from the on set 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 Xs use them only when they provide a larger implicant
3. 4. 5.
Repeat steps 1-2 for all elements in the on set Select all essential prime implicants For all elements of the on set not covered by the essential prime implicants, select the smallest number of prime implicants that cover them
4 bit codes: 0000 (0) thru 1001 (9) allowed 4 bit input code should operate lights of a 7 segment display: codes 1010 1111 never occur 7 output signals one for each light
a
a b g f b g
f e d
WXYZ = 1001
c
c
d
d = 1 is optional
W 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 X 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
YZ WX 00 01 11 10
00 1 0 X 1
01 0 1 X 1
11 1 1 X X
10 1 X X X
K-map for a
a = W + Y + X'Z' + XZ
The lights (LEDs) on a real 7 segment display are always active low
When you want to use our design, just invert all the results
a f g e d c b
5 Variable K-map
YZ WX 00 01 11 10
00 0 0 1 1
01 0 X 1 1
11 0 1 0 0
10 0 1 X X
YZ WX 00
00 0
01 0
11 1
10 1
01
11 10
0
1 X
0
1 1
X
X X
1
X X
V=0
V=1
f = WY' + W'XY + VY
POS Minimization
cost = 2 + 4 = 6 cost = 3 + 6 = 9
CD AB 00 01 11 10
00 0 0 1 1
01 1 1 1 1 SOP
11 X X X X
10 0 0 0 1
CD AB 00
00 0
01 1
11 X
10 0
01
11 10
0
1 1
1
1 1
X
X X
0
0 1
POS
using two separate systems, or using one combined system that may share gates
A B C A B C
A B C
F G
Gate Sharing
CD AB 00 01 11 10
BC A 0 1
f = B'C' + A'BC
g = B'C + A'C, or g = B'C + A'BC By choosing an implicant that was non-prime, we get an overall cost that is less (due to sharing)
CD AB 00 01 11 10
Look for the 1's that are not 1's for the other function
Then look for shared terms still implicants, but not necessarily prime
Another Example
Note that minterm m1 can be covered by 2 possible prime implicants choose based on gate sharing
00 0 0 0 0 01 1 1 0 1 11 1 1 0 0 10 1 0 0 0
CD AB 00 01 11 10
CD AB
00 01 11 10
00
1 0 0 1
01
0 1 1 1
11
0 1 1 1
10
0 0 0 0
Cost Saving
Based on sharing:
Individually:
CD AB 00
00 X
01 1
11 1
10 0
CD AB 00 01 11 10
00 X X 0 1
01 0 0 0 1
11 1 0 X X
10 0 0 1 1
01 11
10
X 1
1
0 0
1
0 X
X
1 1
0
Alternate Solution
CD AB 00
00 X
01 1
11 1
10 0
CD AB 00 01 11 10
00 X X 0 1
01 0 0 0 1
11 1 0 X X
10 0 0 1 1
01 11
10
X 1
1
0 0
1
0 X
X
1 1
0