0% found this document useful (0 votes)
706 views78 pages

Major Project

This document provides information about Karnaugh maps (K-maps), including: 1) K-maps are a pictorial method to minimize Boolean expressions without using Boolean algebra. They represent truth tables as matrices and allow grouping of variables to simplify expressions. 2) The program described implements K-map simplification for expressions with 3-6 variables. It accepts minterms as input, draws the K-map, simplifies the expression, displays the logic circuit, and generates the truth table. 3) The program has functions for defining the K-map, grouping variables, drawing the map, simplifying the expression, drawing the logic circuit, and generating the truth table. It prompts the user for

Uploaded by

Manas Mehrotra
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
706 views78 pages

Major Project

This document provides information about Karnaugh maps (K-maps), including: 1) K-maps are a pictorial method to minimize Boolean expressions without using Boolean algebra. They represent truth tables as matrices and allow grouping of variables to simplify expressions. 2) The program described implements K-map simplification for expressions with 3-6 variables. It accepts minterms as input, draws the K-map, simplifies the expression, displays the logic circuit, and generates the truth table. 3) The program has functions for defining the K-map, grouping variables, drawing the map, simplifying the expression, drawing the logic circuit, and generating the truth table. It prompts the user for

Uploaded by

Manas Mehrotra
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 78

KARNAUGH MAP

1. INTRODUCTION

A karnaugh map (K- MAP) is a pictorial method to minimize Boolean expression


without having to use Boolean algebra theorems and equation manipulations. It is
basically a matrix consisting o rows and columns that represent the output values of the
Boolean functions. K-MAP simplification is a technique for designing a logical circuit a
special arrangement of a truth table.

However, k-maps are not useful for solving logical expressions having more than six
input variables. After six variables k-map becomes very complex.

Here we present a program for K-map simplification. We can obtain the sum-of-products
(SOP) or the product-of-sum (POS) forms of logical expressions using k-map. A
minterm is a Boolean expression resulting in ‘1’ for the output of a single cell and ‘0’s
for all the other cells in a k-map. A Boolean expression or a k-map may have multiple
minterm.

This program is written in ‘C’ language and compiled using ‘Turbo C++’ IDE. It accepts
for variable inputs (functions of minterm), then it plots k-map and gives a logical
expression obtained after solving k-map in the SOP form. The program then displays the
logical circuit (realization of the expression) consisting of AND & OR gates.

The initial screen of the program output shows animated text like title of the program,
and other relevant information. We have used ‘ctime’ function available in ‘time.h’
header file to display the current date and time of the system.

After the initial screen the program prompts you to enter minterms in decimal number.
Enter minterms separated by spaces and close the parenthesis for the input function.

After we enter the minterms and press ‘Enter’ key, k-map is drawn by the program using
the line() function. Next, program checks the inputs, grouping the terms, and generate
logical expression for the input values.

In the program Bar is represented by ‘^’ symbol.When we hit a key, we will see the
logical circuit required for realizing the obtained logical expression. The logic circuit
consist of AND & OR gates. For this circuit we have include images of the AND & OR
gates in the program. The program draws the logic circuit by checking the terms in the
expression and putting the images of gates accordingly using putimage() function.

Page | 1
KARNAUGH MAP

1.1 Objective of project

• This project aims at making K-MAP for variables ranging from 3-6.

• Depending upon the user’s choice, the project then solves K-MAP as
sum-of-product (SOP) or product-of-sum (POS).

• It then displays the K-MAP with simplified expression depending


upon the input given by the user.

• It then draws the logical circuit for the simplified expression.

• It then displays the truth table for the K-MAP.

Page | 2
KARNAUGH MAP

1.2 Need Of K-MAP


The increasing number of various digital gadgets around us is a
testimonial of the fact that in today’s world we are getting a lot more
dependent on these gadgets. All of these work on basic digital
principles and have to pass through various stages before their final
model is implemented. It is one of these stages that we require
optimization and reduction of these circuits so that they can be
implemented more efficiently by using lesser number of basic
components i.e. logic gates at the lowest level.

If we do not reduce the logic expressions before implementing the


circuits we may end up getting a very large logic expressions and
their implementation may turn out to be any engineer’s nightmare.

K-Map is one of the techniques used for simplification of these logic


circuits. Although this method is quite primitive and has many
limitations, it serves as the first step towards understanding the logic
expression simplification. Also if the number of Boolean variables is
less then six then this approach proves to be one of the best for
simplification of logic expressions. This method fails when the
number of variables is more than six.

Here we have a made a software for simplifying logic expressions


involving four variables. It has been implemented in ‘C’. It accepts as
input a logic expression in form of minterms (SOP or the Sum Of
Products) form. It then displays the K-map for the given expression,
simplifies the expression, gives the output in form of the input
variables and then goes on to display the logic diagram using the
basic AND and OR gates. So this software can be used for
simplifying small expressions provided they are in SOP form.

Page | 3
KARNAUGH MAP

1.3What Is K-MAP?
The Karnaugh map, also known as a Veitch diagram (K-map or KV-map
for short), is a tool to facilitate simplification of Boolean Algebraic
expressions.

A Karnaugh map is unique in that only one variable changes value


between squares, in other words, the rows and columns are ordered
according to the principles of Gray Code. 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 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 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.

A Karnaugh map provides a pictorial method of grouping together


expressions with common factors and therefore eliminating unwanted
variables.

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


a truth table) ordered according to the principles of Gray codes 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 through the axiom laws of boolean algebra.

Page | 4
KARNAUGH MAP

Page | 5
KARNAUGH MAP

2 DESCRIPTION

2.1 Functions

There are six functions in our project

• Kmap();

In this we declare K-MAP as a 3-D array. It takes 2 arguments. First


argument tells about the number of variables in K-MAP and other is a 1-D
array that defines position in K-MAP.

• group();

In this we do the grouping of our input in order to get the reduced


expression. For reducing expression first we have to mark pairs, quads and
octets. To reduce an expression adjacent 1’s are encircled. If two
adjacent 1’s are encircled it makes a pair. If four adjacent 1’s are
encircled it makes a quad. If eight adjacent 1’s are encircled it makes an
octet.

Page | 6
KARNAUGH MAP

• k_map();

This function draws a formatted K-MAP on the screen that shows the
input with marked pairs, quads or octets.

• sim();

This function returns a simplified expression

• circuit();

This function draws a logical circuit using logical AND or OR or NOT


gates in accordance with the simplified expression.

• truth table();

This function draws the truth table on the screen for the given input.

2.2 Module Description

i. MODULE 1:

In this module the user is asked to input the number of variables in


K Map. The range of variable is between 3-6. Then after that he is
asked to enter his choice for maximization or minimization of K
Map. After this he is asked to enter the number of values in K
Map.

Page | 7
KARNAUGH MAP

The range of value for 3 variables K Map is between 0-7. The


range of value for 4 variables K Map is between 0-15. The range
of value for 5 variables K Map is between 0-31. The range of
value for 6 variables K Map is between 0-63. Then user will enter
the values for displaying K Map.

ii. MODULE 2:

In this module K Map will be displayed depending upon the user’s


choice. It means that a 3 variable K Map or 4 variables K Map or
5 variables K Map or 6 variables K Map will be displayed on the
screen for the user.

iii. MODULE 3:

In this module the user provides the input three. The five options
that the users have are as follows:

A) Truth Table:

If a user chooses 1st choice then truth table will be displayed


to the user .The truth table is obtained from the K Map.

B) K Map:

If a user chooses 2nd choice then K Map will be displayed to


the user.

C) Expressions:

If a user chooses 3rd choice then expression will be displayed


to the user .The expression is obtained from the K Map.

D) Circuit Diagram:

If a user chooses 4th choice then circuit diagram will be


displayed to the user .The circuit diagram is drawn from the
expression obtained by K Map.

E) Exit:

If a user chooses 5th choice then the program will end.

iv. MODULE 4:

In this module the user provides the input four. The five options
that the users have are as follows:

Page | 8
KARNAUGH MAP

A) Truth Table:

If a user chooses 1st choice then truth table will be displayed


to the user .The truth table is obtained from the K Map.

B) K Map:

If a user chooses 2nd choice then K Map will be displayed to


the user.

C) Expressions:

If a user chooses 3rd choice then expression will be displayed


to the user .The expression is obtained from the K Map.

D) Circuit Diagram:

If a user chooses 4th choice then circuit diagram will be


displayed to the user .The circuit diagram is drawn from the
expression obtained by K Map.

E) Exit:

If a user chooses 5th choice then the program will end

v. MODULE 5:

In this module the user provides the input five. The five options
that the users have are as follows:

A) Truth Table:

If a user chooses 1st choice then truth table will be displayed


to the user .The truth table is obtained from the K Map.

B) K Map:

If a user chooses 2nd choice then K Map will be displayed to


the user.

C) Expressions:

If a user chooses 3rd choice then expression will be displayed


to the user .The expression is obtained from the K Map.

Page | 9
KARNAUGH MAP

D) Circuit Diagram:

If a user chooses 4th choice then circuit diagram will be


displayed to the user .The circuit diagram is drawn from the
expression obtained by K Map.

E) Exit:

If a user chooses 5th choice then the program will end

vi. MODULE 6:

In this module the user provides the input six. The five options
that the users have are as follows:

A) Truth Table:

If a user chooses 1st choice then truth table will be displayed


to the user .The truth table is obtained from the K Map.

B) K Map:

If a user chooses 2nd choice then K Map will be displayed to


the user.

C) Expressions:

If a user chooses 3rd choice then expression will be displayed


to the user .The expression is obtained from the K Map.

D) Circuit Diagram:

If a user chooses 4th choice then circuit diagram will be


displayed to the user .The circuit diagram is drawn from the
expression obtained by K Map.

E) Exit:

If a user chooses 5th choice then the program will end

Page | 10
KARNAUGH MAP

Page | 11
KARNAUGH MAP

3. System Requirements

3.1 Hardware Requirements

a. RAM 128 MB

b. PROCESSOR PentinumIII or higher

c. Hard disk space 50 MB(required)

3.2 Software Requirements

a. Software Turbo C++

b. Operating environment- Microsoft windows XP

Page | 12
KARNAUGH MAP

4. DESIGNING

Page | 13
KARNAUGH MAP

Ent KMAP
INTRODUCTION
ers

Takes
Variables
From 3-6

Input SOS/P
Variable OS

PRES
S Takes
Values for
Kmap
Expressi
on
Input
Values
Displ
ays Displ
ays

Disp
ELS
E
K MAP lay

Displ
Truth
ay
Disp Table
lay
Circuit
diagram Kmap
diagram

ER DIAGRAM

Page | 14
KARNAUGH MAP

USER EXIT

Zero level DFD

Page | 15
KARNAUGH MAP

5. ABOUT C
C is a programming language developed at AT & T Bell Laboratories of USA in
1972.
It was designed and written by a man named Dennis Ritchie.

In the late seventies C began to replace the more familiar languages of that time
like PL/I, ALGOL etc.
Possibly why C seems so popular is because it is reliable, simple and easy to use.

5.1 Getting Started With C:

i) Constants, Variables and Keywords in C

The alphabets, numbers and special symbols when properly combined


form constants, variables and keywords. Let us see what are constants and
variables in C.

A Constant is an entity that doesn’t change whereas variable is an entity


that may change.

ii) Types of C constants

C constants can be divided into two major categories:

(1) Primary Constants

(2) Secondary Constants

(i) Primary constants are further classified as:

1. Integer constant
2. Real Constant
3. Character Constant

(2) Secondary constants are further classified as

1. Array
2. Pointer
3. Structure
4. Union
5. Enum. etc.

Page | 16
KARNAUGH MAP

iii. C Keywords

Keywords are the words whose meaning has already been explained to the
compiler.

The keyword cannot be used as variable names because if we do so we


are trying to assign a new meaning to the keyword, which is not
allowed by the computer.

There are 32 Keyword available in C. Examples are auto, break, case,


char, double.

iv. Some basic rules:

(i) An integer constant must have at least one digit.

(ii) No commas or blanks are allowed within a real constant.

(iii)The maximum length of a character constant can be 1 character.


For ex. ‘A’.

v. C Instructions

There are basically three types of instructions in C.

a. Type Declaration Instruction

It is used to declare the type of variables used in a C program.

1. Arithmetic Instruction:

It is used to perform arithmetic operations between


constants and variables.

2. Control Instruction:

It is used to control the sequence of execution of various


statements in a C program.

There are four types of control instructions in C:

i. Sequence Control Instruction

ii. Selection or Decision Control Instruction

iii. Repetition or Loop Control Instruction

Page | 17
KARNAUGH MAP

iv. Case Control Instruction

o The Sequence Control Instruction ensures that the


instructions are executed in the same order in which they
appear in the program.

o Decision and Case Control Instruction allow the computer


to take a decision as to which instruction is to be executed
next.

o The Loop Control Instruction helps computer to execute a


group of statements repeatedly.

vi. The Loop Control Structure:

The versatility of the computer lies in its ability to perform a set of


instructions repeatedly.
This involves repeating some portion of the program either a
specified number of times or until a particular condition is being
satisfied. This repetitive operation is done through a loop control
instruction.

There are three methods by way of which we can repeat a part of a


program. They are:

1. Using a for statement

2. Using a while statement

3. Using a do-while statement

a. The for Loop

The for allows us to specify three things about a loop in a single line:

Setting a loop counter to an initial value.


Testing the loop counter to determine whether its value has reached the number
of repetitions desired.
Increasing the value of loop counter each time the program segment within the
loop has been executed.

Page | 18
KARNAUGH MAP

The general form of for statement is as under:

For (initialize counter; test counter; increment counter)


{
do this;
and this;
}

b. The while Loop

The general form of while is as shown below:

Intialise loop counter;


While (test loop counter using a condition)
{
do this ;
and this;
increment loop counter;
}

c. The do-while Loop

The do-while loop looks like this:

Do
{
this;
and this;
and this;
and this;
} while (this condition is true);

There is a minor difference between the working of while and do-while loops.

The while tests the condition before executing any of the statements within the
while loop.

The do-while tests the condition after having executed the statements within the
loop.

Page | 19
KARNAUGH MAP

vii. Functions

Knowingly or unknowingly we rely on so many persons for so many


things. Man is an intelligent species, but still cannot perform all of life’s
tasks all alone. He has to rely on others.

A computer program (except for the simplest one) finds him in a similar
situation. It cannot handle all the tasks by itself. Instead, it requests other
programs like entities – called ‘functions’ in C.

What is function?

A function is a self-contained block of statements that perform a coherent


task of some kind.

Every C program can be thought of as a collection of these functions. As


we noted earlier, using a function is something like hiring a person to do a
specific job for you.

Sometimes the interaction with this person is very simple, sometimes it’s
complex. To avoid repetition of code and bulky programs functionally
related statements are isolated into a function.

Function declaration specifies, what is the return type of the function and
the types of parameters it accepts.

Function definition defines the body of the function. A function can be


called either by value or by reference. Adding too many functions and
calling them frequently may slow down the program execution.
Variables declared in the function are not available to other functions in a
program.

viii. Pointer

Pointers are not exclusive to functions, but this seems a good place to
introduce the pointer type.
Imagine that we have an int called i. Its address could be represented by
the symbol &i. If the pointer is to be stored as a variable, it should be
stored like this.

int *pi = &i;


int * is the notation for a pointer to an int. & is the operator which returns
the address of its argument. When it is used, as in &i we say it is
referencing i.
The opposite operator, which gives the value at the end of the pointer is *.
An example of use, known as de-referencing pi, would be
Page | 20
KARNAUGH MAP

i = *pi;
Take care not to confuse the many uses of the * sign; Multiplication,
pointer declaration and pointer de-referencing.

Page | 21
KARNAUGH MAP

6. PROJECT DESCRIPTION

6.1 Boolean Algebra

One of the primary requirements when dealing with digital circuits is to find
ways to make them as simple as possible. This constantly requires that
complex logical expressions be reduced to simpler expressions that
nevertheless produce the same results under all possible conditions. The
simpler expression can then be implemented with a smaller, simpler circuit,
which in turn saves the price of the unnecessary gates, reduces the number of
gates needed, and reduces the power and the amount of space required by
those gates.

One tool to reduce logical expressions is the mathematics of logical


expressions, introduced by George Boole in 1854 and known today as
Boolean Algebra. The rules of Boolean Algebra are simple and straight-
forward, and can be applied to any logical expression. The resulting reduced
expression can then be readily tested with a Truth Table, to verify that the
reduction was valid.

A logic gate performs a logical operation on one or more logic inputs and
produces a single logic output. The logic normally performed is Boolean
logic and is most commonly found in digital circuits. Logic gates are
primarily implemented electronically using diodes or transistors, but can
also be constructed using electromagnetic relays, fluidics, optics,
molecules, or even mechanical elements.

In electronic logic, a logic level is represented by a voltage or current,


(which depends on the type of electronic logic in use). Each logic gate
requires power so that it can source and sink currents to achieve the
correct output voltage. In logic circuit diagrams the power is not shown,
but in a full electronic schematic, power connections are required.

NAND and NOR logic gates are the two pillars of logic, in that all other
types of Boolean logic gates (i.e., AND, OR, NOT, XOR, XNOR) can be
created from a suitable network of just NAND or just NOR gate(s). They
can be built from relays or transistors, or any other technology that can
create an inverter and a two-input AND or OR gate. Hence the NAND
and NOR gates are called the universal gates

Page | 22
KARNAUGH MAP

The rules of Boolean Algebra are:.

1. AND Operations (·)

0·0 = 0 A·0 = 0
1·0 = 0 A·1 = A
0·1 = 0 A·A = A
1·1 = 1 A·A' = 0

2. OR Operations (+)

0+0 = 0 A+0 = A
1+0 = 1 A+1 = 1
0+1 = 1 A+A = A
1+1 = 1 A+A' = 1

3. NOT Operations (')

0' = 1 A'' = A
1' = 0

4. Associative Law

(A·B)·C = A·(B·C) = A·B·C


(A+B)+C = A+(B+C) = A+B+C

5. Distributive Law

A·(B+C) = (A·B) + (A·C)


A+(B·C) = (A+B) · (A+C)

6. Commutative Law

A·B = B·A
A+B = B+A

Page | 23
KARNAUGH MAP

7. Precedence

AB = A·B
A·B+C = (A·B) + C
A+B·C = A + (B·C)

8. DeMorgan's Theorem

(A·B)' = A' + B' (NAND)


(A+B)' = A' · B' (NOR)

6.1.1 DeMorgan's Theorem


DeMorgan's theorems are extremely useful in simplifying
expressions in which a product or sum of variables is inverted. The
two theorems are:

(x+y)' = x' * y'

(x*y)' = x' + y'

In formal logic, De Morgan's laws are rules relating the logical


operators 'and' and 'or' in terms of each other via negation.

NOT (P OR Q) = (NOT P) AND (NOT Q)

NOT (P AND Q) = (NOT P) OR (NOT Q)

Theorem (16) says that when the OR sum of two variables is


inverted, this is the same as inverting each variable individually and
then ANDing these inverted variables.

Theorem (17) says that when the AND product of two variables is
inverted, this is the same as inverting each variable individually and
then ORing them.

Page | 24
KARNAUGH MAP

Example

X = [(A'+C) * (B+D')]'
= (A'+C)' + (B+D')'
[by theorem (17)]
= (A''*C') + (B'+D'')
[by theorem (16)]
= AC' + B'D

Three Variables DeMorgan's Theorem

(x+y+z)' = x' * y' * z'

(xyz)' = x' + y' + z'

6.1.2 Truth table


A truth table is a mathematical table used in logic—specifically in
connection with Boolean algebra, boolean functions, and propositional
calculus—to compute the functional values of logical expressions on
each of their functional arguments, that is, on each combination of
values taken by their logical variables (Enderton 2001). In
particular, truth tables can be used to tell whether a propositional
expression is true for all legitimate input values, that is, logically valid

6.1.3 Boolean rules for simplification


Boolean algebra finds its most practical use in the simplification of logic
circuits. If we translate a logic circuit's function into symbolic (Boolean)
form, and apply certain algebraic rules to the resulting equation to reduce
the number of terms and/or arithmetic operations, the simplified equation
may be translated back into circuit form for a logic circuit performing the
same function with fewer components. If equivalent function may be
achieved with fewer components, the result will be increased reliability
and decreased cost of manufacture.

To this end, there are several rules of Boolean algebra presented in this
section for use in reducing expressions to their simplest forms. The
identities and properties already reviewed in this chapter are very useful
in Boolean simplification, and for the most part bear similarity to many
identities and properties of "normal" algebra. However, the rules shown in
this section are all unique to Boolean mathematics.

Page | 25
KARNAUGH MAP

This rule may be proven symbolically by factoring an "A" out of the two
terms, then applying the rules of A + 1 = 1 and 1A = A to achieve the
final result:

Please note how the rule A + 1 = 1 was used to reduce the (B + 1) term to

1. When a rule like "A + 1 = 1" is expressed using the letter "A", it doesn't
mean it only applies to expressions containing "A". What the "A" stands
for in a rule like A + 1 = 1 is any Boolean variable or collection of
variables. This is perhaps the most difficult concept for new students to
master in Boolean simplification: applying standardized identities,
properties, and rules to expressions not in standard form.

Page | 26
KARNAUGH MAP

For instance, the Boolean expression ABC + 1 also reduces to 1 by means


of the "A + 1 = 1" identity. In this case, we recognize that the "A" term in
the identity's standard form can represent the entire "ABC" term in the
original expression.

The next rule looks similar to the first on shown in this section, but is
actually quite different and requires a more clever proof:

Note how the last rule (A + AB = A) is used to "un-simplify" the first "A"
term in the expression, changing the "A" into an "A + AB". While this
may seem like a backward step, it certainly helped to reduce the
expression to something simpler! Sometimes in mathematics we must
take "backward" steps to achieve the most elegant solution. Knowing
when to take such a step and when not to is part of the art-form of algebra,
just as a victory in a game of chess almost always requires calculated
sacrifices.

Page | 27
KARNAUGH MAP

Another rule involves the simplification of a product-of-sums expression:

And, the corresponding proof:

To summarize, here are the three new rules of Boolean simplification


expounded in this section:

Page | 28
KARNAUGH MAP

6.1.4 Boolean arithmetic


Let us begin our exploration of Boolean algebra by adding numbers
together:

The first three sums make perfect sense to anyone familiar with
elementary addition. The last sum, though, is quite possibly responsible
for more confusion than any other single statement in digital
electronics, because it seems to run contrary to the basic principles of
mathematics. Well, it does contradict principles of addition for real
numbers, but not for Boolean numbers. Remember that in the world of
Boolean algebra, there are only two possible values for any quantity
and for any arithmetic operation: 1 or 0. There is no such thing as "2"
within the scope of Boolean values. Since the sum "1 + 1" certainly
isn't 0, it must be 1 by process of elimination.

It does not matter how many or few terms we add together, either.
Consider the following sums:

Take a close look at the two-term sums in the first set of equations.
Does that pattern look familiar to you? It should! It is the same pattern
of 1's and 0's as seen in the truth table for an OR gate. In other words,
Boolean addition corresponds to the logical function of an "OR" gate,
as well as to parallel switch contacts:

Page | 29
KARNAUGH MAP

There is no such thing as subtraction in the realm of Boolean


mathematics. Subtraction implies the existence of negative numbers: 5
- 3 is the same thing as 5 + (-3), and in Boolean algebra negative
quantities are forbidden. There is no such thing as division in Boolean
mathematics, either, since division is really nothing more than
compounded subtraction, in the same way that multiplication is
compounded addition.

Page | 30
KARNAUGH MAP

Multiplication is valid in Boolean algebra, and thankfully it is the same


as in real-number algebra: anything multiplied by 0 is 0, and anything
multiplied by 1 remains unchanged:

This set of equations should also look familiar to you: it is the same
pattern found in the truth table for an AND gate. In other words,
Boolean multiplication corresponds to the logical function of an
"AND" gate, as well as to series switch contacts:

Page | 31
KARNAUGH MAP

Like "normal" algebra, Boolean algebra uses alphabetical letters to


denote variables. Unlike "normal" algebra, though, Boolean variables
are always CAPITAL letters, never lower-case. Because they are
allowed to possess only one of two possible values, either 1 or 0, each
and every variable has a complement: the opposite of its value. For
example, if variable "A" has a value of 0, then the complement of A
has a value of 1. Boolean notation uses a bar above the variable
character to denote complementation, like this:

In written form, the complement of "A" denoted as "A-not" or "A-bar".


Sometimes a "prime" symbol is used to represent complementation.
For example, A' would be the complement of A, much the same as
using a prime symbol to denote differentiation in calculus rather than
the fractional notation d/dt. Usually, though, the "bar" symbol finds
more widespread use than the "prime" symbol, for reasons that will
become more apparent later in this chapter.

Boolean complementation finds equivalency in the form of the NOT


gate, or a normally-closed switch or relay contact:

Page | 32
KARNAUGH MAP

The basic definition of Boolean quantities has led to the simple rules of
addition and multiplication, and has excluded both subtraction and
division as valid arithmetic operations. We have a symbology for
denoting Boolean variables, and their complements. In the next section
we will proceed to develop Boolean identities.

Boolean algebraic identities

In mathematics, an identity is a statement true for all possible values of


its variable or variables. The algebraic identity of x + 0 = x tells us that
anything (x) added to zero equals the original "anything," no matter
what value that "anything" (x) may be. Like ordinary algebra, Boolean
algebra has its own unique identities based on the bivalent states of
Boolean variables.

The first Boolean identity is that the sum of anything and zero is the
same as the original "anything." This identity is no different from its
real-number algebraic equivalent:

Page | 33
KARNAUGH MAP

No matter what the value of A, the output will always be the same:
when A=1, the output will also be 1; when A=0, the output will also be
0.

The next identity is most definitely different from any seen in normal
algebra. Here we discover that the sum of anything and one is one:

No matter what the value of A, the sum of A and 1 will always be 1. In


a sense, the "1" signal overrides the effect of A on the logic circuit,
leaving the output fixed at a logic level of 1.

Next, we examine the effect of adding A and A together, which is the


same as connecting both inputs of an OR gate to each other and
activating them with the same signal:

In real-number algebra, the sum of two identical variables is twice the


original variable's value (x + x = 2x), but remember that there is no
concept of "2" in the world of Boolean math, only 1 and 0, so we
cannot say that A + A = 2A. Thus, when we add a Boolean quantity to
itself, the sum is equal to the original quantity: 0 + 0 = 0, and 1 + 1 = 1.

Introducing the uniquely Boolean concept of complementation into an


additive identity, we find an interesting effect. Since there must be one
"1" value between any variable and its complement, and since the sum
of any Boolean quantity and 1 is 1, the sum of a variable and its
complement must be 1:

Page | 34
KARNAUGH MAP

Just as there are four Boolean additive identities (A+0, A+1, A+A, and
A+A'), so there are also four multiplicative identities: Ax0, Ax1, AxA,
and AxA'. Of these, the first two are no different from their equivalent
expressions in regular algebra:

The third multiplicative identity expresses the result of a Boolean


quantity multiplied by itself. In normal algebra, the product of a
variable and itself is the square of that variable (3 x 3 = 32 = 9).
However, the concept of "square" implies a quantity of 2, which has no
meaning in Boolean algebra, so we cannot say that A x A = A2.
Instead, we find that the product of a Boolean quantity and itself is the
original quantity, since 0 x 0 = 0 and 1 x 1 = 1:

Page | 35
KARNAUGH MAP

The fourth multiplicative identity has no equivalent in regular algebra


because it uses the complement of a variable, a concept unique to
Boolean mathematics. Since there must be one "0" value between any
variable and its complement, and since the product of any Boolean
quantity and 0 is 0, the product of a variable and its complement must
be 0:

To summarize, then, we have four basic Boolean identities for addition


and four for multiplication:

Another identity having to do with complementation is that of the


double complement: a variable inverted twice. Complementing a
variable twice (or any even number of times) results in the original
Boolean value. This is analogous to negating (multiplying by -1) in
real-number algebra: an even number of negations cancel to leave the
original value:

Page | 36
KARNAUGH MAP

Describing Logic Circuits Algebraically

Any logic circuit, no matter how complex, may be completely


described using the Boolean operations, because the OR gate, AND
gate, and NOT circuit are the basic building blocks of digital systems.

This is an eample of the circuit using Boolean expression:

If an expression contains both AND and OR operations, the AND


operations are performed first (X=AB+C : AB is performed first),
unless there are parentheses in the expression, in which case the
operation inside the parentheses is to be performed first (X=(A+B)+C :
A+B is performed first).

Page | 37
KARNAUGH MAP

Circuits containing Inverters

Whenever an INVERTER is present in a logic-circuit diagram, its


output expression is simply equal to the input expression with a prime
(') over it.

Evaluating Logic Circuit Outputs

Once the Boolean expression for a circuit output has been obtained, the
output logic level can be determined for any set of input levels.

This are two examples of the evaluating logic circuit output:

Let A=0, B=1, C=1, D=1

= A'BC
X
(A+D)'
=
0'*1*1*
(0+1)'
=1
*1*1*
(1)'
= 1
*1*1* 0
=0

Let A=0, B=0, C=1, D=1, E=1

Page | 38
KARNAUGH MAP

= [D+
X ((A+B)C)']
*E
= [1 +
((0+0)1 )']
*1
= [1 +
(0*1)'] * 1
= [1+ 0']
*1
= [1+ 1 ] *
1
=1

In general, the following rules must always be followed when


evaluating a Boolean expression:

1. First, perform all inversions of single terms; that is, 0 = 1 or 1 = 0.

2. Then perform all operations within parentheses.

3. Perform an AND operation before an OR operation unless


parentheses indicate otherwise.

4. If an expression has a bar over it, perform the operations of the


expression first and then invert the result.

Determining Output Level from a Diagram

The output logic level for given input levels can also be determined
directly from the circuit diagram without using the Boolean expression.

Page | 39
KARNAUGH MAP

Implementing Circuits From Boolean Expression

If the operation of a circuit is defined by a Boolean expression, a logic-


circuit diagram can he implemented directly from that expression.

Suppose that we wanted to construct a circuit whose output is y =


AC+BC' + A'BC. This Boolean expression contains three terms (AC,
BC', A'BC), which are ORed together. This tells us that a three-input
OR gate is required with inputs that are equal to AC, BC', and A'BC,
respectively.

Each OR-gate input is an AND product term, which means that an


AND gate with appropriate inputs can be used to generate each of these
terms. Note the use of INVERTERs to produce the A' and C' terms
required in the expression.

Page | 40
KARNAUGH MAP

Universality of NAND & NOR Gates

It is possible to implement any logic expression using only NAND


gates and no other type of gate. This is because NAND gates, in the
proper combination, can be used to perform each of the Boolean
operations OR, AND, and INVERT.

Page | 41
KARNAUGH MAP

In a similar manner, it can be shown that NOR gates can be arranged to


implement any of the Boolean operations.

Logic Symbol Interpretation

When an input or output line on a logic circuit symbol has no bubble


on it, that line is said to be active-HIGH. When an input or output line
does have a bubble on it, that line is said to be active-LOW. The
presence or absence of a bubble, then, determines the active-
HIGH/active-LOW status of a circuit's inputs and output, and is used to
interpret the circuit operation.

Page | 42
KARNAUGH MAP

6.2 CANONICAL FORM (BOOLEAN ALGEBRA)

In Boolean algebra, any Boolean function can be expressed in a canonical


form using the dual concepts of minterms and maxterms. Minterms are
called products because they are the AND of a set of variables, and
maxterms are called sums because they are the OR of a set of variables
(further definition appears in the sections headed Minterms and Maxterms
below). These concepts are called duals because of their complementary-
symmetry relationship as expressed by De Morgan's laws, which state that
AND(x,y,z,...) = NOR(x',y',z',...) and OR(x,y,z,...) = NAND(x',y',z',...).

The dual canonical forms of any Boolean function are a "sum of minterms"
and a "product of maxterms." The term "Sum of Products" or "SoP" is
widely used for the canonical form that is a disjunction (OR) of minterms.
Its De Morgan dual is a "Product of Sums" or "PoS" for the canonical form
that is a conjunction (AND) of maxterms. These forms allow for greater
analysis into the simplification of these functions, which is of great
importance in the minimization or other optimization of digital circuits.

The usual purpose of doing Boolean algebra is to simplify the design of a


digital circuit that performs a function, either to minimize the number of
gates, or to minimize the time for the value of the function to settle down
after a change in its input(s), or some other practical criterion.

All variables in Boolean algebra take on the values 0 or 1 only, sometimes


referred to as false and true respectively because George Boole focused on
a propositional calculus rather than binary numbers as such.

Boolean algebra does not rely on conventional algebraic notation, as it is


the arthimetic between false and true variables, not numeric. There are three
primary functions in Boolean algebra: NOT, AND and OR.

The usual notation for NOT is that of a trailing apostrophe; for example, x'
means x not. This is also known as the complement of the function.

The usual notation for AND is that of multiplication; for example, x y


means x AND y.

The usual notation for OR is that of addition; for example, x + y means x


OR y.

There are sixteen possible functions of two variables, but in digital logic
hardware, the simplest gate circuits implement only four of them:

Page | 43
KARNAUGH MAP

conjunction (AND), disjunction (inclusive OR), and the complements of


those (NAND and NOR).

Most gate circuits accept more than 2 input variables; for example, the
spaceborne Apollo Guidance Computer, which pioneered the application of
integrated circuits in the 1960s, was built with only one type of gate, a 3-
input NOR, whose output is true only when all 3 inputs are false

A) Minterms

For a boolean function of n variables , a product term in


which each of the n variables appears once (in either its complemented
or uncomplemented form) is called a minterm. Thus, a minterm is a
logical expression of n variables that employs only the complement
operator and the conjunction operator.

For example, abc, ab'c and abc' are examples of minterms for a Boolean
function of the three variables a, b and c. The customary reading of the
last of those is a AND b AND NOT-c.

There are 2n minterms of n variables, since a variable in the minterm


expression can be in either its direct or its complemented form--two
choices per n variables.

a. Indexing minterms

In general, one assigns each minterm an index based on a


conventional binary encoding of the complementation pattern of
the variables (where the variables in all the minterms are written in
the same order, usually alphabetical). This convention assigns the
value 1 to the direct form (xi) and 0 to the complemented form
(x'i). For example, we assign the index 6 to the minterm abc' (110)
and denote that minterm as m6. Similarly, m0 of the same three
variables is a'b'c' (000), and m7 is abc (111).

b. Functional equivalence

It is apparent that minterm n gives a true value (i.e., 1) for just one
combination of the input variables. For example, minterm 5, a b' c,
is true only when a and c both are true and b is false--the input
arrangement where a = 1, b = 0, c = 1 results in 1.

If one is given a truth table of a logical function, it is possible to


write the function as a "sum of products". This is a special form of
disjunctive normal form. For example, if given the truth table for

Page | 44
KARNAUGH MAP

the arithmetic sum bit u of one bit position's logic of an adder


circuit, as a function of x and y from the addends and the carry in,
ci:

c u(ci,x,y
x y
i )

0 0 0 0

0 0 1 1

0 1 0 1

0 1 1 0

1 0 0 1

1 0 1 0

1 1 0 0

1 1 1 1

Observing that the rows that have an output of 1 are the 2nd, 3rd,
5th, and 8th, we can write u as a sum of minterms m1,m2,m4, and
m7. If we wish to verify this: u(ci, x, y) = m1 + m2 + m4 + m7 = (ci'
x' y) + (ci' x y') + (ci x' y') + (ci x y) evaluated for all 8
combinations of the three variables will match the table.

B) Maxterms

For a boolean function of n variables , a sum term in which


each of the n variables appears once (in either its complemented or
uncomplemented form) is called a maxterm. Thus, a maxterm is a logical
expression of n variables that employs only the complement operator and
the disjunction operator. Maxterms are a dual of the minterm idea (i.e.,
exhibiting a complementary symmetry in all respects). Instead of using
ANDs and complements, we use ORs and complements and proceed
similarly.

For example, the following are two of the eight maxterms of three
variables:

a+b'+c

Page | 45
KARNAUGH MAP

a'+b+c

There are again 2n maxterms of n variables, since a variable in the


maxterm expression can also be in either its direct or its complemented
form--two choices per n variables.

a) Indexing maxterms

Each maxterm is assigned an index based on the opposite conventional


binary encoding used for minterms. The maxterm convention assigns
the value 0 to the direct form (xi) and 1 to the complemented form (x'i).
For example, we assign the index 6 to the maxterm a' + b' + c (110) and
denote that maxterm as M6. Similarly M0 of these three variables is a +
b + c (000) and M7 is a' + b' + c' (111).

b) Functional equivalence

It is apparent that maxterm n gives a false value (i.e., 0) for just one
combination of the input variables. For example, maxterm 5, a' + b + c', is
false only when a and c both are true and b is false--the input arrangement
where a = 1, b = 0, c = 1 results in 0.

If one is given a truth table of a logical function, it is possible to write the


function as a "product of sums". This is a special form of conjunctive
normal form. For example, if given the truth table for the carry-out bit co
of one bit position's logic of an adder circuit, as a function of x and y from
the addends and the carry in, ci:

ci x Y co(ci,x,y)

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

Page | 46
KARNAUGH MAP

Observing that the rows that have an output of 0 are the 1st, 2nd, 3rd, and
5th, we can write co as a product of maxterms M0, M1, M2, and M5. If we
wish to verify this: co(ci, x, y) = M0M1M2M5 = (ci + x + y) (ci + x + y') (ci
+ x' + y) (ci' + x + y) evaluated for all 8 combinations of the three
variables will match the table.

Dualization
The complement of a minterm is the respective maxterm. This can be easily
verified by using de Morgan's law. For example: M5 = a' + b + c' = (ab'c)' =
m5'

C) Non-canonical PoS and SoP forms

It is often the case that the canonical minterm form can be simplified to
an equivalent SoP form. This simplified form would still consist of a sum
of product terms. However, in the simplified form it is possible to have
fewer product terms and/or product terms that contain fewer variables.
For example, the following 3-variable function:

a b c f(a,b,c)

0 0 0 0

0 0 1 0

0 1 0 0

0 1 1 1

1 0 0 0

1 0 1 0

1 1 0 0

1 1 1 1

Page | 47
KARNAUGH MAP

has the canonical minterm representation: f = a'bc + abc, but it has an


equivalent simplified form: f = bc. In this trivial example it is obvious that
bc = a'bc + abc but the simplified form has both fewer product terms, and
the term has fewer variables. The most simplified SoP representation of a
function is referred to as a minimal SoP form.

In a similar manner, a canonical maxterm form can have a simplified PoS


form.

While this example was easily simplified by applying normal algebraic


methods [f = (a' + a)bc], in less obvious cases a convenient method for
finding the minimal PoS/SoP form of a function with up to four variables
is using a Karnaugh map.

The minimal PoS and SoP forms are very important for finding optimal
implementations of boolean functions and minimizing logic circuits.

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.

Page | 48
KARNAUGH 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.

There is a second glitch in the same example that is more difficult to spot:
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.

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

6.3 INTRODUCTION TO KMAP

Page | 49
KARNAUGH MAP

The Karnaugh map, also known as a Veitch diagram (K-map or KV-map for
short), is a tool to facilitate management of Boolean Algebraic expressions.
A Karnaugh map is unique in that only one variable changes value between
squares, in other words, the rows and columns are ordered according to the
principles of Gray Code.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. A
Karnaugh map provides a pictorial method of grouping together expressions
with common factors and therefore eliminating unwanted variables.

History and nomenclature

The Karnaugh map was invented in 1953 by Maurice Karnaugh, a


telecommunications engineer at Bell Labs.

6.3.1 Usage and Boolean logic


Normally, extensive calculations are required to obtain the minimal
expression of a Boolean function, but one can use a Karnaugh map
instead.

Problem solving uses Karnaugh maps make use of the human brain's
excellent pattern-matching capability to decide which terms should
be combined to get the simplest expression.

K-maps permit the rapid identification and elimination of potential


race hazards, something that Boolean equations alone cannot do.

A Karnaugh map is an excellent aid for simplification of up to six


variables, but with more variables it becomes hard even for our brain
to discern optimal patterns.

For problems involving more than six variables, solving the Boolean
expressions is more preferred than the Karnaugh map.

Karnaugh maps also help teach about Boolean functions and


minimization.

Page | 50
KARNAUGH MAP

A mapping of minterms on a Karnaugh map. The arrows indicate


which squares can be thought of as "switched" (rather than being in a
normal sequential order).

A Karnaugh map may have any number of variables, but usually


works best when there are only a few - between 2 and 6 for example.
Each variable contributes two possibilities to each possibility of
every other variable in the system. Karnaugh maps are organized so
that all the possibilities of the system are arranged in a grid form, and
between two adjacent boxes, only one variable can change value.
This is what allows it to reduce hazards.

When using a Karnaugh map to derive a minimized function, one


"covers" the ones on the map by rectangular "coverings" that contain
a number of boxes equal to a power of 2 (for example, 4 boxes in a
line, 4 boxes in a square, 8 boxes in a rectangle, etc). Once a person
has covered the ones, that person can produce a term of a sum of
products by finding the variables that do not change throughout the
entire covering, and taking a 1 to mean that variable, and a 0 as the
complement of that variable. Doing this for every covering gives you
a matching function.

One can also use zeros to derive a minimized function. The


procedure is identical to the procedure for ones, except that each term

Page | 51
KARNAUGH MAP

is a term in a product of sums - and a 1 means the compliment of the


variable, while 0 means the variable non-complimented.

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.

6.3.2 Rules of Simplification


The Karnaugh map uses the following rules for the simplification of
expressions by grouping together adjacent cells containing ones:-

Groups may not include any cell containing a zero

Groups may be horizontal or vertical, but not diagonal.

Groups must contain 1, 2, 4, 8, or in general 2n cells. That is if n = 1, a


group will contain two 1's since 21 = 2. If n = 2, a group will contain four

Page | 52
KARNAUGH MAP

1's since 22 = 4.

Each group should be as large as possible.

Each cell containing a one must be in at least one group.

Page | 53
KARNAUGH MAP

Groups may overlap.

Groups may wrap around the table. The leftmost cell in a row may be
grouped with the rightmost cell and the top cell in a column may be
grouped with the bottom cell.

There should be as few groups as possible, as long as this does not


contradict any of the previous rules.

Page | 54
KARNAUGH MAP

Summary
a. No zeros allowed.

b. No diagonals.

c. Only power of 2 number of cells in each group.

d. Groups should be as large as possible.

e. Every one must be in at least one group.

f. Overlapping allowed.

g. Wrap around allowed.

h. Fewest number of groups possible.

Example
Karnaugh maps are used to facilitate the simplification of Boolean
algebra functions. The following is an unsimplified Boolean Algebra
function with Boolean variables A, B, C, D, and their inverses. They
can be represented in two different functions:

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

Page | 55
KARNAUGH MAP

Note: The values inside ∑ are the minterms to map (i.e. which rows
have output 1 in the truth table).

Truth table

Using the defined minterms, the truth table can be created:

A B C D f(A,B,C,D)
#

0 000 0 0

1 000 1 0

2 001 0 0

3 001 1 0

4 010 0 0

5 010 1 0

6 011 0 1

7 011 1 0

8 100 0 1

9 100 1 1

10 101 0 1

Page | 56
KARNAUGH MAP

11 101 1 1

12 110 0 1

13 110 1 1

14 111 0 1

15 111 1 0

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 × 4 grid.

The binary digits in the map represent the function's output for any given
combination of inputs. We write 0 in the upper leftmost corner of the map
because f = 0 when A = 0, B = 0, C = 1, D = 0. Similarly we mark the bottom
right corner as 1 because A = 1, B = 0, C = 0, D = 0 gives f = 1. Note that the
values are ordered in a Gray code, so that precisely one variable flips
between any pair of adjacent cells.

After the Karnaugh map has been constructed our next task is to find the
minimal terms to use in the final expression. These terms are found by

Page | 57
KARNAUGH MAP

encircling groups of 1's in the map. The encircling must be rectangular and
must have an area that is a positive power of two (i.e. 2, 4, 8 …). The
rectangles should be as large as possible without containing any 0's. The
optimal encircling in this map are marked by the green, red and blue lines.

For each of these encircling we find those variables that have the same state
in each of the fields in the encircling. For the first encircling (the red one) we
find that:

The variable A maintains the same state (1) in the whole encircling; therefore
it should be included in the term for the red encircling.

Variable B does not maintain the same state (it shifts from 1 to 0), and
should therefore be excluded.

C does not change: it is always 1.

D changes.

Thus the first term in the Boolean expression is AC.

For the green encircling we see that A and B maintain the same state, but C
and D change. B is 0 and has to be negated before it can be included. Thus
the second term is AB'.

In the same way, the blue rectangle gives the term BC'D' and so the whole
expression is: AC + AB′+ BC′D′.

When not to use K-maps


The diagram becomes cluttered and hard to interpret if there are more than
four variables on an axis. This argues against the use of Karnaugh maps for
expressions with more than six variables. For such expressions, the Quine-
McCluskey algorithm, also called the method of prime implicants, should be
used.

This algorithm generally finds most of the optimal solutions quickly and
easily, but selecting the final prime implicants (after the essential ones are
chosen) may still require a brute force approach to get the optimal
combination (though this is generally far simpler than trying to brute force
the entire problem).

6.3.3 Summary
K-maps are an alternative to algebra for simplifying expressions.

Page | 58
KARNAUGH MAP

• The result is a minimal sum of products, which leads to a minimal


two-level circuit.

• It’s easy to handle don’t-care conditions.

• Things to keep in mind:

1. Remember the correct order of minterms on the K-map.

2. When grouping, you can wrap around all sides of the K-map,
and your groups can overlap.

3. Make as few rectangles as possible, but make each of them as


large as possible. This leads to fewer, but simpler, product
terms.

4. There may be more than one valid solution.

6.3.4 When not to use kmap


The diagram becomes cluttered and hard to interpret if there are
more than four variables on an axis. This argues against the use of
Karnaugh maps for expressions with more than six variables. For
such expressions, the Quine-McCluskey algorithm, also called the
method of prime implicants, should be used.

This algorithm generally finds most of the optimal solutions


quickly and easily, but selecting the final prime implicants (after
the essential ones are chosen) may still require a brute force
approach to get the optimal combination (though this is generally
far simpler than trying to brute force the entire problem).

Page | 59
KARNAUGH MAP

• K-map advantages

• The K-map interprets Boolean logic from a truth table or list of


minterms to create a chart that can create an algebraic expression with the
least number of logic gates used.

• Using this method, the chart eliminates the need to list out all the
terms of the equation, which if you have an equation with three or four
variables with many true values can be quite length. These methods can
eliminate the need to factor out variables.

• K-map disadvantages

 The K-map has a few limitations. In some algebraic expressions,


there may be variations as to how they are interpreted. K-maps are
not very effective using five or more variables. When five or more
variables are used, a truth table is recommenced.

Page | 60
KARNAUGH MAP

7. IMPLEMENTATION DETAILS

 It has been implemented in ‘C’.

 First it accepts as input a logic expression in form of minterms

 It then displays the K-map for the given expression,& the simplified expression

 It then displays the truth table.

 Then it goes on to display the logic diagram using the basic AND and OR gates

Page | 61
KARNAUGH MAP

8. TESTING
Testing is the process of exercising software with the intent of finding errors and
ultimately correcting them. The following testing techniques have been used to
make this project free of errors.

i) CONTENT REVIEW

The whole content of the project has been reviewed thoroughly to uncover
typographical errors, grammatical error and ambiguous sentences.

ii) NAVIGATION ERRORS

Different users were allowed to navigate through the project to uncover the
navigation errors. The views of the user regarding the navigation flexibility
and user friendliness were taken into account and implemented in the project.

iii) UNIT TESTING

Focuses on individual software units, groups of related units.Unit - smallest


testable piece of software.

A unit can be compiled /assembled /linked/loaded; and put under a test


harness.

Unit testing done to show that the unit does not satisfy the application and/or
its implemented software does not match the intended designed structure.

iv) INTEGRATION TESTING

Page | 62
KARNAUGH MAP

Focuses on combining units to evaluate the interaction among them.


Integration is the process of aggregating components to create larger
components.

Integration testing done to show that even though components were


individually satisfactory, the combination is incorrect and inconsistent.

v) SYSTEM TESTING

Focuses on a complete integrated system to evaluate compliance with


specified
requirements (test characteristics that are only present when entire system is
run)
A system is a big component.
System testing is aimed at revealing bugs that cannot be attributed to a
component as such, to inconsistencies between components or planned
interactions between components.
Concern: issues, behaviors that can only be exposed by testing the entire
integrated system (e.g., performance, security, recovery).

vi) REGRESSION TESTING

Each time a new feature is added to the project the whole project is tested
thoroughly to rectify any side effects. That might have occurred due to the
addition of the new feature. Thus regression testing has been performed.

vii) DEBUGGING

Debugging is a consequence of successful testing. That is when a test care


uncovers an error, debugging is the process that results in the removal of
errors. There are mainly two types of debugging.

viii) BACKTRACKING

Backtracking is a fairly common debugging approach that can be used


successfully in small programs. Beginning at the site where a symptom has
been uncovered, the source code is traced backward until the site of the cause
is found.

ix) BRUTE FORCING

Page | 63
KARNAUGH MAP

This is the most common category of debugging which involves loading the
source code with write statements and tracking line by line execution to
isolate possible errors.

9. SCREEN SHOTS

9.1 SCREENSHOT 1

Enter no of variables(3-6): 4

Enter i/p choice (m/M): m

Enter the no of inputs: 6

Enter i/p value within 15

3
4
5
6
7
8

Page | 64
KARNAUGH MAP

9.2 SCREENSHOT 2

K-MAP

Page | 65
KARNAUGH MAP

9.3 SCREENSHOT 3

I/P is
∑(3,4,5,6,7,8)
No. of variables=4

1: Truth Table

2: K Map

3: Expression

4: Circuit

5: Out form exe

Enter your choice: 1

Page | 66
KARNAUGH MAP

9.4 SCREENSHOT 4

A B C D Y
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 1
0 1 0 0 1
0 1 0 1 1
0 1 1 0 1
0 1 1 1 1
1 0 0 0 1
1 0 0 1 0 A B C D Y
1 0 1 0 0 1 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0

Page | 67
KARNAUGH MAP

9.5 SCREENSHOT 5

I/P is
∑(3,4,5,6,7,8)
No. of variables=4

1: Truth Table

2: K Map

3: Expression

4: Circuit

5: Out form exe

Page | 68
KARNAUGH MAP

Enter your choice: 2

9.6 SCREENSHOT 6

Page | 69
KARNAUGH MAP

9.7 SCREENSHOT 7

Page | 70
KARNAUGH MAP

I/P is
∑(3,4,5,6,7,8)
No. of variables=4

1: Truth Table

2: K Map

3: Expression

4: Circuit

5: Out form exe

Enter your choice: 3

9.8 SCREENSHOT 8

Page | 71
KARNAUGH MAP

I/P is
∑(3,4,5,6,7,8)
No. of variables=4

1: Truth Table

2: K Map

3: Expression

4: Circuit

5: Out form exe

K map Expression= A’B+A’CD+AB’C’D’

Simplified expression= A’B+A’CD+AB’C’D’

9.9 SCREENSHOT 9

Page | 72
KARNAUGH MAP

I/P is
∑(3,4,5,6,7,8)
No. of variables=4

1: Truth Table

2: K Map

3: Expression

4: Circuit

5: Out form exe

Enter your choice: 4

9.10 SCREENSHOT 10

Page | 73
KARNAUGH MAP

9.11 SCREENSHOT 11

Page | 74
KARNAUGH MAP

I/P is
∑(3,4,5,6,7,8)
No. of variables=4

1: Truth Table

2: K Map

3: Expression

4: Circuit

5: Out form exe

Enter your choice: 5

10. LIMITATION OF K-MAP

Page | 75
KARNAUGH MAP

1. The diagram becomes cluttered and hard to interpret if there are more
than four variables on an axis. This argues against the use of Karnaugh
maps for expressions with more than six variables. For such expressions, the
Quine-McCluskey algorithm, also called the method of prime implicants,
should be used.

2. This algorithm generally finds most of the optimal solutions quickly and
easily, but selecting the final prime implicates (after the essential ones are
chosen) may still require a brute force approach to get the optimal
combination (though this is generally far simpler than trying to brute force
the entire problem).

11. FUTURE ENHANCEMENTS

Page | 76
KARNAUGH MAP

a. Kmaps can be used in simple and systematic design of Full adder cell using
Kmap.

b. Kmap can be used in nano devices.It aware of fundamental abstracted logical


behaviors of future nano-devices, their functionality.

c. Karnaugh Maps can be used a great deal as "scratch pad" visualization in logical
circuit design and most of the information on the Web looks like it was written
for an audience of electrical engineers. Nonetheless, they're also very
useful for programmers for exactly the same reasons.

d. Karnaugh Maps are a more analytical tool. Let's add one more variable to
our list of conditions: "Accounts in force more than five years". This
would rule out the use of Venn Diagrams.

e. The Karnaugh calculator will be released as an open source project under the
Gnu Public License (or a creative commons equivalent), along with
instructions for use and an object description within the next few months.
Enhancements that would improve the calculator immensely would be a s
implification function that identifies groups in the K-Map and suggests a
simplified boolean function, and also an ability to show both K-Maps and
a simplified function in both sum-of-products and product-of-sums forms.
These functions should be relatively simple to add to the calculator as an
outgrowth of the necessary work on the GUI prior to release

12. REFERENCES

Page | 77
KARNAUGH MAP

1.1) “Switching Theory & Logic System Design” by M. Morris Mano.

1.2) “Let Us c” by Yashavant Kanetker

1.3) “Complete Reference through C” of T.M.H. Publication.

1.4) www.wikipedia.com

Page | 78

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy