Vous êtes sur la page 1sur 35

Department of Mechanical Engineering

NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Boolean Algebra
and
Karnaugh Maps

Boolean Algebra and K-maps Page 1 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Review of Boolean Algebra

In 1847, George Boole published the book, Mathematical


Analysis of Logic.
Thus Boolean Algebra come into being.
Found to be applicable for the formalization and
manipulation of logic expressions.
Applied to the design of digital circuits for present-day
computers.

Boolean Algebra and K-maps Page 2 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Binary Logic Fundamentals

Binary logic has only two states


TRUE (represented by 1, or ON, etc)
FALSE (represented by 0, or OFF, etc.
Basic Operators
Only three basic operators are required to derive any logic
expressions AND, OR and NOT

AND is normally denoted by the algebraic multiplication


symbol, e.g. ., or *.

OR is normally denoted by the algebraic addition symbol +.

NOT: For a logic function A, NOT(A) is denoted by A or A.


A is also called the complement of A.

Boolean Algebra and K-maps Page 3 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Basic logic gates

AND
C A B C is true if A and B are both true.

OR
A
B
C C A B C is true if either A or B or both are true.

NOT
CA C is true if A is not true, and vice-versa.

Boolean Algebra and K-maps Page 4 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Other common logic gates

NAND
C A B C is NOT of (A AND B).

NOR
C ( A B) C is NOT of (A OR B).

XOR
C A B AB A B
C is true if either A or B, but not both, are true.

Boolean Algebra and K-maps Page 5 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Truth Tables
The Truth Table for a given logic variable, gives the state of that
variable for all possible input combinations.
AND OR NAND NOR ExOR

A B C A B C AB C(A B) C(AB) C A B
FALSE FALSE FALSE FALSE TRUE TRUE FALSE
FALSE TRUE FALSE TRUE TRUE FALSE TRUE
TRUE FALSE FALSE TRUE TRUE FALSE TRUE
TRUE TRUE TRUE TRUE FALSE FALSE FALSE

AND OR NAND NOR ExOR


A B C A B CAB C(A B) C(AB) C A B
0 0 0 0 1 1 0
0 1 0 1 1 0 1
1 0 0 1 1 0 1
1 1 1 1 0 0 0
Boolean Algebra and K-maps Page 6 ME3242E Industrial Automation
Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Axioms
Commutative
(a + b) = (b + a) (a * b) = (b * a)
Associative Law
(a + b) + c = a + (b + c) (a * b) * c = a * (b * c)
Distributive Law
a * (b + c) = (a * b) + (a * c) a + (b * c) = (a + b) * (a + c)
(different from normal algebra)
Operation with 0 and 1
a+0=a a*1=a 0+0=0 0*1=0
0+1=1 0*0=0
a+1=1 a*0=0
1+1=1 1*1=1

Boolean Algebra and K-maps Page 7 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Duality Principle

Duality Principle
Any algebraic equality derived from the axioms of Boolean
algebra remains true when the operators OR and AND are
interchanged and the elements 0 and 1 are also
interchanged.
For example, a+1=1
a * 0 = 0 (dual)

Another example
a * (b + c) = (a * b) + (a * c)
a + (b * c) = (a + b) * (a + c) (dual)

Boolean Algebra and K-maps Page 8 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Axioms

Idempotent Theorem
a+a=a a * a = a (dual)

Law of Absorption
a*b+a=a (a + b) * a = a (dual)

Operation with Complement


a + a = 1 a * a = 0 (dual)
(a + b) * b = a * b a * b + b = a + b (dual)

Boolean Algebra and K-maps Page 9 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

DeMorgans Theorem
DeMorgans Theorem
( x y) x y ( x y z) x y z
( x y ) x y (dual) ( x y z ) x y z (dual)

Truth Table proof:


x y x+y (x + y)' X' Y' x' * y'
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0

Boolean Algebra and K-maps Page 10 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Min-terms
For a Boolean function of n variables, a product term in which each
of the n variables appears once (in either its complemented form or
uncomplemented form) is called a minterm. If there are n variables,
then there will be 2n minterms.

Examples:
Minterms for 2 variables: Minterms for 3 variables:

ab 00 abc abc 000 100


ab 01 abc abc 001 101
ab 10 abc abc 010 110
ab 11 abc abc 011 111

Corresponding binary
numbers
Boolean Algebra and K-maps Page 11 ME3242E Industrial Automation
Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Simplication: Sum-of-Products

A truth table for a Boolean function F gives


the value of F for all combinations of the Truth Table
inputs. xyz F
Given the truth table for a function F, the 000 0
function can be readily written as a sum-of-
minterms. 001 1
010 0
Example: F x y z xyz xyz
011 0
Often it is required to simplify this canonical
form into a sum-of-product (SOP) form for 100 0
easier implementation. This can be done 101 0
using Boolean algebra.
110 1
Example: F x y z xyz xyz 111 1
x y z xy ( z z )
x y z xy
Boolean Algebra and K-maps Page 12 ME3242E Industrial Automation
Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Karnaugh Maps
Limitation of Boolean algebra
Not easy to get to the simplest form of the expression
Needs skill and familiarity to do algebraic manipulation.
Karnaugh Maps
Graphical approach to representing Boolean functions.
Easier to get to the simplest form of the Boolean function
quickly
Structure of Karnaugh Maps or K-maps
The K-map has as many squares as there are minterms.
For a K-map of a Boolean function with n variables, there will
be 2n minterms and thus 2n squares in the K-map.
Each square of the K-map contains the value of the function
for that minterm condition.

Boolean Algebra and K-maps Page 13 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Drawing the K-Map

Start with one square as the


universe. X X
Each time a variable, say X , is
added, divide all the squares
in the universe into two halves
and label one half as X and
the other half as X .

Usually, up to 5 variables can be


added. Beyond that, it becomes a
little unwieldy.

Boolean Algebra and K-maps Page 14 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Two-variable K-Map
A
Single variable map 1 0

B 1 AB AB
Two-variable map by
0
adding a second variable. AB AB

Any two adjacent squares can


The minterms for each of
also be covered together. The
the four squares are as
resulting Boolean function will
shown.
then have one fewer variable
than a minterm. A
1 0
A
B 1

0
A

Boolean Algebra and K-maps Page 15 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Two-variable K-Map
A
1 0

B 1 AB AB
Two-variable map by
0
adding a second variable. AB AB

Any two adjacent squares can


The minterms for each of
also be covered together. The
the four squares are as
resulting Boolean function will
shown.
then have one fewer variable
than a minterm. A B
1 0

B 1
B
0

Boolean Algebra and K-maps Page 16 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Three-variable K-Map
A BC
A
Two- variable map AC: 10 11 01 00

B 1

Three-variable map by
0
adding a third variable.
C ABC
AB C
Any two(or four) adjacent
squares can also be covered
together. The resulting Boolean
BC
AC A
AC: 10 11 01 00
function will then have one (or
two) fewer variable than a B 1 A
minterm.
0

C
BC

Boolean Algebra and K-maps Page 17 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Four-variable K-Map
A A BC D
Three-variable map
B
Four-variable map by D
adding a fourth variable.
C
AB C D
Any two/four/8 adjacent squares
can be covered together. The
resulting Boolean function will A CD
then have one/two/three fewer
variable than a minterm. B
D
AC D
A
AC D C
CD

Boolean Algebra and K-maps Page 18 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Five-variable K-Map
A BC E
Four-variable map
B
Five-variable map by D
adding a fifth variable and
dividing all the squares C
into two.
E
AD
Any 2/4/8/16 adjacent squares E A
can be covered together. A B
square in the top figure is B
considered adjacent to the D
corresponding square in the AD E
bottom figure.
C

Boolean Algebra and K-maps Page 19 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Boolean simplification using K-Maps

1) Draw the K-map and fill all the squares with the
required value of the function.
2) Cover all the 1s. Each cover will have 2n squares,
n = 0, 1, 2,
3) Make each cover as large as possible by covering
any appropriate adjacent squares containing 1 but
not including any square with 0.
4) Use a minimum number of covers.
5) The Boolean function is then the sum of the Boolean
expressions for all the covers.

Boolean Algebra and K-maps Page 20 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Boolean simplification using K-Maps


Previous Example:
Three-variable K-map
Truth Table
xyz F x yz
000 0
001 1 F x y z xy 0 0 1 0
010 0
011 0
y 1 10 0
100 0
xy z
101 0
110 1
111 1 F x y z xy

Boolean Algebra and K-maps Page 21 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

4-variable Example

DCBA is 4-bit binary number with D as the most significant


bit.
A Boolean variable, Y, is to represent the condition when
DCBA is non-zero and divisible by 2.
Draw the K-map for Y and obtain its simplified expression.

Solution:
A 4-bit binary number will have the range of 0~15.
Y will be true for the binary numbers 2, 4, 6, 8,10, 12 and
14.

Boolean Algebra and K-maps Page 22 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

4-variables Example (cont)

Exercise: Obtain the expression for Y


Four-variable K-map
Truth table for Y
A
DCBA Y DCBA Y
0000 0 1000 1 B
0001 0 1001 0 D
0010 1 1010 1
0011 0 1011 0
C
0100 1 1100 1
0101 0 1101 0
0110 1 1110 1
0111 0 1111 0

Boolean Algebra and K-maps Page 23 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

4-variables Example (cont)

Truth table for Y


Four-variable K-map
DCBA Y DCBA Y
A AB
0000 0 1000 1
0001 0 1001 0 0 0 1 1
B 0 0
0010 1 1010 1 1 1 D
0011 0 1011 0 0 0 1 1
0100 1 1100 1 0 0 1 0 AD
0101 0 1101 0 C AC
0110 1 1110 1
0111 0 1111 0
Y A B A D AC

Boolean Algebra and K-maps Page 24 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Dont Care States


If there are n binary inputs and if all the inputs can take either of
their two states (0 or 1), there will be 2n possible unique states, the
same as the number of minterms.
In many applications, there are constraints on the inputs and some
of the input combinations will never occur. For these input
combinations which we know will never occur, then for the circuit
we design, we really dont care what the output will be.
In the truth tables and in the K-maps, we indicate dont care
states for these input combinations.
Often, a - or x is used for a dont care state.
When covering all the 1s in a K-map, we can choose to cover, or
not to cover, the dont cares. This flexibility can result in a simpler
Boolean expression.

Boolean Algebra and K-maps Page 25 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Dont Care Example

Problem: Write simple


Boolean expressions for
segment g of the BCD to 7
segment decoder.

Boolean Algebra and K-maps Page 26 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Dont Care Example (Cont)

K-map for segment g

B
D

Boolean Algebra and K-maps Page 27 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Dont Care Example (Cont)

K-map for segment g

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

g D B C BC A B

Boolean Algebra and K-maps Page 28 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

5-variable K-Maps

Problem: The K-map for F is shown.


Obtain the Boolean expression for F.

K-map for F

Boolean Algebra and K-maps Page 29 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

5-variable K-Maps
BC
Problem: The K-map for F is shown.
Obtain the Boolean expression for F.
BD

AB
F A B B C B D A C D

Reviewing note that all the 1s covered


by the red cover, or B C , are all covered by
AC D other covers. This cover can thus be
K-map for F removed.

Boolean Algebra and K-maps Page 30 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

5-variable K-Maps

Problem: The K-map for F is shown.


Obtain the Boolean expression for F.
BD

AB
F A B B D A C D

Reviewing note that all the 1s covered


by the red cover, or B C , are all covered by
AC D other covers. This cover can thus be
K-map for F removed.

Boolean Algebra and K-maps Page 31 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Labelling sides of K-Maps

When the sides of a K-map is to be labelled, care must be to


ensure that this is done properly. Otherwise the Boolean
expression may not be obtained easily.

Example of the previously-obtained 4-variable K-map


A AC
10110100
B 10

D 11
BD
01
00
C
4-variable K-map With sides labelled

Boolean Algebra and K-maps Page 32 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Labelling sides of K-Maps


For a side of a K-map representing 2 variables, there are
only 4 suitable sequence of labelling. All others will give rise
to problems when obtaining the final Boolean expression.
4 suitable sequences

A A A
C C C C

In a suitable sequence, when


Unsuitable moving from one square to an
sequence adjacent square, only one
examples C A variable should change.

Boolean Algebra and K-maps Page 33 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

Labelling sides of 5-variable K-Maps


AC BD C E
A 10110100
101
B
D 111
A DE
011 BD C

E C 001
BDE
E A 100
110 BD C E
B AD
D 010
ADE
000
C Sequence of BD the same for both top and bottom half.
Any cover in the top half can be combined with the same
cover in the bottom half, eliminating variable E.

Boolean Algebra and K-maps Page 34 ME3242E Industrial Automation


Department of Mechanical Engineering
NATI O NAL U N I V E R S ITY O F SI N GAPO R E

End

Boolean Algebra and K-maps Page 35 ME3242E Industrial Automation

Vous aimerez peut-être aussi