0% found this document useful (0 votes)
25 views43 pages

KMAP With-Notes

Uploaded by

bastiongamerz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views43 pages

KMAP With-Notes

Uploaded by

bastiongamerz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 43

Module 5:

K-MAPPING
Engr. Mon Arjay Malbog
Circuit Optimization
 Karnaugh Map (K-map)
• 2 Variables KMAP
• 3 Variables KMAP
• 4 Variables KMAP

Circuit Optimization 2
SOP and POS
 Consider again: F = y + x z

x y z F Minterm
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0 M3 = (x+y+z)
1 0 0 1
1 0 1 1
1 1 0 0 M6 = (x+y+z)
1 1 1 0 M7 = (x+y+z)

Circuit Optimization 3
Standard Sum-of-
Products (SOP)
 A Simplification Example:
F (A , B , C )   (1,4,5,6,7)
 Writing the minterm expression:
F = A B C + A B C + A B C + ABC + ABC
 Simplifying:
F = A B C + A (B C + B C + B C + B C)
F = A B C + A (B (C + C) + B (C + C))
F = A B C + A (B + B)
F=ABC+A
F=BC+A
 Simplified F contains 3 literals compared to 15

4
AND/OR Two-Level Implementation

 The two implementations for F


are shown below
A
F
B
C

It is quite
apparent which
is simpler!

5
Circuit Optimization
 Goal: To obtain the simplest
implementation for a given function
 Optimization is a more formal approach
to simplification that is performed using
a specific procedure or algorithm
 Optimization requires a cost criterion to
measure the simplicity of a circuit
 Distinct cost criteria we will use:
• Literal cost (L)
• Gate input cost (G)
• Gate input cost including inverters (GN)
Circuit Optimization 6
Literal Cost
 Literal – a variable or it complement
 Literal cost – the number of literal
appearances in a Boolean expression
corresponding to the logic circuit diagram
 Example: Boolean expressions for F
• F=BD+ABC+ACD L=8
• F= BD+ABC+ABD+ABC L = 11
• F = (A+B)(A+D)(B+C+D)(B+C+D) L = 10
• Which solution is best? First solution is best
Circuit Optimization 7
Gate Input Cost
 Gate Input Cost: Count of total number of inputs to the
gates in the logic circuit implementation
 Two gate input costs are defined:
G = Count of gate inputs without counting Inverters
GN = Count of gate inputs + count of Inverters
 For SOP and POS equations, the gate input cost can be
found from the Boolean expression by finding the sum of:
• All literal appearances
• Number of terms excluding single literal terms (added to G)
• Number of distinct complemented single literals (added to GN)
 Example:
L = 8 G = L+3 = 11
• F=BD+ABC+ACD GN = G+3 = 14
Circuit Optimization 8
Cost Criteria (continued)
GN = G + 2 = 9
 F=A+ BC+ BC L= 5
G=L+2= 7
B
C
A F

 L (literal count) counts the AND inputs and the single


literal OR input.
 G (gate input count) adds the remaining OR gate inputs
 GN(gate input count with NOTs) adds the inverter inputs

Circuit Optimization 9
Cost Criteria (continued)
A
B
 F = A B C + AB C C
 L = 6 G = 8 GN = 11 F

 Same function and same


literal cost
 But first circuit has better
gate input count and better
gate input count with NOTs
 Select first circuit!

Circuit Optimization 10
Cost Criteria (continued)
 Example 3:

 F = (A + C)( B+ C)( A+ B)
 L = 6 G = 9 GN = 12
 Same function and same A
literal cost B
 But first circuit has betterC
F
gate input count and better
gate input count with NOTs
 Select first circuit!
Circuit Optimization 11
Cost Criteria Summary
 Literal Count:
• Simple to evaluate by counting all literals
• However, does not represent circuit complexity
accurately in all cases
 Gate Input Cost (or Count):
• Good measure of logic implementation
• Proportional to the number of transistors and
wires used in the implementation
• Important when measuring cost of circuits with
more than two levels
Circuit Optimization 12
Boolean Function Optimization
 Minimizing the gate input (or literal) cost of a
Boolean equation reduces the circuit cost
 We choose the gate input cost
 Boolean Algebra and graphical techniques are
tools to minimize cost criteria values
 Some important questions:
• When do we stop trying to reduce the cost?
• Do we know when we have a minimum cost?
 Treat optimum or near-optimum cost functions
for two-level (SOP and POS) circuits first
 Introduce a graphical technique using Karnaugh
maps (K-maps for short)
Circuit Optimization 13
Karnaugh Map (K-map)
 A K-map is a collection of squares
• Each square represents a minterm
• The collection of squares is a graphical representation
of a Boolean function
• Adjacent squares differ in the value of one variable
• Alternative algebraic expressions for the same function
are derived by recognizing patterns of squares
 The K-map can be viewed as
• A reorganized version of the truth table

Circuit Optimization 14
Some Uses of K-Maps
 Provide a means for:
• Finding optimum or near optimum
 SOP and POS standard forms
 Two-level AND/OR and OR/AND circuits
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

Circuit Optimization 15
Two-Variable K-Map
 A 2-variable Karnaugh Map:
• Minterm m0 and minterm m1 are “adjacent”
they differ in the value of variable y
• Similarly, minterm m0 and minterm m2 are
adjacent and differ in x
• Also, m1 and m3 differ in the x variable
• Finally, m2 and m3 differ in the y variable
y y=0 y=1
x

x = 0 m0 = x y m1 = x y
x = 1 m2 = x y m3 = x y
Circuit Optimization 16
K-Map and Truth Tables
 The K-Map is a different form of the truth table

Truth Table
Input Function K-Map
Values Value
y y=0 y=1
(x,y) F(x,y) x

00 1 x=0 1 0
01 0 x=1 1 1
10 1
11 1

Circuit Optimization 17
K-Map Function Minimization
 F(x,y) = m0 + m2 + m3 K-Map
F=xy+xy+xy y y=0 y=1
x
 Two adjacent cells x=0 1 0
containing 1’s can be
x=1 1 1
combined using the
Minimization Theorem
 m0 + m2 = x y + x y = (x + x) y = y
 m2 + m3 = x y + x y = x (y + y) = x
 Therefore, F can be simplified as F = x + y
Circuit Optimization 18
Three Variable K-Map
yz
x 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
x yz=00 yz=01 yz=11 yz=10
x=0 x y z xyz xyz xyz
x=1 xyz xyz xyz xyz
 Note that if the binary value for an index differs in one bit
position, the minterms are adjacent on the K-Map
Circuit Optimization 19
Alternative K-Map Labeling
 K-Map largely involves:
• Entering values into the map, and
• Reading off product terms from the map
 Alternate labelings are useful:
yz y
x 00 01 11 10 y y
0 0 1 3 2
x 0 1 3 2

x 1 4 5 7 6 x 4 5 7 6

z z z z
Circuit Optimization 20
Example Functions
 By convention, we represent the minterms of F by a ‘1’
in the map and leave the entries that contain ‘0’ blank
 Example 1: y
0 3 2
1
1 1
F(x, y, z) = ∑(2, 3, 4, 5)
x 41 5
1 7 6

 Example 2: z
G(x, y, z) = ∑(3, 4, 6, 7) y
0 1 3 2
 Learn the locations of the 8 1
indices based on the variable x 41 5 7
1 6
1
order shown
z
Circuit Optimization 21
Combining Squares
 By combining squares, we reduce number of literals in
a product term, thereby reducing the gate input cost

 On a 3-variable K-Map:

• One square represents a minterm with 3 variables

• Two adjacent squares represent a term with 2 variables

• Four adjacent squares represent a term with 1 variable

• Eight adjacent square is the function 1 (no variables)

Circuit Optimization 22
Example: Combining Squares
 Example: y
0 1 3 2
1 1
F = ∑(2, 3, 6, 7) x 4 5 7
1 6
1
z
 Applying the Minimization Theorem 3 times:

F( x, y , z )  x y z  x y z  x y z  x y z
 yz  y z
y
 Thus the four terms that form a 2 × 2 square
correspond to the term ‘y’.
Circuit Optimization 23
Combining Four Squares
 Example Shapes of 4-square Rectangles:

x y y z
0 1 3 2

4 5 7 6
x
z
Circuit Optimization 24
Combining Two Squares
 Example Shapes of 2-square Rectangles:

xy y xz
0 1 3 2

4 5 7 6
x
z
yz
Circuit Optimization 25
Simplifying 3-Variable Functions
 K-Maps can be used to simplify Boolean functions
 Example: find an optimum SOP equation for
F(x, y, z) = ∑ (0, 1, 2, 4, 6, 7)
xy y z
0 1 3 2
1 1 1
5 7
x
4 6
1 1 1
z
xy
F=z+xy+xy
Circuit Optimization 26
Four-Variable K-Map

yz Y Y
00 01 11 10
wx
00 m0 = w x y z m1 = w x y z m3 = w x y z m2 = w x y z X
W
01 m4 = w x y z m5 = w x y z m7 = w x y z m6 = w x y z
X
11 m12 = w x y z m13 = w x y z m15 = w x y z m14 = w x y z
W
10 m8 = w x y z m9 = w x y z m11 = w x y z m10 = w x y z X
Z Z Z
Circuit Optimization 27
4-Variable K-map Terms
 4-variable K-maps can have rectangles
corresponding to:
• Single square = 4-variable minterm
• 2 combined squares = 3-variable term
• 4 combined squares = 2-variable term
• 8 combined squares = 1 variable term
• 16 (all) combined squares = constant ‘1’
Circuit Optimization 28
Combining Eight Squares
 Examples of 8-square Rectangles:
Y
Z
0 1 3 2
W
4 5 7 6
X
12 13 15 14
W
8 9 11 10

Z
Circuit Optimization 29
Combining Four Squares
 Examples of 4-square Rectangles:
XZ XZ Y
WY
0 1 3 2

4 5 7 6

12 13 15 14 X
W
8 9 11 10

Z
Circuit Optimization 30
Combining Two Squares
 Examples of 2-square Rectangles:
WXZ Y
XYZ WYZ
0 1 3 2

4 5 7 6

12 13 15 14 X
W
8 9 11 10
WXZ
Z
Circuit Optimization 31
Simplifying 4-Variable Functions
 F(W, X, Y, Z) = ∑ (0, 2, 4, 5, 6, 7, 8, 12)

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

F=WX+YZ+WZ Z
Circuit Optimization 32
Product-of-Sum (POS) Simplification
 F (W, X, Y, Z) = ∑ (1, 2, 3, 9, 10, 11, 13, 14, 15)
 F = W Z + W Y + X Z + X Y (G = 8+4 = 12)
 F (W, X, Y, Z) = ∑ (0, 4, 5, 6, 7, 8, 12) = Y Z + W X
 F = Y Z + W X = (Y + Z) (W + X) (G = 4+2 = 6)
Y F Y
0 1 3 2 0 1 3 2
1 1 1 1
4 5 7 6 4 5 7 6
1 1 1 1
12 13 15 14
X 12 13 15 14
X
1 1 1 1
W 8 9 11 10
W 8 9 11 10
1 1 1 1
Z Z
Circuit Optimization 33
Example#1

Truth Table
Input Function
Values Value
(x,y) F(x,y) K-Map
00 1 y 0 1
x
01 1 0
10 0
11 0 1

Circuit Optimization 34
Example#2

Truth Table
Input Function
Values Value
(x,y) F(x,y) K-Map
00 1 y 0 1
x
01 1 0
10 1
11 0 1

Circuit Optimization 35
Example#3

x y z F
0 0 0 1 yz 00 01 11 10
x
0 0 1 1
0
0 1 0 1
0 1 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 0

Circuit Optimization 36
Example#4

x y z F
0 0 0 1 yz 00 01 11 10
x
0 0 1 0
0
0 1 0 1
0 1 1 0 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 0

Circuit Optimization 37
z x y z F
0
0
0
0
0
0
0
1
1
1
Example#5
0 0 1 0 0
0 0 1 1 0
0 1 0 0 1
0 1 0 1 1
0 1 1 0 1
0 1 1 1 1 yz 00 01 11 10
1 0 0 0 1 wx
1 0 0 1 1 00
1 0 1 0 0
01
1 0 1 1 0
1 1 0 0 1 11
1 1 0 1 1
1 1 1 0 1 10
1 1 1 1 1
Circuit Optimization 38
z x y z F
0
0
0
0
0
0
0
1
1
1
Example#6
0 0 1 0 1
0 0 1 1 0
0 1 0 0 1
0 1 0 1 1
0 1 1 0 0
0 1 1 1 0 yz 00 01 11 10
1 0 0 0 0 wx
1 0 0 1 0 00
1 0 1 0 1
01
1 0 1 1 1
1 1 0 0 0 11
1 1 0 1 0
1 1 1 0 1 10
1 1 1 1 1
Circuit Optimization 39
z x y z F
0
0
0
0
0
0
0
1
1
1
Example#7
0 0 1 0 1
0 0 1 1 0
0 1 0 0 0
0 1 0 1 0
0 1 1 0 1
0 1 1 1 1 yz 00 01 11 10
1 0 0 0 1 wx
1 0 0 1 0 00 1 1 1
1 0 1 0 1
01 1 1
1 0 1 1 0
1 1 0 0 1 11 1 1 1 1
1 1 0 1 1
1 1 1 0 1 10 1 1
1 1 1 1 1
Circuit Optimization 40
Don't Cares in K-Maps
 Sometimes a function table or K-map contains entries for
which it is known:
• The input values for the minterm will never occur, or
• The output value for the minterm is not 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” ( an “x” entry) in the function table
or map, the cost of the logic circuit may be lowered.
 Example: A logic function having the binary codes for the
BCD digits as its inputs. Only the codes for 0 through 9 are
used. The six codes, 1010 through 1111 never occur, so the
output values for these codes are “x = don’t cares.”

Circuit Optimization 41
Selection Rule 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
Minterms covered by essential prime implicants
Circuit Optimization 42
Selection Rule 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
Minterms covered by essential prime implicants
Circuit Optimization 43

You might also like