ENGIN112 - lecture 2

Lecture 7
Minimization with Karnaugh Maps
Overview
°K-maps: an alternate approach to representing
Boolean functions
°K-map representation can be used to minimize
Boolean functions
°Easy conversion from truth table to K-map to
minimized SOP representation.
°Simple rules (steps) used to perform minimization
°Leads to minimized SOP representation.
• Much faster and more more efficient than previous minimization
techniques with Boolean algebra.
Karnaugh maps
° Alternate way of representing Boolean function
• All rows of truth table represented with a square
• Each square represents a minterm
° Easy to convert between truth table, K-map, and
SOP
• Unoptimized form: number of 1’s in K-map equals number of
minterms (products) in SOP
• Optimized form: reduced number of minterms
x
y
0
y
1
0 x’y’ x’y
x
1 xy’ xy
F = Σ(m0,m1) = x’y + x’y’
x
y
0
1
0
1
1
1
0
0
x
y
F
0
0
1
0
1
1
1
0
0
1
1
0
Boolean Cubes and Boolean Functions
Boolean Cubes and Boolean Functions
° A Boolean n-cube uniquely represents
a Boolean function of n variables if
each vertex is assigned a 1 (marked) or
0 (unmarked)
° Each vertex of the n-cube represents a
minterm (a row in the truth table)
Map Representation
° Complexity of digital circuit (gate
count) / complexity of algebraic
expression (literal count).
° A function’s truth-table representation
is unique; its algebraic expression is
not. Simplification by algebraic means
is awkward (from algorithmic point of
view).
° A Karnaugh map (K-map) is an array of
squares each representing one
minterm. Simplification by the map
method is straightforward.
Boolean cubes and corresponding Karnaugh maps
• Each K-map defines a unique
Boolean function
• A Boolean function can be
represented by a truth table, a
Boolean expression, an n-cube, or a
map.
K-Maps
Ex: How do you transform a K-map into a truth
table? Is it unique? How do you transform a K-map
into an n-cube? Is it unique?
Two- and Three-Variable Maps
K-Maps Cont………
• Minterms are arranged in the Gray-code sequence (Why?)
• Any 2 (horizontally or vertically) adjacent squares differ by
exactly 1 variable, which is complemented in one square
and uncomplemented in the other.
• Any 2 minterms in adjacent squares that are ORed together
will cause a removal of the different variable, e.g., m5 +m7
= xy’z + xyz = xz(y’ + y) = xz, because y + y’ = 1.
K-Maps Cont………
°One square) a minterm of 4 literals.
°Two adjacent squares) a term of 3 literals.
°Four adjacent squares)a term of 2 literals.
°Eight adjacent squares) a term of 1 literal.
°Sixteen adjacent squares)the constant ‘1’.
K-Maps Cont………
EX: Show the region in the K-map that is represented
by X’Z’
Flat and on a Torus to Show Adjacencies
K-Maps Cont………
Ex: Simplify the Boolean function F(W,X, Y, Z) =å (0,1, 2, 4, 5, 6,8, 9,12,13,14)
F =Y’ + W’Z’ + XZ’
K-Maps Cont………
°Simplify the Boolean function F = A’B’C’ + B’CD’ +
AB’C’ + A’BCD’.
F = B’D’ + B’C’ + A’CD’
K-Maps Cont………
Five-Variable Maps
• Imagine that the 2 maps are superimposed on one another.
• It is possible to construct a 6-variable map with four 4-variable
maps by following a similar procedure.
• Maps of 6 or more variables are hard to read, and thus are
impractical.
• Variable-entered maps (VEMs); (2) CAD programs.
• Any 2k adjacent squares, k = 0, 1,……, n, in an n-variable map
represent an area that gives a product term of n - k literals.
Simplification Using K-Maps
°The complement of a function is represented in the
map by the squares not marked by 1s (they usually
are marked by 0s).
The complement of f’ gives f in pos.
Simplification Using K-Maps
Ex: Simplify the following function in sop & pos:
• Mark the map with 1s and 0s according to the function.
• Use the 1s to determine the EPIs of f, which immediately
give the sop form:
• Use the 0s to determine the EPIs of f’, and complement it to
give the pos form
Implicants
°Implicants with 2 1s
• Prime Implicants
A’D
BD’
A’B
• Essential Prime Implicants
A’D
BD’
with 4 1s
Simplification of Boolean Functions
Multi-Output Minimization Using Maps
°Identify all possible PIs that cover each implicated
minterms in each output expression, and search for
a minimal cover by using shared terms
°The Quine-McCluskey method also can be
extended for this purpose
Multi-Output Minimization Using Maps
Simplification of multiple output functions
XOR & XNOR Patterns on the Map
°Inspect the K-map to detect XOR/XNOR patterns:
• Kitty-corner adjacencies;
• Offset adjacencies.
XOR & XNOR Patterns on the Map
offset adjacencies
XOR & XNOR Patterns on the Map
Kitty-corner
Karnaugh Maps
°A Karnaugh map is a graphical tool for assisting in the
general simplification procedure.
°Two variable maps.
B0 1
A
00 1
F=AB +A’B
11 0
B0 1
A
00 1
11 1
F=AB +AB +AB 
°Three variable maps.
BC
00 01 11 10
A
00 1 0 1
11 1 1 1
+
A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
C
0
1
0
1
0
1
0
1
F
0
1
1
0
1
1
1
1
F=AB’C’ +AB C +ABC +ABC  + A’B’C + A’BC’
Boolean function simplification
Ex: Simplify the Boolean function
x
0
0
0
0
1
1
1
1
y
0
0
1
1
0
0
1
1
z
0
1
0
1
0
1
0
1
F
0
0
1
1
1
1
0
0
Map of the example is
Boolean function simplification
Ex: Simplify the Boolean function
Map of the example is
Boolean function simplification
Ex:Let the Boolean function be
F = AC + AB + ABC + BC
F = AC(B + B) + AB(C + C) + ABC + BC(A + A)
F = ABC + ABC + ABC + ABC + ABC + ABC + ABC
F = ABC + ABC + ABC + ABC + ABC + ABC + ABC
F = ABC + ABC + ABC + ABC + ABC
A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
C
0
1
0
1
0
1
0
1
F
0ABC
1 ABC
1 ABC
1 ABC
0 ABC
1 ABC
0ABC
1ABC
m0
m1
m2
m3
m4
m5
m6
m7
Rules for K-Maps
 We can reduce functions by circling 1’s in the K-map
 Each circle represents minterm reduction
 Following circling, we can deduce minimized and-or
form.
Rules to consider
Every cell containing a 1 must be included at least
once.
The largest possible “power of 2 rectangle” must be
enclosed.
The 1’s must be enclosed in the smallest possible
number of rectangles.
Example
Karnaugh Maps
°A Karnaugh map is a graphical tool for assisting in the
general simplification procedure.
°Two variable maps.
B0 1
A
00 1
F=AB +A’B
11 0
B0 1
A
00 1
11 1
F=AB +AB +AB 
F=A+B
°Three variable maps.
BC
00 01 11 10
A
00 1 0 1
1 1 1 1 1 F=A+B C +BC 
F=AB’C’ +AB C +ABC +ABC  + A’B’C + A’BC’
Karnaugh maps
°Numbering scheme based on Gray–code
• e.g., 00, 01, 11, 10
• Only a single bit changes in code for adjacent map cells
• This is necessary to observe the variable transitions
C
00
0
0
1
1
0
0
1
1
G(A,B,C) = A
C 1
B
B
A
C
1
0
0
1
0
0
1
1
B
11
01
0
A
C
AB
F(A,B,C) =
m(0,4,5,7) = AC + B’C’
A
10
More Karnaugh Map Examples
°Examples
b
a
0 1
0 0 1
1 0 1
f=a
ab
c
00 01 11 10
0 0 0 1 0
1 0 1 1 1
cout = ab + bc + ac
a
b
0 1
0 1 1
1 0 0
g = b'
ab
c
00 01 11 10
0 0 0 1 1
1 0 0 1 1
f=a
1. Circle the largest groups possible.
2. Group dimensions must be a power of 2.
3. Remember what circling means!
Application of Karnaugh Maps: The One-bit Adder
Cin
A
Adder
S
B
Cout
+
A
0
0
0
0
1
1
1
1
B Cin S
0 0
0
0 1
1
1 0
1
1 1
0
0 0
1
0 1
0
1 0
0
1 1
1
Cout
0
0
0
1
0
1
1
1
How to use a Karnaugh
Map instead of the
Algebraic simplification?
S = A’B’Cin + A’BCin’ + A’BCin + ABCin
Cout = A’BCin + A B’Cin + ABCin’ + ABCin
= A’BCin + ABCin + AB’Cin + ABCin + ABCin’ + ABCin
= (A’ + A)BCin + (B’ + B)ACin + (Cin’ + Cin)AB
= 1·BCin + 1· ACin + 1· AB
= BCin + ACin + AB
Application of Karnaugh Maps: The One-bit Adder
Cin
A
0
0
0
0
1
1
1
1
A
Adder
S
B
Cout
B
A
B Cin S
0 0
0
0 1
1
1 0
1
1 1
0
0 0
1
0 1
0
1 0
0
1 1
1
Cout
0
0
0
1
0
1
1
1
+
0
0
1
0
0
1
1
1
Cin
Karnaugh Map for Cout
Now we have to cover all the 1s in the
Karnaugh Map using the largest
rectangles and as few rectangles
as we can.
Application of Karnaugh Maps: The One-bit Adder
Cin
A
0
0
0
0
1
1
1
1
A
Adder
S
B
Cout
B
A
B Cin S
0 0
0
0 1
1
1 0
1
1 1
0
0 0
1
0 1
0
1 0
0
1 1
1
Cout
0
0
0
1
0
1
1
1
+
0
0
1
0
0
1
1
1
Cin
Karnaugh Map for Cout
Now we have to cover all the 1s in the
Karnaugh Map using the largest
rectangles and as few rectangles
as we can.
Cout = ACin
Application of Karnaugh Maps: The One-bit Adder
Cin
A
0
0
0
0
1
1
1
1
A
Adder
S
B
Cout
B
A
B Cin S
0 0
0
0 1
1
1 0
1
1 1
0
0 0
1
0 1
0
1 0
0
1 1
1
Cout
0
0
0
1
0
1
1
1
+
0
0
1
0
0
1
1
1
Cin
Karnaugh Map for Cout
Now we have to cover all the 1s in the
Karnaugh Map using the largest
rectangles and as few rectangles
as we can.
Cout = Acin + AB
Application of Karnaugh Maps: The One-bit Adder
Cin
A
0
0
0
0
1
1
1
1
A
Adder
S
B
Cout
B
A
B Cin S
0 0
0
0 1
1
1 0
1
1 1
0
0 0
1
0 1
0
1 0
0
1 1
1
Cout
0
0
0
1
0
1
1
1
+
0
0
1
0
0
1
1
1
Cin
Karnaugh Map for Cout
Now we have to cover all the 1s in the
Karnaugh Map using the largest
rectangles and as few rectangles
as we can.
Cout = ACin + AB + BCin
Application of Karnaugh Maps: The One-bit Adder
Cin
A
0
0
0
0
1
1
1
1
A
Adder
S
B
Cout
B
A
B Cin S
0 0
0
0 1
1
1 0
1
1 1
0
0 0
1
0 1
0
1 0
0
1 1
1
+
0
1
0
1
1
0
1
0
Cin
Karnaugh Map for S
S = A’BCin’
Cout
0
0
0
1
0
1
1
1
Application of Karnaugh Maps: The One-bit Adder
Cin
A
0
0
0
0
1
1
1
1
A
Adder
S
B
Cout
B
A
B Cin S
0 0
0
0 1
1
1 0
1
1 1
0
0 0
1
0 1
0
1 0
0
1 1
1
Cout
0
0
0
1
0
1
1
1
+
0
1
0
1
1
0
1
0
Cin
Karnaugh Map for S
S = A’BCin’ + A’B’Cin
Application of Karnaugh Maps: The One-bit Adder
Cin
A
0
0
0
0
1
1
1
1
A
Adder
S
B
Cout
B
A
B Cin S
0 0
0
0 1
1
1 0
1
1 1
0
0 0
1
0 1
0
1 0
0
1 1
1
Cout
0
0
0
1
0
1
1
1
+
0
1
0
1
1
0
1
0
Cin
Karnaugh Map for S
S = A’BCin’ + A’B’Cin + ABCin
Application of Karnaugh Maps: The One-bit Adder
Can you draw the circuit diagrams?
Cin
A
0
0
0
0
1
1
1
1
A
Adder
S
B
Cout
B
A
B Cin S
0 0
0
0 1
1
1 0
1
1 1
0
0 0
1
0 1
0
1 0
0
1 1
1
Cout
0
0
0
1
0
1
1
1
+
0
1
0
1
1
0
1
0
Cin
Karnaugh Map for S
S = A’BCin’ + A’B’Cin + ABCin + AB’Cin’
No Possible Reduction!
Summary
° Karnaugh map allows us to represent functions with
new notation
° Representation allows for logic reduction.
• Implement same function with less logic
° Each square represents one minterm
° Each circle leads to one product term
° Not all functions can be reduced
° Each circle represents an application of:
• Distributive rule -- x(y + z) = xy + xz
• Complement rule – x + x’ = 1