k map doc

59
1. INTRODUCTION The Karnaugh map, also known as a Veitch diagram (KV-map or K-map for short), is a tool to facilitate the simplification of Boolean algebraic expressions. The Karnaugh map reduces the need for extensive calculations by taking advantage of human pattern-recognition and permitting the rapid identification and elimination of potential race hazards. The Karnaugh map was invented in 1952 by Edward W. Veitch. It was further developed in 1953 by Maurice Karnaugh, a telecommunications engineer at Bell Labs, to help simplify digital electronic circuits. In a Karnaugh map the Boolean variables are transferred (generally from a truth table) and ordered according to the principles of Gray code in which only one variable changes in between squares. Once the table is generated and the output possibilities are transcribed, the data is arranged into the largest even group possible and the minterm is generated though the axiom laws of Boolean algebra 1

Transcript of k map doc

Page 1: k map doc

1. INTRODUCTION

The Karnaugh map, also known as a Veitch diagram (KV-map or K-map for short), is a

tool to facilitate the simplification of Boolean algebraic expressions.

The Karnaugh map reduces the need for extensive calculations by taking advantage of

human pattern-recognition and permitting the rapid identification and elimination of potential

race hazards.

The Karnaugh map was invented in 1952 by Edward W. Veitch. It was further developed

in 1953 by Maurice Karnaugh, a telecommunications engineer at Bell Labs, to help simplify

digital electronic circuits.

In a Karnaugh map the Boolean variables are transferred (generally from a truth table)

and ordered according to the principles of Gray code in which only one variable changes in

between squares.

Once the table is generated and the output possibilities are transcribed, the data is

arranged into the largest even group possible and the minterm is generated though the axiom

laws of Boolean algebra

Why Do You Need To Know About Karnaugh Maps?

        Karnaugh Maps are used for many small design problems.  It's true that many larger

designs are done using computer implementations of different algorithms.  However designs

with a small number of variables occur frequently in interface problems and that makes learning

Karnaugh Maps worthwhile.  In addition, if you study Karnaugh Maps you will gain a great deal

of insight into digital logic circuits.

        In this section we'll examine some Karnaugh Maps for three and four variables.  As

we use them be particularly tuned in to how they are really being used to simplify Boolean

functions1

Page 2: k map doc

2. TRUTH TABLE REPRESENTATION

        A Karnaugh Map is a grid-like representation of a truth table.  It is really just

another way of presenting a truth table, but the mode of presentation gives more insight.  A

Karnaugh map has zero and one entries at different positions.  Each position in a grid

corresponds to a truth table entry.  Here's an example taken from the voting circuit presented in

the lesson on Minterms.  The truth table is shown first.  The Karnaugh Map for this truth table is

shown after the truth table.

2.1. For three variables.

A B C V

0 0 0 0

0 0 1 0

0 1 0 0

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 1

1 1 1 1

Fig: 2.1.1 truth table for three variables

2

Page 3: k map doc

Fig: 2.1.2 k-map for three variables

        Let's examine the map again.

The term on the left in the gray area of the map corresponds to:

o

The term on the right in the gray area of the map corresponds to:

o

These two terms can be combined to give

O

3

Page 4: k map doc

2.2. FOR FOUR VARIABLES:

w x y z y

0 0 0 0 0

0 0 0 1 0

0 0 1 0 0

0 0 1 1 0

0 1 0 0 0

0 1 0 1 0

0 1 1 0 1

0 1 1 1 0

1 0 0 0 1

1 0 0 1 1

1 0 1 0 1

1 0 1 1 1

1 1 0 0 1

1 1 0 1 1

1 1 1 0 1

4

Page 5: k map doc

1 1 1 1 0

Fig: 2.2.1 truth table for four variables

Fig: 2.2.2 k-map for four variables

        The beauty of the Karnaugh Map is that it has been cleverly designed so that any

two adjacent cells in the map differ by a change in one variable.  It's always a change of one

variable any time you cross a horizontal or vertical cell boundaries.

At first, it might seem that the Karnaugh Map is just another way of presenting the

information in a truth table. In one way that’s true. However, any time you have the opportunity

to use another way of looking at a problem advantages can accrue to you. In the case of the

Karnaugh Map advantage is that the Karnaugh Map is designed to present the information in a

way that allows easy groupings of terms that can be combined.

5

Page 6: k map doc

3. SIZE OF KMAP

The size of the Karnaugh map with n Boolean variables is determined by 2n. The size of

the group within a Karnaugh map with n Boolean variables and k number of terms in the

resulting Boolean expression is determined by 2nk. Common sized maps are of 2 variables

which is a 2x2 map, 3 variables which is a 2x4 map, and 4 variables which is a 4x4 map.

In a Karnaugh Map of any size, crossing a vertical or horizontal cell boundary is a change of

only one variable - no matter how many variables there are.

Each single cell that contains a 1 represents a minterm in the function, and each minterm can be

thought of as a "product" term with N variables.

To combine variables, use groups of 2, 4, 8, etc.  A group of 2 in an N-variable Karnaugh map

will give you a "product" term with N-1 variables.  A group of 4 will have N-2 variables, etc.

You will never have a group of 3, a group of 5, etc.

6

Page 7: k map doc

4. REPRESENTATION OF TERMS IN KMAP

        Notice that the order of terms isn't random.  Look across the top boundary of the

Karnaugh Map.  Terms go 00, 01, 11, and 10.  If you think binary well, you might have ordered

terms in order 00, 01, 10, 11.  That's the sequence of binary numbers for 0,1,2,3.  However, in a

Karnaugh Map terms are not arranged in numerical sequence!  That's done deliberately to ensure

that crossing each horizontal or vertical cell boundary will reflect a change of only one variable. 

In the numerical sequence, the middle two terms, 01, and 10 differ by two variables!  Anyhow,

when only one variable changes that means that you can eliminate that variable, as in the

example above for the terms in the gray area.

The Karnaugh Map is a visual technique that allows you to generate groupings of terms

that can be combined with a simple visual inspection.  The technique you use is simply to

examine the Karnaugh Map for any groups of ones that occur.  Grouping ones into the largest

groups possible and ensuring that all ones in the table have been included are the first step in

using a Karnaugh Map.

4.1. Two variables in kmap:

.

E (); K=0

E (1); K=A'B'

E (2); K=AB'

E (3); K=A'B

E (4); K=AB

7

Page 8: k map doc

E (1, 2); K=B'

E (1, 3); K=A'

E (1, 4); K=A'B' + AB

E (2, 3); K=AB' + A'B

E (2, 4); K=A

E (3, 4); K=B

E (1, 2, 3); K=A' + B'

E (1, 2, 4); K=A + B'

E (1, 3, 4); K=A' + B

E (2, 3, 4); K=A + B

E (1, 2, 3, 4); K=1

4.2. Three variables in k-map:

Fig: 4.2.1 k-map for three variables

8

Page 9: k map doc

        Let's examine the map again.

The term on the left in the gray area of the map corresponds to:

o

The term on the right in the gray area of the map corresponds to:

o

These two terms can be combined to give

O

4.3. Four variables in k map:

No w x y z F (w, x, y, z)

0 0 0 0 0 0

1 0 0 0 1 0

2 0 0 1 0 0

3 0 0 1 1 0

4 0 1 0 0 0

5 0 1 0 1 0

6 0 1 1 0 1

7 0 1 1 1 0

8 1 0 0 0 1

9 1 0 0 1 1

10 1 0 1 0 1

11 1 0 1 1 1

12 1 1 0 0 1

13 1 1 0 1 1

14 1 1 1 0 1

15 1 1 1 1 0

9

Page 10: k map doc

Fig: 4.3.1 k-map for four variables

There are 16 cells in the map.  Anytime you have N variables, you will have 2N possible

combinations, and 2N places in a truth table or Karnaugh Map.

Imagine moving around in the Karnaugh Map.  Every time you cross a horizontal or

vertical boundary one - and only one - variable changes value.

The two pairs of variables - WX and YZ - both change in the same pattern.

Note that Y and Z are 00 and 01 at the top of the two columns in which you find the two

1s.  The variable, Z, changes from a 0 to a 1 as you move from the left cell to the right cell.  

Consequently, these two 1s are not dependent upon the value of Z, and Z will not appear in the

product term that results when we combine the 1s in this group of 2.  Conversely, W, X and Y

will be in the product term.  Notice that in the row in which the 1s appear, W = 0 and X = 1.  

Also, in the two columns in which the 1s appear we have Y = 0.  That means that the term

represented by these two cells is:

10

Page 11: k map doc

5. SOLUTION

A Karnaugh map may contain any number of boolean variables, but is most often used

when there are fewer than six variables. Each variable contributes two possibilities: the initial

value, and its inverse; it therefore organizes all possibilities of the system. The variables are

arranged in Gray code in which only one possibility of one variable changes between two

adjacent grid boxes.

Once the variables have been defined, the output possibilities are transcribed according to

the grid location provided by the variables. Thus for every possibility of a Boolean input or

variable the output possibility is defined.

When the Karnaugh map has been completed, to derive a minimized function the "1s" or

desired outputs are grouped into the largest possible rectangular groups in which the number of

grids boxes (output possibilities) in the groups must be equal to a power of 2.

For example, the groups may be 4 boxes in a line, 2 boxes high by 4 boxes long, 2 boxes

by 2 boxes, and so on. "Don't care(s)" possibilities (generally represented by a "X") are grouped

only if the group created is larger than the group with "Don't care" is excluded.

The boxes can be used more than once only if it generates the least number of groups. All

"1s" or desired output possibilities must be contained within a grouping.

The groups generated are then converted to boolean expression by: locating and

transcribing the variable possibility attributed to the box, and by the axiom laws of boolean

algebra.

In which if the (initial) variable possibility and its inverse are contained within the same

group the variable term is removed. Each group provides a "product" to create a "sum-of-

products" in the boolean expression.

11

Page 12: k map doc

To determine the inverse of the Karnaugh map, the "0s" are grouped instead of the "1s".

The two expressions are non-complementary.

Each square in a Karnaugh map corresponds to a Minterm (And maxterm).

The picture to the right shows the location of each Minterm on the map. A Venn diagram

of four sets — labeled A, B, C, and D — is shown to the right that corresponds to the 4-variable

K-map of minterms just above it:

Variable A of the K-map corresponds set A in the Venn diagram; etc.

Minterm m0 of the K-map corresponds to area 0 in the Venn diagram; etc.

Minterm m9 is (or 1001) in the K-map corresponds only to where sets A & D intersect in

the Venn diagram.

Thus, a specific Minterm identifies a unique intersection of all four sets.

The Venn diagram can include an infinite number of sets and still correspond to the

respective Karnaugh maps. With increasing number of sets and variables, both Venn diagram

and Karnaugh map increase in complexity to draw and manage.

The grid is toroidally connected, so the rectangular groups can wrap around edges. For

example m9 can be grouped with m1; just as m0, m9, m3, and m10 can be combined into a four

by four group.

Karnaugh maps are used to facilitate the simplification of Boolean algebra functions. The

following is an unsimplified Boolean algebra functions with Boolean variables A, B, C, D, and

their inverses. They can be represented in two different functions:

f(A,B,C,D) = F(6,8,9,10,11,12,13,14).

12

Page 13: k map doc

K-map showing minterms and boxes covering the desired minterms. The brown region is

an overlapping of the red (square) and green regions. The input variables can be combined in 16

different ways, so the Karnaugh map has 16 positions and therefore is arranged in a 4 x 4 grid.

The binary digits in the map represent the function's output for any given combination of

inputs. So 0 is written in the upper leftmost corner of the map because f = 0 when A = 0, B = 0,

C = 0, D = 0. Similarly we mark the bottom right corner as 1 because A = 1, B = 0, C = 1, D = 0

gives f = 1. Note that the values are ordered in a Gray code, so that precisely one variable

changes between any pair of adjacent cells.

After the Karnaugh map has been constructed the next task is to find the minimal terms to

use in the final expression. These terms are found by encircling groups of 1s in the map. The

groups must be rectangular and must have an area that is a power of two (i.e. 1, 2, 4, 8…). The

rectangles should be as large as possible without containing any 0s. The optimal groups in this

map are marked by the green, red and blue lines.

The grid is toroidally connected, which means that the rectangular groups can wrap

around edges, so is a valid term, although not part of the minimal set — this covers minterms 8,

10, 12, & 14.

Perhaps the hardest-to-visualize wrap-around term is which covers the four corners —

this covers minterms 0, 2, 8, 10.

5.1. Don't cares

The minterm 15 is dropped and replaced as a don't care, this removes the green term

completely but restricts the blue inverse term Karnaugh maps also allow easy minimizations of

functions whose truth tables include "don't care" conditions (that is sets of inputs for which the

13

Page 14: k map doc

designer doesn't care what the output is) because "don't care" conditions can be included in a ring

to make it larger. They are usually indicated on the map with a dash or X.

The example to the right is the same above example but with minterm 15 dropped and

replaced as a don't care. This allows the red term to expand all the way down and, thus, removes

the green term completely.

This yields the new minimum equation:

Note that the first term is just a not. In this case, the don't care has dropped a term (the

green); simplified another (the red); and removed the race hazard (the yellow as shown in a

following section).

Also, since the inverse case no longer has to cover minterm 15, minterm 7 can be covered

with rather than with similar gains.

5.2. Race hazards

Above k-map with the term added to avoid race hazards Karnaugh maps are useful for

detecting and eliminating race hazards. They are very easy to spot using a Karnaugh map,

because a race condition may exist when moving between any pair of adjacent, but disjointed,

regions circled on the map.

In the above example, a potential race condition exists when C is 1 and D is 0, A is 1, and

B changes from 1 to 0 (moving from the blue state to the green state). For this case, the output is

defined to remain unchanged at 1, but because this transition is not covered by a specific term in

the equation, a potential for a glitch (a momentary transition of the output to 0) exists.

A harder possible glitch to spot is when D is 0 and A and B are both 1, with C changing

from 1 to 0 (moving from the blue state to the red state). In this case the glitch wraps around

from the top of the map to the bottom.

14

Page 15: k map doc

Whether these glitches do occur depends on the physical nature of the implementation,

and whether we need to worry about it depends on the application.

In this case, an additional term of would eliminate the potential race hazard, bridging

between the green and blue output states or blue and red output states: this is shown as the

yellow region.

The term is redundant in terms of the static logic of the system, but such redundant, or

consensus terms, are often needed to assure race-free dynamic performance.

Similarly, an additional term of must be added to the inverse to eliminate another

potential race hazard. Applying De Morgan's laws creates another product of sums expression for

F, but with a new factor of.

5.3. Reduction of Boolean expressions

The following four variable Karnaugh maps illustrate reduction of Boolean expressions

too tedious for Boolean algebra. Reductions could be done with Boolean algebra. However, the

Karnaugh map is faster and easier, especially if there are many logic reductions to do.

Fig: 5.3.1 k-map for four variables

15

Page 16: k map doc

The above Boolean expression has seven product terms. They are mapped top to bottom

and left to right on the K-map above. For example, the first P-term A'B'CD is first row 3rd cell,

corresponding to map location A=0, B=0, C=1, D=1. The other product terms are placed in a

similar manner. Encircling the largest groups possible, two groups of four are shown above. The

dashed horizontal group corresponds to the simplified product term AB. The vertical group

corresponds to Boolean CD. Since there are two groups, there will be two product terms in the

Sum-Of-Products result of Out=AB+CD.

Fold up the corners of the map below like it is a napkin to make the four cells physically

adjacent.

Fig: 5.3.2 k-map for four variables

The four cells above are a group of four because they all have the Boolean variables B'

and D' in common. In other words, B=0 for the four cells, and D=0 for the four cells. The other

variables (A, B) are 0 in some cases, 1 in other cases with respect to the four corner cells. Thus,

these variables (A, B) are not involved with this group of four. This single group comes out of

the map as one product term for the simplified result: Out=B'C'

16

Page 17: k map doc

For the K-map below, roll the top and bottom edges into a cylinder forming eight

adjacent cells.

The above group of eight has one Boolean variable in common: B=0. Therefore, the one

group of eight is covered by one p-term: B'. The original eight term Boolean expression

simplifies to Out=B'

The Boolean expression below has nine p-terms, three of which have three Booleans

instead of four. The difference is that while four Boolean variable product terms cover one cell,

the three Boolean p-terms cover a pair of cells each.

Fig: 5.3.3 k-map for four variables

The six product terms of four Boolean variables map in the usual manner above as single

cells. The three Boolean variable terms (three each) map as cell pairs, which is shown above.

Note that we are mapping p-terms into the K-map, not pulling them out at this point.

For the simplification, we form two groups of eight. Cells in the corners are shared with

both groups. This is fine. In fact, this leads to a better solution than forming a group of eight and

a group of four without sharing any cells. Final Solution is Out=B'+D'

17

Page 18: k map doc

Below we map the UN simplified Boolean expression to the Karnaugh

map.

Fig: 5.3.4 k-map for four variables

Above, three of the cells form into a group of two cells. A fourth cell cannot be combined

with anything, which often happens in "real world" problems. In this case, the Boolean p-term

ABCD is unchanged in the simplification process. Result: Out= B'C'D'+A'B'D'+ABCD

An often time there is more than one minimum cost solution to a simplification problem.

Such is the case illustrated below.

18

Page 19: k map doc

Fig: 5.3.5 k-map for four variables

Both results above have four product terms of three Boolean variable each. Both are

equally valid minimal cost solutions. The difference in the final solution is due to how the cells

are grouped as shown above. A minimal cost solution is a valid logic design with the minimum

number of gates with the minimum number of inputs.

Below we map the unsimplified Boolean equation as usual and form a group of four as a

first simplification step. It may not be obvious how to pick up the remaining cells.

19

Page 20: k map doc

Fig: 5.3.6 k-map for four variables

Pick up three more cells in a group of four, center above. There are still two cells

remaining. The minimal cost method to pick up those is to group them with neighboring cells as

groups of four as at above right.

On a cautionary note, do not attempt to form groups of three. Groupings must be powers

of 2 that is, 1, 2, 4, 8...

Below we have another example of two possible minimal cost solutions. Start by forming

a couple of groups of four after mapping the cells.

Fig: 5.3.7 k-map for four variables

The two solutions depend on whether the single remaining cell is grouped with the first

or the second group of four as a group of two cells. That cell either comes out as either ABC' or

ABD, your choice. Either way, this cell is covered by either Boolean product term. Final results

are shown above.

20

Page 21: k map doc

Below we have an example of a simplification using the Karnaugh map at left or Boolean

algebra at right. Plot C' on the map as the area of all cells covered by address C=0, the 8-cells on

the left of the map. Then, plot the single ABCD cell. That single cell forms a group of 2-cell as

shown, which simplifies to P-term ABD, for an end result of Out = C' + ABD.

Fig: 5.3.8 k-map for four variables

This (above) is a rare example of a four variable problem that can be reduced with

Boolean algebra without a lot of work, assuming that you remember the theorems.

21

Page 22: k map doc

6. MINIMIZATION OF BOOLEAN FUNCTIONS

6.1. What is minimization?

In mathematics expressions are simplified for a number of reasons, for instance

simpler expression are easier to understand and easier to write down, they are also less prone to

error in interpretation but, most importantly, simplified expressions are usually more efficient

and effective when implemented in practice.

A Boolean expression is composed of variables and terms. The simplification of Boolean

expressions can lead to more effective computer programs, algorithms and circuits.

The minimization output may be in the form of sum of product(sop) or product of

sum(sop).

6.2. Methods for minimization

Minimization can be achieved by number of methods, they are:

l. Algebraic Manipulation of Boolean Expressions

ll. Karnaugh Maps

III. Tabular Method of Minimization

l. Algebraic Manipulation of Boolean Expressions.

22

Page 23: k map doc

This is an approach where you can transform one boolean expression into an equivalent

expression by applying Boolean Theorems.

Minimizing terms and expressions can be important because electrical circuits consist of

individual components that are implemented for each term or literal for a given expression. This

allows designers to make use of fewer components, thus reducing the cost of a particular system.

It should be noted that there are no fixed rules that can be used to minimize a given

expression. It is left to an individual’s ability to apply Boolean Theorems in order to minimize a

function.

Numerical Assignment of Karnaugh Map Cells

Each cell of a Karnaugh map has a unique binary value. With reference to the Forms and

Definitions of Boolean Expressions it is obvious that each value can be converted to the

equivalent decimal value. This can be useful when entering functions expressed in numerical

form, in the map.

So far we can see that applying Boolean algebra can be awkward in order to simplify

expressions. Apart from being laborious (and requiring the remembering all the laws) the method

can lead to solutions which, though they appear minimal, are not.

The Karnaugh map provides a simple and straight-forward method of minimizing

boolean expressions. With the Karnaugh map Boolean expressions having up to four and even

six variables can be simplified.

ll. Karnaugh Map

A Karnaugh map provides a pictorial method of grouping together expressions with

common factors and therefore eliminating unwanted variables. The Karnaugh map can also be

described as a special arrangement of a truth table.

23

Page 24: k map doc

The diagram below illustrates the correspondence between the Karnaugh map and the

truth table for the general case of a two variable problem.

The values inside the squares are copied from the output column of the truth table,

therefore there is one square in the map for every row in the truth table.

Around the edge of the Karnaugh map are the values of the two input variable. A is along

the top and B is down the left hand side. The diagram below explains this:

The values around the edge of the map can be thought of as coordinates. So as an

example, the square on the top right hand corner of the map in the above diagram has coordinates

A=1 and B=0. This square corresponds to the row in the truth table where A=1 and B=0 and

F=1. Note that the value in the F column represents a particular function to which the Karnaugh

map corresponds.

By using the rules of simplification and ringing of adjacent cells in order to make as

many variables redundant, the minimized result obtained is B.

By using the rules of simplification and ringing of adjacent cells in order to make as

many variables redundant, the minimized result obtained is B + AC--

lll. Tabular Method of Minimization.

In order to understand the tabular method of minimization, it is best you understand the

numerical assignment of Karnaugh map cells and the incompletely specified functions also

known as the can’t happen conditions. This is because the tabular method is based on these

principles.

24

Page 25: k map doc

The tabular method which is also known as the Quine-McCluskey method is particularly

useful when minimizing functions having a large number of variables, e.g. the six-variable

functions. Computer programs have been developed employing this algorithm.

The method reduces a function in standard sum of products form to a set of prime

implicants from which as many variables are eliminated as possible. These prime implicants are

then examined to see if some are redundant.

The tabular method makes repeated use of the law A +Â = 1. Note that Binary notation is

used for the function, although decimal notation is also used for the functions. As usual a

variable in true form is denoted by 1, in inverted form by 0, and the absence of a variable by a

dash (-).

Rules of Tabular Method

Consider a function of three variables f (A, B, C):

Consider the function:

Listing the two minterms shows they can be combined

Now consider the following:

Note that these variables cannot be combined

This is because the FIRST RULE of the Tabular method for two terms to combine, and

thus eliminate one variable, is that they must differ in only one digit position.

Bear in mind that when two terms are combined, one of the combined terms has one digit

more at logic 1 than the other combined term. This indicates that the number of 1's in a term is

significant and is referred to as its index.25

Page 26: k map doc

For example: f(A, B, C, D)

0000...................Index 0

0010, 1000.............Index 1

1010, 0011, 1001.......Index 2

1110, 1011.............Index 3

1111...................Index 4

The necessary condition for combining two terms is that the indices of the two terms

must differ by one logic variable which must also be the same.

The Quine–McCluskey algorithm (or the method of prime implicants) is a method used

for minimization of boolean functions which was developed by W.V. Quine and Edward J.

McCluskey. It is functionally identical to Karnaugh mapping, but the tabular form makes it more

efficient for use in computer algorithms, and it also gives a deterministic way to check that the

minimal form of a Boolean function has been reached. It is sometimes referred to as the

tabulation method.

The method involves two steps:

Use prime implicants in a prime implicant chart to find the essential prime implicants of

the function, as well as other prime implicants that are necessary to cover the function.

Contents

Step 1: finding prime implicants26

Page 27: k map doc

Step 2: prime implicant chart

i. Step 1: finding prime implicants

Minimizing an arbitrary function:

A B C D f

m0 0 0 0 0 0

m1 0 0 1 0 0

m2 0 0 1 0 0

m3 0 0 1 1 0

m4 0 1 0 0 1

m5 0 1 0 1 0

m6 0 1 1 0 0

m7 0 1 1 1 0

m8 1 0 0 0 1

m9 1 0 0 1 x

m10 1 0 1 0 1

m11 1 0 1 1 1

m12 1 1 0 0 1

m13 1 1 0 1 0

m14 1 1 1 0 x

m15 1 1 1 1 1

One can easily form the canonical sum of products expression from this table, simply by

summing the minterms (leaving out don't-care terms) where the function evaluates to one:

F A, B, C, D = A'BC'D' + AB'C'D' + AB'CD' + AB'CD + ABC'D' + ABCD

27

Page 28: k map doc

Of course, that's certainly not minimal. So to optimize, all minterms that evaluate to one

are first placed in a minterm table. Don't-care terms are also added into this table, so they can be

combined with minterms:

Number of 1s Minterm Binary Representation

--------------------------------------------

1 m4 0100

m8 1000

--------------------------------------------

2 m9 1001

m10 1010

m12 1100

--------------------------------------------

3 m11 1011

m14 1110

--------------------------------------------

4 m15 1111

At this point, one can start combining minterms with other minterms. If two terms vary

by only a single digit changing, that digit can be replaced with a dash indicating that the digit

doesn't matter. Terms that can't be combined any more are marked with a "*". When going from

Size 2 to Size 4, treat '-' as a third bit value. Ex: -110 and -100 or -11- can be combined, but not -

110 and 011-. (Trick: Match up the '-' first.)

Number of 1s Minterm 0-Cube | Size 2 Implicants | Size 4

Implicants------------------------------|-------------------|----------------------

1 m4 0100 | m(4,12) -100* | m(8,9,10,11) 10--*

m8 1000 | m(8,9) 100- | m(8,10,12,14) 1--0*

------------------------------| m(8,10) 10-0 |----------------------

2 m9 1001 | m(8,12) 1-00 | m(10,11,14,15) 1-1-*28

Page 29: k map doc

m10 1010 |-------------------|

m12 1100 | m(9,11) 10-1 |

------------------------------| m(10,11) 101- |

3 m11 1011 | m(10,14) 1-10 |

m14 1110 | m(12,14) 11-0 |

------------------------------|-------------------|

4 m15 1111 | m(11,15) 1-11 |

| m(14,15) 111- |

ii. Step 2: prime implicant chart

None of the terms can be combined any further than this, so at this point we construct an

essential prime implicant table. Along the side goes the prime implicants that have just been

generated, and along the top go the minterms specified earlier.

The don't care terms are not placed on top - they are omitted from this section because

they are not necessary inputs.

4 8 10 11 12 15

M (4, 12)* X X -100

M (8, 9, 10, 11) X X X 10--

M (8, 10, 12, 14) X X X 1--0

M (10, 11, 14, 15)* X X X 1-1-

Here, each of the essential prime implicants has been starred - the second prime implicant

can be 'covered' by the third and fourth, and the third prime implicant can be 'covered' by the

second and first, and is thus neither an essential. If a prime implicant is essential then, as would

be expected, it is necessary to include it in the minimized Boolean equation.

29

Page 30: k map doc

In some cases, the essential prime implicants do not cover all minterms, in which case

additional procedures for chart reduction can be employed.

The simplest "additional procedure" is trial and error, but a more systematic way is

Patrick’s Method.

7. MIN TERM

A Minterm is a Boolean expression resulting in 1 for the output of a single cell, and 0s for

all other cells in a Karnaugh map, or truth table. If a minterm has a single 1 and the remaining

cells as 0s, it would appear to cover a minimum area of 1s. The illustration above left shows the

minterm ABC, a single product term, as a single 1 in a map that is otherwise 0s. We have not

shown the 0s in our Karnaugh maps up to this point, as it is customary to omit them unless

specifically needed. Another minterm A'BC' is shown above right. The point to review is that the

address of the cell corresponds directly to the minterm being mapped. That is, the cell 111

corresponds to the minterm ABC above left. Above right we see that the minterm A'BC'

corresponds directly to the cell 010. A Boolean expression or map may have multiple minterms.

Referring to the above figure, Lets summarize the procedure for placing a minterm in a

K-map:

Identify the minterm (product term) term to be mapped.

Write the corresponding binary numeric value.

Use binary value as an address to place a 1 in the K-map

Repeat steps for other minterms (P-terms within a Sum-Of-Products).

30

Page 31: k map doc

Fig:7.1 three variable k-map finding min term

A Boolean expression will more often than not consist of multiple minterms

corresponding to multiple cells in a Karnaugh map as shown above. The multiple minterms in

this map are the individual minterms which we examined in the previous figure above. The point

we review for reference is that the 1s come out of the K-map as a binary cell address which

converts directly to one or more product terms. By directly we mean that a 0 corresponds to a

complemented variable, and a 1 corresponds to a true variable. Example: 010 converts directly to

A'BC'. There was no reduction in this example. Though, we do have a Sum-Of-Products result

from the minterms.

Referring to the above figure, Lets summarize the procedure for writing the Sum-Of-

Products reduced Boolean equation from a K-map:

Form largest groups of 1s possible covering all minterms. Groups must be a power of 2.

Write binary numeric value for groups.

Convert binary value to a product term.

Repeat steps for other groups. Each group yields p-terms within a Sum-Of-Products.

Nothing new so far, a formal procedure has been written down for dealing with minterms.

This serves as a pattern for dealing with maxterms.

Next we attack the Boolean function which is 0 for a single cell and 1s for all others.

31

Page 32: k map doc

Fig:7.2 three variable k-map finding min term

8. MAX TERM

A maxterm is a Boolean expression resulting in a 0 for the output of a single cell

expression, and 1s for all other cells in the Karnaugh map, or truth table. The illustration above

left shows the maxterm (A+B+C), a single sum term, as a single 0 in a map that is otherwise 1s.

If a maxterm has a single 0 and the remaining cells as 1s, it would appear to cover a maximum

area of 1s.

There are some differences now that we are dealing with something new, maxterms. The

maxterm is a 0, not a 1 in the Karnaugh map. A maxterm is a sum term, (A+B+C) in our

example, not a product term.

It also looks strange that (A+B+C) is mapped into the cell 000. For the equation Out=

(A+B+C) =0, all three variables (A, B, C) must individually be equal to 0. Only (0+0+0) =0 will

equal 0. Thus we place our sole 0 for minterm (A+B+C) in cell A, B, C=000 in the K-map,

where the inputs are all0. This is the only case which will give us a 0 for our maxterm. All other

cells contain 1s because any input values other than (0, 0, 0) for (A+B+C) yields 1s upon

evaluation.

32

Page 33: k map doc

Referring to the above figure, the procedure for placing a maxterm in the K-map is:

Identify the Sum term to be mapped.

Write corresponding binary numeric value.

Form the complement

Use the complement as an address to place a 0 in the K-map

Repeat for other maxterms (Sum terms within Product-of-Sums expression).

Fig:8.1 three variable k-map finding max term

Another maxterm A'+B'+C' is shown above. Numeric 000 corresponds to A'+B'+C'. The

complement is 111. Place a 0 for maxterm (A'+B'+C') in this cell (1, 1, 1) of the K-map as shown

above.

Why should (A'+B'+C') cause a 0 to be in cell 111? When A'+B'+C' is (1'+1'+1'), all 1s

in, which is (0+0+0) after taking complements, we have the only condition that will give us a 0.

All the 1s are complemented to all 0s, which is 0 when ORed.

33

Page 34: k map doc

Fig:8.2 three variable k-map finding max term

A Boolean Product-Of-Sums expression or map may have multiple maxterm as shown

above. Maxterm (A+B+C) yields numeric 111 which complements to 000, placing a 0 in cell (0,

0, 0). Maxterm (A+B+C') yields numeric 110 which complements to 001, placing a 0 in cell (0,

0, 1).

Now that we have the k-map setup, what we are really interested in is showing how to

write a Product-Of-Sums reduction. Form the 0s into groups. That would be a group of two

below. Write the binary value corresponding to the sum-term which is (0, 0, X). Both A and B

are 0 for the group. But, C is both 0 and 1 so we write an X as a place holder for C. Form the

complement (1, 1, X). Write the Sum-term (A+B) discarding the C and the X which held its'

place. In general, expect to have more sum-terms multiplied together in the Product-Of-Sums

result. Though, we have a simple example here.

34

Page 35: k map doc

Fig:8.3 three variable k-map finding max term

Let's summarize the procedure for writing the Product-Of-Sums Boolean reduction for a

K-map:

Form largest groups of 0s possible, covering all maxterms. Groups must be a power of 2.

Write binary numeric value for group.

Complement binary numeric value for group.

Convert complement value to a sum-term.

Repeat steps for other groups. Each group yields a sum-term within a Product-Of-Sums

result.

9. FEATURES

A. Karnaugh:

1. This method is more elegant and powerful.

2. This method takes advantage of the human pattern recognition capabilities.

B. Tabulation method:

1. It reduces the number of comparisons.

2. This method is fully algorithmic and programmable.

3. This method is used for more number of variables.

35

Page 36: k map doc

10. PROGRAM#include<iostream.h>#include<conio.h>#include<string.h>#include<graphics.h>#include<dos.h>#include<math.h>void main(){ // clrscr(); int c=1,c1=4,c2=1,c3=1,r[2000][10],c4=1,c5=1,p[2000][10],q[2000][10],o[2000][10],t[2000][10],s[2000][10],w[2000][10],i,l=1,j,k,m,u[2000][10],a[2000][10],v,e=0,g=1,f=1,h=0,b[2000][10],z[2000][10],y[6000][5],x[2000][10]; cout<<"Enter 0 for not selecting and 1 for selecting\n"; for(i=0;i<=15;i++)

{cout<<"Enter the value for "<<i<<":";cin>>v;if(v==1) { a[c][5]=i; m=i; while(c1!=0)

{a[c][c1]=m%2;m=m/2;c1--;

36

Page 37: k map doc

} c++; c1=4;}

} for(i=1;i<c;i++)

{for(j=1;j<c;j++) { for(k=1;k<=4;k++)

{if(a[i][k]+a[j][k]==1)e++;

} if(e==1)

{for(k=1;k<=4;k++){ if(a[i][k]+a[j][k]!=1) b[f][g]=a[i][k]; else b[f][g]=3; g++;}b[f][5]=a[i][5];b[f][6]=a[j][5];g=1;f++;h++;

} e=0;}if(h==0){ for(k=1;k<=4;k++) x[c2][k]=a[i][k]; c2++;}h=0;

} c=0; for(i=1;i<f;i++)

{for(j=1;j<i;j++)

{ for(k=1;k<=4;k++)

37

Page 38: k map doc

{if(b[i][k]==b[j][k])c++;

} if(c!=4) e++; c=0;}if(e==i-1){ for(k=1;k<=6;k++) u[h+1][k]=b[i][k]; h++;}e=0;

} for(i=1;i<=h;i++)

{if(u[i][7]!=4){ for(j=1;j<=h;j++)

{if(u[j][7]!=4) { if((u[i][6]==u[j][5])||(u[i][6]==u[j][5])||(u[i][5]==u[j][5])||(u[i][5]==u[j][6]))

{for(k=1;k<=h;k++) { if(u[j][6]==u[k][5]||u[j][6]==u[k][6]||u[j][5]==u[k][5]||u[j][5]==u[k]

[6]){for(e=1;e<=h;e++) { if(i!=j&&i!=k&&i!=e&&j!=k&&j!=e&&k!=e)

{if(u[k][6]!=u[e][5]&&u[k][6]!=u[e][6]&&u[k][6]!=u[e]

[6]&&u[k][6]!=u[e][5])u[j][7]=4;

}}

}}

}}

}}

38

Page 39: k map doc

} cout<<endl; f=h+1; e=0;h=0;g=1;l=1;c=1; for(i=1;i<f;i++)

{for(j=1;j<f;j++) { for(k=1;k<=4;k++)

{if(u[i][k]+u[j][k]==1)e++;if((u[i][k]+u[j][k]==3)||(u[i][k]+u[j][k]==4))e=2;

} if(e==1) {

for(k=1;k<=4;k++){ if(u[i][k]+u[j][k]!=1&&u[i][k]+u[j][k]!=6) z[l][g]=u[i][k]; else z[l][g]=3; g++;}g=1;l++;h++;

} e=0;}if(h==0) { for(k=1;k<=7;k++) w[c3][k]=u[i][k]; c3++;}h=0;

} c=0; for(i=1;i<l;i++)

{for(j=1;j<i;j++) { for(k=1;k<=4;k++)

{39

Page 40: k map doc

if(z[i][k]==z[j][k])c++;

} if(c!=4) e++; c=0;}if(e==i-1) { for(k=1;k<=4;k++) t[h+1][k]=z[i][k]; h++;}e=0;

} l=h+1; e=0;h=0;g=1;m=1;c=1;c1=4; for(i=1;i<l;i++)

{for(j=i+1;j<l;j++) { for(k=1;k<=4;k++)

{if(t[i][k]+t[j][k]==1)e++;if(t[i][k]+t[j][k]==3||t[i][k]+t[j][k]==4)e=2;

} if(e==1)

{for(k=1;k<=4;k++) { if(t[i][k]+t[j][k]!=1&&t[i][k]+t[j][k]!=6) y[m][g]=t[i][k]; else y[m][g]=3; g++;}g=1;m++;h++;

} e=0;}if(h==0) {

40

Page 41: k map doc

for(k=1;k<=4;k++) r[c4][k]=t[i][k]; c4++;}h=0;

} c=0;h=0; for(i=1;i<m;i++)

{for(j=1;j<i;j++) { for(k=1;k<=4;k++)

{if(y[i][k]==y[j][k])c++;

} if(c!=4) e++; c=0;}if(e==i-1) { for(k=1;k<=4;k++) s[h+1][k]=y[i][k]; h++;}e=0;

} f=h+1; e=0;h=0;g=1;l=1;c=1; for(i=1;i<f;i++)

{for(j=1;j<f;j++) { for(k=1;k<=4;k++)

{if(s[i][k]+s[j][k]==1)e++;if((s[i][k]+s[j][k]==3)||(s[i][k]+s[j][k]==4))e=2;

} if(e==1)

{for(k=1;k<=4;k++) { if(s[i][k]+s[j][k]!=1&&s[i][k]+s[j][k]!=6)

41

Page 42: k map doc

q[l][g]=s[i][k]; else q[l][g]=3; g++;}g=1;l++;h++;

} e=0;}if(h==0) { for(k=1;k<=4;k++) p[c5][k]=s[i][k]; c5++; }h=0;

} c=0; for(i=1;i<l;i++)

{for(j=1;j<i;j++) { for(k=1;k<=4;k++)

{if(q[i][k]==q[j][k])c++;

} if(c!=4) e++; c=0;}if(e==i-1) { for(k=1;k<=4;k++) o[h+1][k]=q[i][k]; h++;}e=0;

} for(i=1;i<=h;i++)

{cout<<1;

} cout<<endl;

42

Page 43: k map doc

for(i=1;i<c2;i++){if(x[i][1]==0)cout<<"A'";if(x[i][1]==1)cout<<"A";if(x[i][2]==0)cout<<"B'";if(x[i][2]==1)cout<<"B";if(x[i][3]==0)cout<<"C'";if(x[i][3]==1)cout<<"C";if(x[i][4]==0)cout<<"D'";if(x[i][4]==1)cout<<"D";cout<<"+";

} c=0; for(i=1;i<c3;i++)

{if(w[i][7]!=4) { if(w[i][1]==0) cout<<"A'"; if(w[i][1]==1) cout<<"A"; if(w[i][2]==0) cout<<"B'"; if(w[i][2]==1) cout<<"B"; if(w[i][3]==0) cout<<"C'"; if(w[i][3]==1) cout<<"C"; if(w[i][4]==0) cout<<"D'"; if(w[i][4]==1) cout<<"D"; cout<<"+";}

} cout<<endl; c=0;

43

Page 44: k map doc

for(i=1;i<c4;i++){for(j=1;j<=h;j++) { if(((o[j][1]-r[i][1])==2||(o[j][1]-r[i][1])==3||(o[j][1]-r[i][1])==0)&&((o[j][2]-r[i]

[2])==2||(o[j][2]-r[i][2])==3||(o[j][2]-r[i][2])==0)&&((o[j][3]-r[i][3])==2||(o[j][3]-r[i][3])==0||(o[j][3]-r[i][3])==3)&&((o[j][4]-r[i][4])==2||(o[j][4]-r[i][4])==0||(o[j][4]-r[i][4])==3))

c++;}for(j=1;j<c5;j++) { if(((p[j][1]-r[i][1])==2||(p[j][1]-r[i][1])==3||(p[j][1]-r[i][1])==0)&&((p[j][2]-r[i]

[2])==2||(p[j][2]-r[i][2])==3||(p[j][2]-r[i][2])==0)&&((p[j][3]-r[i][3])==2||(p[j][3]-r[i][3])==0||(p[j][3]-r[i][3])==3)&&((p[j][4]-r[i][4])==2||(p[j][4]-r[i][4])==0||(p[j][4]-r[i][4])==3))

c++;}if(c==0) { if(r[i][1]==0) cout<<"A'"; if(r[i][1]==1) cout<<"A"; if(r[i][2]==0) cout<<"B'"; if(r[i][2]==1) cout<<"B"; if(r[i][3]==0) cout<<"C'"; if(r[i][3]==1) cout<<"C"; if(r[i][4]==0) cout<<"D'"; if(r[i][4]==1) cout<<"D"; cout<<"+";}c=0;

} cout<<endl; for(i=1;i<c5;i++)

{if(p[i][1]==0)cout<<"A'";if(p[i][1]==1)cout<<"A";if(p[i][2]==0)

44

Page 45: k map doc

cout<<"B'";if(p[i][2]==1)cout<<"B";if(p[i][3]==0)cout<<"C'";if(p[i][3]==1)cout<<"C";if(p[i][4]==0)cout<<"D'";if(p[i][4]==1)cout<<"D";cout<<"+";

} getch ();}

10. CONCLUSION

The project has been completed by implementation and analyzation of code.

The Karnaugh map has been designed in ‘c++’ language.

The process has been verified by using various inputs.

45