You are on page 1of 57

Industrial Electronics I

IE501

Lecture 7b

Semester 1, 2020-21
Topics Covered
This lecture will:
• Cover Karnaugh maps.

Semester 1, 2020-21 IE501, Lecture 7b 2


Reading For This Week
• M. Morris Mano & Charles Kime, Logic and Computer Design
Fundamentals, 4th Ed., USA: Prentice Hall
– Read Chapter 2 on Simplifying Logic circuits & Karnaugh Maps.

• Thomas Floyd, Digital Fundamentals : A Systems Approach, 9th Ed., USA:


Prentice Hall.
– Read chapter 4 on logic simplification & Karnaugh maps.

• Kuphaldt, Tony R. (2014). Lessons In Electric Circuits, Vol IV —Digital.


– Read Chapter 7 on Boolean algebra.
– http://www.ibiblio.org/kuphaldt/electricCircuits/Digital/DIGI_3.html
– This is a free online book available at the above link. Also available for download
as a pdf file.
– See also the associated website: http://www.allaboutcircuits.com/

Semester 1, 2020-21 IE501, Lecture 7b 3


Boolean Function Optimization
• Goal: To obtain the simplest implementation for a
given function
• Boolean Algebra and graphical techniques are tools to
minimize (optimize) implementation of logic
functions.
• Some important questions:
– What is the “best” (most minimized) expression of a logic
function?
– Do we know when we have a minimum expression?
• Introduce a graphical technique using Karnaugh maps
(K-maps, for short)

Semester 1, 2020-21 IE501, Lecture 7b 4


Karnaugh Map (K-map)
• A K-map is a collection of cells
– Each cell represents a minterm or maxterm
– The collection of cells is a graphical representation of a Boolean
function
– Adjacent cells differ in the value of one variable
– Alternative algebraic expressions for the same function are
derived by recognizing patterns of cells
• The K-map can be viewed as
– A reorganized version of the truth table
– A topologically-warped Venn diagram, as used to visualize sets in
algebra of sets (the Kuphaldt & the Floyd books both reference
Venn diagrams as a way of understanding Boolean logic)

Semester 1, 2020-21 IE501, Lecture 7b 5


Some Uses of K-Maps
• Provide a means for:
– Finding optimum or near optimum
• SOP and POS expressions, and
• two-level AND/OR and OR/AND circuit
implementations
for functions with small numbers of variables
– Visualizing concepts related to manipulating
Boolean expressions, and
– Demonstrating concepts used by computer-
aided design programs to simplify large circuits

Semester 1, 2020-21 IE501, Lecture 7b 6


K-Map and Truth Tables
• The K-Map is just a different form of the truth table.
• Example – Two variable function:
– a, b, c and d are used in the truth table below to illustrate where
in the K-map the outputs of the function F(x, y), are mapped.
Truth Table
K-Map
i x y F(x, y) F y
0 0 0 a x 0 1
0 1
1 0 1 b
0 a b
2 3
2 1 0 c 1 c d
3 1 1 d
Semester 1, 2020-21 IE501, Lecture 7b 7
Semester 1, 2020-21 IE501, Lecture 7b 8
Adjacency in Two Variable Maps
• A 2-variable Karnaugh Map:
– Note that minterm m0 and minterm m1 F y=0 y=1
are “adjacent” and differ in the y
variable. m0 m1
– Similarly, minterm m0 and minterm m2 x=0
xy xy
differ in the x variable. m2 m3
– Also, m1 and m3 differ in the x variable. x = 1
xy x y
– Finally, m2 and m3 differ in the y variable.
• Thus, 2 “adjacent” cells share a side and differ in a
single variable (with the variable in one cell & its
complement in the other).
– Therefore m0 and m3 are NOT adjacent.
– And m1 and m2 are NOT adjacent.
Semester 1, 2020-21 IE501, Lecture 7b 9
Combining Cells on 2-Variable Maps
• By combining cells, we reduce number of literals in a
product term
• On a 2-variable K-Map:
– One cell represents a minterm with two variables
– Two adjacent cells represent a simplified product term
with one variable
– Four “adjacent” cells is the function of all ones (no
variables) = 1.

Semester 1, 2020-21 IE501, Lecture 7b 10


Example 1: Combining 2-Variable Map Cells
F y
•  Example: F(x, y) = x x 0 1
0 1
0 0 0
2 3
1 1 1
x
• The two adjacent cells containing 1’s can be
combined using rule 6: :

F ( x , y )  x y  xy  x( y  y )  x

1
Semester 1, 2020-21 IE501, Lecture 7b 11
Semester 1, 2020-21 IE501, Lecture 7b 12
Example 2: Combining 2-Variable Map Cells
•  Example: G(x, y) = x + y y
G y
x 0 1
0 1
0 0 1
2 3
1 1 1
x
• For G(x, y), two pairs of adjacent cells containing 1’s can
be combined using rule 6:

G (x, y ) = x y + x y + x y = x y + x y + x y + x y

( )(
Duplicate x y using = x y + x y + x y + x y = x + y
rule 5: A + A = A
)
to get: xy + xy = xy
Semester 1, 2020-21 IE501, Lecture 7b 13
Combining Cells on 2-Variable Maps
• Example: G(x, y) = x + y y
G y
x 0 1
0 1
0 0 1
2 3
1 1 1
x
• NOTE: any border contained inside a group or loop means that the
variable that changes across that border is eliminated according to rule 6.
• For the group containing minterms 2 & 3, the variable that changes
across the border is y. ⸫ the product term is simply x.
• For the group containing minterms 1 & 3, the variable that changes
across the border is x. ⸫ the product term is simply y.

Semester 1, 2020-21 IE501, Lecture 7b 14


Semester 1, 2020-21 IE501, Lecture 7b 15
Three Variable Maps
• A three-variable K-map:
yz=00 yz=01 yz=11 yz=10
x=0 m0 m1 m3 m2
x=1 m4 m5 m7 m6
• Where each minterm corresponds to the product terms:
yz=00 yz=01 yz=11 yz=10
x y z x y z x y z x y z
x=0
x y z
x=1 x y z x y z x y z

• Note that if the binary value for an index differs in one bit
position, the minterms are adjacent on the K-Map

Semester 1, 2020-21 IE501, Lecture 7b 16


Three Variable Maps
F
• Alternate construction – this
is what is used in the Floyd z=0 z=1
book. xy=00 m0 m1

xy=01 m2 m3
• Note: If a problem provides a
K-map in a different format xy=11 m6 m7
than you are used to, simply xy=10 m4 m5
redraw it in the format you
prefer and solve the problem.

Semester 1, 2020-21 IE501, Lecture 7b 17


Alternative Map Labeling
• Map use largely involves:
– Entering values into the map, and
– Reading off product terms from the map.
• Alternate labelings are useful, e.g.:

y y yz y
00 01 11 10 x 00 01 11 10
0 1 3 2
x 0 00 1 3 2

4 7 6
x 1
5
x 14 5 7 6

z z z z
Semester 1, 2020-21 IE501, Lecture 7b 18
Example Functions
•• By
  convention, we represent the minterms of F by a "1" in the
map and leave the maxterms of F (the “0”s) blank. Recall: the
maxterms of F = minterms of = the “0”s.
• Example: yz y
F(x, y, z)  m(2,3,4,5) x 00 01 11 10
0 1 3 2
0 1 1
4 5 7 6
x1 1 1
• Example:
G(x, y, z)  m(3,4,6,7) z
• NOTE: Learn the locations of the yz y
x 00 01 11 10
8 indices based on the variable 0 1 3 2
order shown (x, most significant 0 1
and z, least significant) on the x1 41 5 7
1
6
1
map boundaries
Semester 1, 2020-21 IE501, Lecture 7b
z 19
Semester 1, 2020-21 IE501, Lecture 7b 22
Semester 1, 2020-21 IE501, Lecture 7b 23
Semester 1, 2020-21 IE501, Lecture 7b 24
Combining Cells on 3-variable Maps
• By combining cells, we reduce number of literals in a
product term
• On a 3-variable K-Map:
– One cell represents a minterm with three variables
– Two adjacent cells represent a simplified product term
with two variables
– Four “adjacent” cells represent a simplified product
term with one variable
– Eight “adjacent” cells is the function of all ones (no
variables) = 1.

Semester 1, 2020-21 IE501, Lecture 7b 25


Example: Combining Cells
y
•• Example:
  Let 00 01 11 10
0 1 3 2
F(x, y, z)   m (2,3,6,7) 0 1 1
x 14 5 7
1
6
1
z
• Applying rule 6 () three times:
F ( x, y, z ) = x y z + x y z + x y z + x y z
= y z+ yz
=y
• Thus the four terms that form a 2 × 2 square correspond
to the term "y".
Semester 1, 2020-21 IE501, Lecture 7b 26
SOP K-Mapping Rules for Combining Cells
• In SOP maps, only 1s can be inside a group or loop. All 1s MUST be in a group/loop
• No diagonal groups/loops allowed.
• The number of cells in each group or loop must be a power of 2: (i.e. 1, 2, 4, 8, etc.
cells).
• Each group or loop should be as big as possible, containing the most cells possible.
This allows the most variables to be eliminated.
• Groups or loops can overlap – but total overlap not is allowed (see next point).
• Every group or loop MUST contain at least one 1 that is NOT inside any other loop.
• Create the smallest possible number of biggest groups or loops THAT COVERS ALL
THE 1s (this yields the fewest terms in the simplified equation).
• The leftmost & rightmost cells are adjacent. Imagine the map wrapping around like a
cylinder, so that the rightmost cell edges meet the leftmost cell edges (called
topological warping). See next slide.
• Credit for summary of above Karnaugh mapping rules: D. Belton, April 1998,
http://www.ee.surrey.ac.uk/Projects/Labview/minimisation/karrules.html
Semester 1, 2020-21 IE501, Lecture 7b 27
Three-Variable Maps
• 3-variable K-map that shows edge adjacencies,
which allow groups or loops to wrap around:
 K-map  Cylinder

y
0 1 3 2

x 4 5 7 6

Semester 1, 2020-21 IE501, Lecture 7b 28


Three-Variable Maps
• Example Shapes of 2-cell Groups:
00 01 11
y 10
0 1 3 2
0

4 5 7 6
x1
z
• Read off the product terms for the groups shown
Semester 1, 2020-21 IE501, Lecture 7b 29
Three-Variable Maps
• Example Shapes of 4-cell Groups:
00 01 11
y 10
0 1 3 2
0

4 5 7 6
x1
z

• Read off the product terms for the groups shown


Semester 1, 2020-21 IE501, Lecture 7b 30
Simplifying with SOP K-Maps
• Draw & label the K-map as shown in earlier slides
• Group/loop adjacent cells containing 1s (the minterms)
using the rules on the previous slide
– Remember, choose the “smallest number of biggest loops”
• Eliminate variables that change across borders in each loop
• Create a PRODUCT term from the remaining variables left
in each loop. Remember:
– Where variable = 1 write the variable in the product term
– Where variable = 0 write the complement in the product term
• SUM (or OR) product terms together to create the
simplified sum of products (SOP) expression.

Semester 1, 2020-21 IE501, Lecture 7b 31


Example: Simplifying with 3-Variable Map
 K-Maps can be used to simplify Boolean functions by
systematic methods. Terms are selected to cover the
“1s” on SOP maps.
 Example: Simplify F(x, y, z)  m(1,2,3,5,7)
z y 𝐱𝐲
 

00 01 11 10

0 1 1 1
x 1 1 1

z
F(x, y, z) = z + x y
Semester 1, 2020-21 IE501, Lecture 7b 32
Another Example: 3-Variable Map Simplification
• Use a K-map to find an optimum SOP equation
for F(X, Y, Z)  m(0,1,2,4,6,7)

Semester 1, 2020-21 IE501, Lecture 7b 33


Four Variable Maps
 Map and location of minterms:
YZ Y
WX 00 01 11 10
0 1 3 2
00
4 5 7 6
01
Variable X
12 13 15 14
Order: WXYZ 11
W
Replace with 8 9 11 10
10
any other set of
variables in the
same order. Z
E.g.: ABCD
Semester 1, 2020-21 IE501, Lecture 7b 34
Four Variable Terms
 Four variable maps can have groups
corresponding to:
• A single 1 (i.e. Minterm) = 4 variables,
• Two 1s = 3 variables,
• Four 1s = 2 variables
• Eight 1s = 1 variable,
• Sixteen 1s = zero variables (i.e. constant "1")

Semester 1, 2020-21 IE501, Lecture 7b 35


Four-Variable Maps
• 4-variable K-map that shows edge adjacencies,
which allow groups or loops to wrap around:
 Side to side Top to bottom

Credit: http://www.learnabout-electronics.org/Digital/dig24.php
Image location: http://www.learnabout-electronics.org/Digital/images/Karnaugh-groups-1.jpg
Semester 1, 2020-21 IE501, Lecture 7b 36
Four-Variable Maps
• This top-bottom AND side-side wrap around turns the
4-variable K-map into a torus or doughnut. This makes
the 4 corners adjacent to each other:
 Torus (doughnut shape) K-map 

"Karnaugh6" by Jochen Burghardt - Own work. Licensed under CC BY-SA 3.0 via Commons -
https://commons.wikimedia.org/wiki/File:Karnaugh6.gif#/media/File:Karnaugh6.gif
Semester 1, 2020-21 IE501, Lecture 7b 37
Four-Variable Maps
• Example Shapes of Groups:
YZ Y
WX 00 01 11 10
0 1 3 2
00
4 5 7 6
01
X
12 13 15 14
11
W
8 9 11 10
10

Semester 1, 2020-21 IE501, Lecture 7b 38


Four-Variable Maps
Note: borders in
• Example Shapes of Groups: black in order to
highlight groups (or
YZ Y loops in colour.
WX 00 01 11 10
0 1 3 2
00
4 5 7 6
01
X
12 13 15 14
11
W
8 9 11 10
10

Z
Semester 1, 2020-21 IE501, Lecture 7b 39
Four-Variable Map Simplification
Simplify:
 

YZ Y
WX 00 01 11 10
0 1 3 2
00
4 5 7 6
01
X
12 13 15 14
11
W
8 9 11 10
10

Z
Semester 1, 2020-21 IE501, Lecture 7b 40
Four-Variable Map Simplification
• Simplify:
F(A, B, C, D)  m(0,2,3,8,9,10,11,12, 13,14,15)
CD C
00 01 11 10
AB
00

01
B
11
A
10

D
Semester 1, 2020-21 IE501, Lecture 7b 41
Selection Example with Multiple Possible Loops
• One approach is to find ALL loops first.
• Next, select the “essential” loops that cover 1s that no other loops can cover
• Then choose the minimum number of remaining loops that still cover all 1s,
and remove the redundant loops.
BD
CD
CD C CD C
00 01 11 10 00 01 11 10
AB BD AB
00 1 1 1 00

BD 01 1 1 BD 01
B B
11 1 1 11
A A
10 1 1 1 1 10

AB
D D
AD Minterms covered by single loop
Semester 1, 2020-21 BC IE501, Lecture 7b 42
Selection Example with Multiple Possible Loops
• Another example: Simplify F(A, B, C, D) given on the
K-map.
Selected Essential
C C

1 1 1 1

1 1 1 1 1 1 1 1
B B
1 1
A A
1 1 1 1

D D

Semester 1, 2020-21 IE501, Lecture 7b 43


Practice Example with Multiple Possible Loops
Simplify:
 

Semester 1, 2020-21 IE501, Lecture 7b 44


Practice Example with Multiple Possible Loops
• Simplify:
G(A, B, C, D)  m(0,2,3,4,7,12,13,14,15)
– Hint: There are seven loops!
CD C
00 01 11 10
AB
00

01
B
11
A
10

D
Semester 1, 2020-21 IE501, Lecture 7b 45
Don't Cares in K-Maps
• Sometimes a K-map contains entries where:
– the input values for the minterm will never occur, or
– The output value for the minterm will not be used
• In these cases, the output value need not be defined
• Instead, the output value is defined as a “don't care”
• By placing “don't cares” (as “X” entries) in the K-map, the logic circuit may
simplified further.
• Because we “don’t care”, each don’t care “X” entry may be treated as either
a 1 or 0 value on the resulting map and either included or excluded from the
loops, depending on what is needed to create the biggest loops. Recall: the
bigger the loop the more variables eliminated, & the simpler the solution.
• For example, an “X” may take on value “0” in an SOP solution and value
“1” in a POS solution, or vice-versa.
• Any minterm with value “X” does not need to be covered by a loop.

Semester 1, 2020-21 IE501, Lecture 7b 47


Selection Example with Don't Cares
• Simplify F(A, B, C, D) given on the K-map.
Selected Essential
C C

1 x 1 x

1 x x 1 1 x x 1
B B
x x
A A
1 1 x 1 1 x

D D

Semester 1, 2020-21 IE501, Lecture 7b 48


Don't Cares in K-Maps

Example: A 4-input logic function having the binary


codes for the BCD digits as its inputs.
• Only the codes for 010 through 910 are used.
• The six codes for 1010 through 1510, (1010 through
1111) never occur.
• So the output values for these codes are labeled “X”
to represent “don’t cares.”

Semester 1, 2020-21 IE501, Lecture 7b 49


Example 1: BCD “5 or More”

• The map below gives a function F1(w,x,y,z) with BCD inputs.


• F1 = 1 when the input combinations = 510 or more. With don't
cares used for the 6 non-BCD combinations, we get this:

yz y
wx 00 01 11 10
00 00 01 03 02 F1(w,x,y,z) = w + x z + x y
01 04 15 17 16 Don’t cares are treated as “1s” (i.e. X 
x
1).
w
11 X12 X13 X15 X14 F2(w, x, y, z) = w x z + w x y + w x y
10 1 8 1 9 X11 X10 For F2 the don't cares are treated as “0s”
z (i.e. X  0), & not included in loops.
F1 is much simpler than F2 where the “don't cares” are not used
Semester 1, 2020-21 IE501, Lecture 7b 50
Product of Sums (POS) K-Maps

• How do we draw & use the K-map to produce a


simplified (or optimum) Product of Sums (POS)
solution?

Semester 1, 2020-21 IE501, Lecture 7b 51


Product of Sums (POS) K-Maps
• Draw the POS K-map the same way as you do the SOP K-map. See
next slide on labeling POS K-maps
• Group/loop adjacent cells containing 0s (the maxterms).
– Use the same rules as SOP K-maps (see earlier slide), but replace “1s” with “0s”
– Remember, select the “smallest number of biggest loops”
• Eliminate variables that change across borders in each loop (like the
SOP K-maps)
• Create a SUM term from the remaining variables in each loop.
Remember, for POS:
– Where variable = 0 write the variable in the sum term
– Where variable = 1 write the complement in the sum term
• Multiply (or AND) sum terms together to create the simplified product
of sums (POS) expression.
Semester 1, 2020-21 IE501, Lecture 7b 52
Product of Sums K-Maps
• Note the POS labeling is opposite of SOP:
– Where the variable = 0, label rows/columns with the variable
– Where the variable = 1, label rows/columns with the complement
YZ  𝒀  𝒀
WX 00 01 11 10
0 1 3 2
 𝑿
00
 𝑾
4 5 7 6
01
 𝑿
12 13 15 14
11
 𝑾
8 9 11 10
10  𝑿

 𝒁  𝒁  𝒁
Semester 1, 2020-21 IE501, Lecture 7b 53
Product of Sums Example
Find the optimum POS solution for:
 𝐹 ( 𝑊 , 𝑋 , 𝑌 , 𝑍 ) =∏ (0 , 2 ,5 , 7 , 8 ,10)∙ ∏ (1 , 4 ,6)
𝑀 𝐷

YZ  𝒀  𝒀
WX 00 01 11 10
0 1 3 2
 𝑿
00
 𝑾
4 5 7 6
01
 𝑿
12 13 15 14
11
 𝑾
8 9 11 10
10  𝑿

 𝒁  𝒁  𝒁
Semester 1, 2020-21 IE501, Lecture 7b 54
Product of Sums Example
•  Find the optimum POS solution for:
F(A,B,C,D)  m (3,9,11,12 ,13,14,15) 

 d
(1,4,6)

– Hint: Use , find SOP solution and complement it


to get the POS result.
• NOTE: when complementing F, the “don’t
cares” remain the same (i.e. the complement
of a don’t care is a don’t care!).

Semester 1, 2020-21 IE501, Lecture 7b 55


Summary
•• The
  Karnaugh map (K-map) provides a systematic (and
graphical) approach to simplifying combinational logic with a
small number of input variables.
• Minterms (or maxterms) can be combined when they differ in
only one variable (i.e. they are adjacent on a K-map)
• E.g.:
• Deriving a minimum SOP or POS form is accomplished by
eliminating variables that change value within groups/loops of
adjacent minterms or maxterms. The resulting combination of
simplified terms is the minimum SOP (or POS) form.
• The K-map illustrates this combination graphically

Semester 1, 2020-21 IE501, Lecture 7b 56


Questions/Comments/Discussion

Semester 1, 2020-21 IE501, Lecture 7b 57


Terms of Use
• All (or portions) of this material © 2008 by Pearson
Education, Inc.
• Permission is given to incorporate this material or adaptations
thereof into classroom presentations and handouts to
instructors in courses adopting the latest edition of Logic and
Computer Design Fundamentals as the course textbook.
• These materials or adaptations thereof are not to be sold or
otherwise offered for consideration.
• This Terms of Use slide or page is to be included within the
original materials or any adaptations thereof.

Semester 1, 2020-21 IE501, Lecture 7b 58

You might also like