## Presentation on theme: ""— Presentation transcript:

Lecture 5 Karnaugh Maps One of the easiest ways to simplify a Boolean expression is through the use of a Karnaugh map. Let us recall the OR gate (again!) The Boolean minterm is A B + A B + A B The general form of a 2 input Karnaugh map is below. Note that each square differs from its neighbouring square by changing only 1 of the numbers- this is more important for 3 and greater Karnaugh maps A logic function with n variables will require 2n squares B A 00 01 11 10

To produce a simplified Boolean expression using a K-map
(1) produce the Boolean minterm (2) plot the 1s for the ANDed variables in the appropriate square (3) loop adjacent (horizontal or vertical groups of 8, 4, or 2 1s together (4) eliminate variable/complements pairs (5) OR the remaining variables Lets use the OR function as an example. 1. The Boolean minterm is 2 A B + A B + A B B A

B A 1 Loop 1 3. Loop adjacent 1s Loop 2 4. Eliminate variable/complements pairs From loop 1: A B and A B, since A and A are variable and complement they are eliminated. This leaves only B. From loop 2, A B and A B, since B and B are variable and complement they are eliminated. This leaves only A. 5. OR the remaining variables Y = A + B

Note You may only loop horizontally or vertically. This is because you are changing just one variable at a time. You cannot loop diagonally. Start with the highest number of squares 8, then 4 then 2. If you have a group of 4, it is the same as looping 4 groups of 2. (Can you see where the 4 doublets are?) You can loop the same 1 more than once – in fact you can do this often.

Consider the case of a 3 input K map. In this case we have A, B and C
which are grouped into the 4 possible AB combinations x 2 possible C combinations. Therefore the K map will have 8 squares A B A B C Consider the truth table. Step 1. Minterm Y =

Step 2. Mark 1s in the appropriate squares
A B A B C Step 3. Loop 8, 4 or 2, adjacent 1s. Step 4. Eliminate variable/complements pairs Step 5. OR remaining variables

Check 1: Do we always get a 1 when C = 1 Do we always get a 1 when A B = 1

Check 2: Can we simplify the original minterm expression to get the same answer. Y = A B C + A B C + A B C + A B C + A B C

AB CD Pick any square and
As the number of variables increases K maps become very useful. Consider the case of a 4 variable input (A,B,C and D). There are 4 possible AB combinations x 4 possible CD combinations so the K map will have 16 squares. Fill in the possible arrangements AB CD Pick any square and going vertically or horizontally we only change one variable at a time.

A B A B C D Note the pattern  0 1  1 1  1 0 We are changing one bit at a time. This single variable change is called adjacency. The bit in the sequence is which is the same as the first bit. This is important when considering special looping arrangements

Exercise 5.1 Use this 4 input truth table.
Step 1. Write out the unsimplified Boolean minterm

Step 2. Mark 1s in the appropriate squares
Step 3. Loop 8, 4 or 2 adjacent 1s. Step 4. Eliminate variable/complements pairs Step 5. OR remaining variables

Check: Do you get a ‘1’ when D = 1 or when A B C = 1

Lecture 6 K maps can have some unusual looping arrangements.
You should prove to yourself that the K map for the expression Y = A B C D + A B C D + A B C D + A B C D + A B C D is given below A B A B C D 1

Is loop 3 permitted???? NO A B A B C D Loop 1 B and B - eliminate
A, C, D - keep 1 1 1 1 1 Loop 2 B and B - eliminate A, C, D - keep Is loop 3 permitted???? NO

Why can we not loop on a diagonal or a group of 3??

So the original expression can be simplified to
Y = A C D + A C D + A B C D But we can combine the first 2 terms here to give Y = A C D + A C D + A B C D = A (C + C ) D + A B C D = A D + A B C D Is this the case could we not have done this using the K-map. Answer – we can if we look for ‘unusual’ looping arrangements.

A B A B C D 1 Eliminate B and B also C and C which just leaves A and D A B A B 1 C D This grouping is equivalent to

Other interesting looping arrangements are
A B A B C 1 1 No change 1 A B A B C Eliminate A and A gives B and C 1 1 1 Y = A B C + B C

A B A B C D 1 1 1 1 Y = B D

You should prove that looping (i) vertically and (ii) horizontally
gives the same result. A B A B A B A B C D 1 1 C D C D C D 1 1

We can come to some conclusions about the structure of K maps
We can come to some conclusions about the structure of K maps. For a 3 variable K map a 1 cell group yields a 3 variable product term a 2 cell group yields a 2 variable product term a 4 cell group yields a 1 variable product term a 8 cell group yields a value of 1 for the expression Example. What logic expression do we get from these K maps? A B A B C 1 1 1 1 A B A B C 1 1 1 1

This allows us to regard different parts of the K map to be associated with different variables.

For a 4 variable K map a 1 cell group yields a 4 variable product term a 2 cell group yields a 3 variable product term a 4 cell group yields a 2 variable product term a 8 cell group yields a 1 variable product term a 16 cell group yields a value of 1 for the expression A B A B C D

Similar to a 3 variable to a map we can regard different parts of the K
map to be associated with different variables. A B A B C D

Some formal definitions
A literal is a variable either complemented or not complemented. Example A, B and D Normal product term is a product of terms in which no variable appears more than once. Example AB or ACD. An example of a non-normal product term would be ACC

An implicant is a normal product term that implies Y = 1
An implicant is a normal product term that implies Y = 1. For example if Y= AB + BC, the implicants are AB and BC. A prime implicant (PI) is one that is not a subset of another implicant. In a K map a PI is the largest possible grouping allowed. E.g a group of 4 will be a PI whereas the two groups of 2 will only be implicants. A distinguished 1-cell is a cell that is covered by only one PI. In a K-map, such cells are 1s that are circled once. An essential prime implicant is a PI if it includes a 1 that is not included in any other prime implicant. For a K map the EPIs must include the PIs associated with a distinguished 1 cells.

5. A minimal sum is a SOP expression such that no SOP expression of Y has fewer product terms.
It will include the EPIs but MUST also include whatever number of other terms to make sure that all the 1s have been covered.

The best way to examine these terms is by means of an example
The best way to examine these terms is by means of an example. Using the information in the K-map to determine the number and list of PIs, The distinguished 1-cells, the EPIs and the minimal sum. A B A B C D 1

So we can write Y as Y = This SOP expression contains 5 terms – these are the 5 implicants. What we want to see is if it is possible to write out another expression for Y but which has fewer terms.

the PIs, The distinguished 1-cells, the EPIs and the minimal sum.

Recall that Y = Now Ymin = A C D + A C D + other terms???? The key point was the distinguished 1-cells are also EPI and the EPI will form part of the minimal sum. We must check whether using the EPIs alone is sufficient so that all the 1s are covered. Answer – NO we must add an extra term/s – but which one?? Add BCD to the EPIs to give the minimal sum

Exercise 6. 1. Here is a slight variation from the previous example
Exercise 6.1. Here is a slight variation from the previous example. Using the information in the K-map to determine the number and list of PIs, The distinguished 1-cells, the EPIs and the minimal sum. A B A B C D 1

the PIs, The distinguished 1-cells, the EPIs and the minimal sum.

In each of the 3 maps the location of the EPI have been circled
1 In each of the 3 maps the location of the EPI have been circled How do we know that theses are EPIs? They are the PIs associated with a distinguished 1 cell. So the minimal sum will include these two terms. How many ways is it possible to group together the other 1s present using as small a number of groups as possible?? 1 1

So the minimal sum will include these two terms.
Do these two terms cover all the 1s present? If YES then the the minimal sum is just the EPIs If NO then we need to add the minimal number of extra terms How many ways is it possible to group together the other 1s present using as small a number ofgroups as possible??

The previous example showed that that there are 3 ways
to ensure that all the 1s are covered so there are three possible ways to write out the the minimal sum Ymin = A B C + A C D + Ymin = A B C + A C D + Each of these uses 4 terms. The original expression used 6. This means that there exist expressions with 5 PI but they do not form a minimal sum.

Exercise 6.2 Using the information in the K-map to determine
the number and lists of PIs, The distinguished 1-cells, the EPIs and the minimal sum. A B A B C D 1 1 1 1 1 1 1 1 1

the PIs, The distinguished 1-cells, the EPIs and the minimal sum.

Remember this is the ‘sum-of-products’. Y = A B C + A B C
Lecture 7 We can write the minterm as Since it consist of terms from rows 4 and 7 it can also be written as S A,B,C (4,7)= S (4,7). This is known as the canonical sum of the logic function and the elements within the sum make up the minterm list and mans ‘the sum of the minterms 4 and 7 with variables A,B and C’. Remember this is the ‘sum-of-products’. In the case of 3 input K map the cell numbers are Y = A B C + A B C

What are the cell numbers associated with the 4 variable K map.
C D

0000 0001 0011 0010 0100 0101 0111 0110 1100 1101 1111 1110 1000 1001 1011 1010 4 1 8 12 2 3 5 9 13 7 11 15 6 10 14

Exercise 7. 1. Look at the K map below
Exercise 7.1. Look at the K map below. Write out an canonical sum for Y? A B A B C D 1

Exercise 7.2 This system has four inputs and one outputs. The first two inputs A and B represent a 2-bit binary number in the range of 0 to 3. A second binary number (in the same range) is represented by the other two outputs, C and D. The output F is to be 1 if and only if the second number is larger than the first number. Show a truth table for F and write down the unsimplifed Boolean expression. Show F on a Karnaugh map and find a simplified expression for F.

The final aspect of K maps is the ‘don’t care’ condition.
To produce a decimal signal for the numbers 0-9 we need to know the binary equivalents.

From the truth table binary numbers 0000 to 1001 represent 0 to 9.
(This is a 4 bit weighted code and is correctly known as the 8421 BCD code – binary coded decimal). The truth table shows that possible values such as 1010 etc are possible but these would not lie in the range 0-9. These six combinations are called ‘Don’t cares’ when plotted on a Karnaugh map using an X We may allow the Xs to be 1 or 0 depending on our needs. In the example above, suppose to prevent using these 6 additional number we wish to stop when the BCD count reaches 9. The Boolean expression for this is D C B A (remember that A B = B A).

The 6 don’t cares are marked with an X which could me that they could be 0 or 1.
A B A B C D X 1 We can then loop around, 8, 4 or 2 adjacent 1s and since the Xs could be 1s we loop around them and then proceed as normally. So the simplified expression is Y = D A

An interesting question. Why do we not loop like this as well.
Answer. Firstly it does not cover a 1 and secondly it would add an extra term AB A B A B C D X 1

Exercise 7.3: Simplify the logic function given by
f= S (1, 3, 7, 8, 9, 10, 12, 13, 14, 15) How would your answer change if the function to be minimised had don’t care conditions D = (4, 5, 11).