Professional Documents
Culture Documents
Boolean algebra can be used to find minimal SOP (POS) logic equations, but it is hard to automate and not very systematic. For small logic functions (<=5 inputs), we can use Karnaugh Map (KMap). KMaps allow us to minimize functions graphically. A KMap is simply an alternative representation to a truth table.
Page 1
Page 2
Canoncial SOP using minterms is: Consider presenting the information in the truth table via a 2-D matrix such that all the same information is presented!
Page 3
Notice: in the first column (where x1 = 0), the function must output a logical 1. Further, note that the value of x2 does not matter (it can be 0 or 1). Similar situation for the second row (where x2 = 1 and the value of x1 does not matter). Each of these rectangles represents a product term for the logic function f. We need to cover all of the 1s of the function so we can write a SOP using product terms. Minimum SOP using product terms is:
Page 4
Represent the same information as a 2-D matrix. This is a 3-variable Karnaugh map.
Note: we always number such that only one variable changes between adjacent columns or rows (Gray codes). Note: columns (and rows) wrap around from left-to-right (top-to-bottom).
Page 5
Page 6
Example 2:
Page 7
Some Comments
To properly implement a function using K-Maps, we must make sure to select enough rectangles (product terms) to cover all of the squares for which the function outputs a 1. Rectangles in the K-Map (product terms) are always powers of 2 in terms of area. Minterms are rectangles of area 1 (1x1). Product terms are rectangles of area 2 (1x2,2x1), area 4 (2x2,1x4,4x1), area 8, area 16, etc Every time we can expand a rectangle to enclose additional 1s, we remove a literal from the product term. Note that it is okay to cover an output 1 multiple times!
ECE124 Digital Circuits and Systems Page 8
Enclosing larger squares are better, as it implies fewer literals and product terms.
Page 9
Page 10
Page 11
00 1 0 0 0
m4
01 0 1 1 1
11 0 1 1 0
10 1 0 0 0
00 1 0 0 0
m5
01 0 1 1 1
11 0 1 1 0
10 1 0 1 1
01 11
x3x4 00
00
01
11
10 x5=0
m0
m8
m24
m16
m1
m9
m25
m17
m2
m10
m26
m18
m3
m11
m27
m19
10
m6
m14
m30
m22
m7
m15
m31
m23
m12
m28
m20
m13
m29
m21
11 10
Page 12
Page 13
Some Comments
So far we have used KMaps to find minimized SOP representations for functions. Our general strategy is as follows: Find product terms with as few literals as possible (by finding larger rectangles in the K-Map covering 1s). Select as few rectangles (product terms) as possible, so that all of the 1s in the KMap are covered. It is okay is a 1 is covered by more than one product term. It is possible that there are multiple solutions that are equally as good.
Page 14
A different way to think of enclosing the 0s is that you are finding an SOP for !f, and then taking the complement for get a POS expression for f.
Page 15
Dont Cares
Sometimes, we might have inputs and it doesnt matter what the output is; i.e., we dont care what the output is. These situations are called dont cares. Rather than using a 1 or a 0, we can use an X to mark a dont care. Why are dont cares important and useful???
Well, if we are looking for a minimum representation using as few literals and gates as possible, we can force the dont care locations to either 0 or 1, however it helps us.
Page 16
For the smallest SOP implementation, it appears good to let one of the dont cares be a 1, while the other 2 are 0.
Question: Is there another equally as good implementation that uses the dont cares differently?
Page 17
When we have dont cares, we can get equally good expressions that are logically correct (i.e., we get output of 1 when it must be 1, and 0 when it must be 0). However, depending on how we use the dont cares, multiple expressions will not equal each other algebraically.
Note that both f1 and f2 are valid implementations of f, but are not algebraically equal to each other since the dont cares are used differently when finding both f1 and f2.
Page 18
We can minimize each function individually, but sometimes the overall circuit implementation will be better if we consider both functions simultaneously.
Basically, we will try to find common product terms useful for both functions and then share them.
Page 19
The functions have no product terms in common. The cost of f_1 is 1 OR + 3 AND + 10 gate inputs = 14. The cost of f_2 is 1 OR + 3 AND + 11 gate inputs = 15. Therefore, to implement the entire circuit the cost is 29.
Page 20
The individual expressions for f1 and f2 are not the best, but If we consider that 2 product terms are shared, the entire circuit requires 2 OR + 4 AND + 17 gate inputs. The total cost of the entire circuit is 23.
Page 21
Page 22
When we have a function and we are told the output is 0 or 1 for every possible input, the function is called completely specified.
When we have a function and are told the output is 0 or 1 for only some of the inputs, we can assume the other inputs have dont cares as outputs. It the situation that we have dont care outputs, the function is incompletely specified. Consider the minterms for any function. We can separate the minterms in to three sets: The on-set is those minterms which require the output to be 1. The off-set is those minterms which require the output to be 0. The dc-set is those minterms which have an output of X (dont care).
Page 23
Page 24
Example of Implicants
In the K-Map, product terms x1 and x2 x3 are prime implicants. Product term x1 x2 is an implicant, but it is not a prime implicant.
Page 25
Page 26
Page 27
Methodical Example
The following K-Map has 6 prime implicants.
4 of them are essential, 2 are not essential.
Page 28
Page 29
The Example
Say we have the following function with 4-inputs. We can draw the truth table, the K-Map, and write the Canonical SOP using minterms.
x1x2 x3x4 00 01 11 10 00 0 1 1 0
m2
01 0 1 1 1
11 0 1 1 0
10 0 0 0 0
m0
m4
m12
m8
m1
m5
m13
m9
m3
m7
m15
m11
m6
m14
m10
Note that the minterms are 1x1 boxes (area 1) in the K-Map.
Page 30
Page 31
Page 32
00 0 1 1 0
m2
01 0 1 1 1
11 0 1 1 0
10 0 0 0 0
00 0 1 1 0
m2
01 0 1 1 1
11 0 1 1 0
10 0 0 0 0
m0
m4
m12
m8
m0
m4
m12
m8
m1
m5
m13
m9
m1
m5
m13
m9
m3
m7
m15
m11
m3
m7
m15
m11
m6
m14
m10
m6
m14
m10
The boxes have DOUBLED in size by merging with an adjacent box of compatible dimension. The result are product terms that handles two rows (minterms) in the truth table.
Page 33
If a variable was removed and replaced with - previously, then the - must match too!!!
We can put (m1,m3) and (m5,m7) next to each other. (Only x2 changes and doesnt matter; x3 = - in both cases). We can put (m5,m7) and (m13.m15) next to each other. (Only x1 changes and doesnt matter; x3 = - in both cases).
Page 34
Page 35
x1x2 x3x4 00 01 11 10
00 0 1 1 0
m2
01 0 1 1 1
11 0 1 1 0
10 0 0 0 0
x1x2 x3x4 00 01 11 10
00 0 1 1 0
m2
01 0 1 1 1
11 0 1 1 0
10 0 0 0 0
m0
m4
m12
m8
m0
m4
m12
m8
m1
m5
m13
m9
m1
m5
m13
m9
m3
m7
m15
m11
m3
m7
m15
m11
m6
m14
m10
m6
m14
m10
The boxes have DOUBLED in size by merging with an adjacent box of compatible dimension. The result are product terms that handles four rows (minterms) in the truth table.
Page 36
The Summary
So why do rectangles in the K-Map need to have areas of 1, 2, 4, 8, etc
Given a product term, we need to find another product term involving the same set of variables.
For these two product terms, it must also be true that one and only one variable appears in complemented form in one of the product terms and in un-complemented form in the other product term.
The two product terms get merged by factoring out the common part which gives something like the following:
Since we begin with minterms (area 1), and merge, and merge, etc. We should see that areas will always double going 1, 2, 4, 8, 16, etc
Page 37