Chap - 02 - P2 Karnaugh

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 57

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 with NOTs (GN)

1
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, which solution is best?
• L=8
F = BD + AB C + AC D
• F = BD + A B C + A B D + ABC L = 11
• F = (A + B)(A + D)(B + C + D )( B + C + D)
L = 10

2
Gate Input Cost
 Gate input costs - the number of inputs to the gates in
the implementation corresponding exactly to the given
equation or equations. (G - inverters not counted, GN - inverters
counted)
 For SOP and POS equations, it can be found from the
equation(s)
by finding the sum of:
• all literal appearances
• the number of terms, (G) and
• optionally, the number of distinct complemented single literals
• = BD + A B C + A C
(GN).
F
G =11, GN = 14
• F =DBDwhich
 Example, + A B solution
C + A B Dis+ best?
AB C G =15, GN = 18
• F = (A + B)(A + D)(B + C + D)( B + C + D) G =14, GN =
17

3
Cost Criteria (continued)

 Example 1: GN = G + 2 = 9

 F = A + B C + B C L G= 5= L + 2 = 7
B
C

A F

•input.
L (literal count) counts the AND inputs and the single literal OR

 G (gate input count) adds the remaining OR gate inputs

 GN(gate input count with NOTs) adds the inverter inputs

4
Cost Criteria (continued)
A

B
• F=ABC+ABC C F
• L= 6 G = 8 GN =
11

A
• F = (A + C )(B + C) ( A + B)
• L=6 G = 9 GN = C
12 B function and same
 Same F
literal cost
 But first circuit has better
gate input count and
better gate input count
with NOTs 5
Boolean Function Optimization

 Minimizing the gate input (or literal) cost of a (a


set of) Boolean equation(s) reduces circuit cost.
 We choose 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) 6
Karnaugh Maps (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 (corresponding
to cubes)
 The K-map can be viewed as
A reorganized version of the truth table or a
particular cube representation

7
Some Uses of K-Maps

 Provide a means for:


• Finding optimum
 SOP and POS standard forms, and
 two-level AND/OR and OR/AND circuit implementations
for functions with small numbers of variables
• Visualizing concepts related to manipulating Boolean
expressions
• Demonstrating concepts used by computer-aided design
programs to simplify large circuits

8
The Boolean Space Bn
 B = { 0,1}
 B2 = {0,1} X {0,1} = {00, 01, 10, 11}

Karnaugh Maps: Boolean


Cubes:
B0

B1

B2

B3
B4

9
Two Variable Maps

 A 2-variable Karnaugh Map:


y
• Note that minterm m0 and x y=0 y=1
minterm m1 are “adjacent” m0 m1
and differ in the value of the x=0
variable y xy xy
• Similarly, minterm m0 and m2 m3
x=1 xy
minterm m2 differ in the xy
x variable.
• Also, m1 and m3 differ in
the x variable as well.
• Finally, m2 and m3 differ
in the value of the
variable y

10
K-Map and Truth Tables

 The K-Map is just a different form of the truth table.


 Example – Two variable function:
• We choose a,b,c and d from the set {0,1} to implement a
particular function, F(x,y).

Function Table K-Map

Input Function
y
Value x y=0
y=1
Values F(x,y)
x=0 a b
(x,y)
00 a
01 b x=1 c d
10 c
11 d
11
K-Map Function Representation

 Example: F(x,y) = x
F=x y=0 y=1

x=0 0 0

x=1 1 1

 For function F(x,y), the two


adjacent cells containing 1’s
can be combined using the
Minimization Theorem:

F(x, y ) = x y + x y
=x

12
K-Map Function Representation
 Example: G(x,y) = xy + xy + xy
G=x+y y = 0 y = 1

x=0 0 1

x=1 1 1

 For G(x,y), two pairs of adjacent cells containing 1’s can be


combined using the Minimization Theorem:

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

Duplicate xy
13
Three Variable Maps

 A three-variable K-map: yz
X yz=00 yz=01 yz=11 yz=10
m0 m1 m3 m2
x=0

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 x y z x y z x y z

x=1 x y z 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

14
Alternative Map Labeling

 Map use largely involves:


• Entering values into the map, and
• Reading off product terms from the map.
 Alternate labelings are useful:

y z y z
x y
y
y
0 1 3 2 0 1 3 2
x
x
4 5 7 6
x x 14 5 7 6

00
z z z z
01

11
15
10
Example: Combining Squares
y z
 Example: Let x y
3
1
 F (x, y, z) = m (2, 3, 6, 7) 0 1
2
1
x 4 5
7 6
1 1
z
 Applying the Minimization Theorem three times:

F(x,y,z) = x y z + x y z + x y z +
x y z
= yz + y z
= y

16
Combining Squares

 By combining squares, we reduce number of


literals in a product term, reducing the literal
cost, thereby reducing the other two cost criteria
 On a 3-variable K-Map:
• One square represents a minterm with three variables
• Two adjacent squares represent a cube that is product
term with two variables
• Four “adjacent” terms represent a cube that is product
term with one variable
• Eight “adjacent” terms is the function of all ones (no
variables) is a tautology f1=1.

17
Example Functions

 By convention, we represent the minterms of F by a "1" in the


map and leave the minterms of blank F
y z
 Example:
x y
F (x, y, z) = m (2, 3, 4, 5) 0 1
3 2
1 1
F (x, y, z) = x y + x y
7 6
x 4 5
1 1
 Example:
y z z
 F (x, y, z) = m (3, 4, 6, 7) x y
 F (x, y, z) = y z + x z
0 1 3 2
 Learn the locations of the 8 1
indices based on the variable
x 4 5
7
1 6
order shown (x, most significant 1 1
and z, least significant) on the z
map boundaries

18
Three-Variable Maps

 Reduced literal product terms for SOP standard


forms correspond to cubes i.e. to rectangles on the
K-maps containing cell counts that are powers of
2.
 Rectangles of 2 cells represent 2 adjacent
minterms; of 4 cells represent 4 minterms that
form a “pairwise adjacent” ring.

19
Three-Variable Maps
 Topological warps of 3-variable K-maps that show
all adjacencies:
 Venn Diagram 

Cylinder
0
4 X

6 5
7
Y 3 Z
2 1

y z

x y
y
0 1 3 2
x
4 5 7 6
x

z z z 20
Three-Variable Maps

 Example Shapes of 2-cell Rectangles:


yz y
x
0 1 3 2

4 5 7 6
x

z
 Read off the product terms for the rectangles
shown
x’z’ x’y’ yz

21
Three-Variable Maps

 Example Shapes of 4-cell Rectangles:


yz y
x
0 1 3 2

4 5 7 6
x

 Read off the product terms for the rectangles


shown
z’ z X’ Y’ 22
Three Variable Maps
 K-Maps can be used to simplify Boolean functions
by a systematic methods. Terms are selected to
cover the “1s”in the map.
 Example: Simplify F (x, y, z) = m (1, 2, 3, 5,
7)
yz
x z y
xy
1 1 1

x 1 1

F(x, y, z) = z + x
y
Three-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)

F=z+xy+xy
yz
x y

1 1 1

x 1 1 1

z
24
Four Variable Maps

 Map and location of minterms:


yz
WX yz=00 yz=01
yz=11 Y yz=10
0 1 3 2
wx=00

4 5 7 6
wx=01
X
12 13 15 14
wx=11
W 11 10
8 9
wx=10

Z
Four Variable Terms

 Four variable maps can have rectangles


corresponding to:
• A single 1 = 4 variables, (i.e. Minterm)
• Two 1s = 3 variables,
• Four 1s = 2 variables
• Eight 1s = 1 variable,
• Sixteen 1s = zero variables (i.e. Constant
"1")

26
Four-Variable Maps

 Example Shapes of Rectangles:


yz Y
WX yz=00 yz=01 yz=11 yz=10
0 1 3 2
wx=00

4 5 7 6
wx=01
X
12 13 15 14
wx=11
W
8 9 11 10
wx=10

27
Four-Variable Maps

 Example Shapes of Rectangles:


yz Y
WX yz=00 yz=01 yz=11 yz=10
0 2
1 3
wx=00

4 5 7 6
wx=01
X
12 13 15 14
wx=11
W 8 9 11 10
wx=10

Z
28
Four-Variable Map Simplification

F(W, X, Y, Z) =  m (0,2,4,5,6,7,
8,10,13,15)yz Y
WX yz=00 yz=01 yz=11 yz=10
0 1 3 2
1 1
wx=00

4 5 7 6
wx=01 1 1 1 1
X
12 13 15 14
wxW=1
1 1
1 9
8 11
wx=10 1 110
Z
F = XZ + 29
X'Z‘+W’X
Four-Variable Map Simplification

F(W,X,Y, Z) =m
yz Y
(3,4,5,7,9,13,14,15)
WX
0 1 3 2
1
6
4 5
1 1
X
12
W 113
15
1
14
1
7
8 19 11 10

Z
F = W' X Y' + W' Y Z + WXY + WY'Z 30
Systematic Simplification

A Prime Implicant is a cube i.e. a product term


obtained by combining the maximum possible
number of adjacent squares in the map into a
rectangle with the number of squares a power of 2.
A prime implicant is called an Essential Prime
Implicant if it is the only prime implicant that
covers (includes) one or more minterms.
Prime Implicants and Essential Prime Implicants
can be determined by inspection of a K-Map.
A set of prime implicants "covers all minterms" if,
for each minterm of the function, at least one
prime implicant in the set of prime implicants
includes the minterm.

31
Example of Prime

 Find ALL Prime Implicants


CD CD
ESSENTIAL Prime Implicants
CD C C
AB B D B D

1 1 1 1
1 1

BD BD 1 1
1 1
B B

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

D D
AD AD
B B
Minterms
C covered by single prime implicant C
32
Prime Implicant Practice
 Find all prime implicants for:
 F (A, B, C, D) = m (0,2,3,8,9,10,11,12,13,14,15)
CD C
AB 3
0 1 1 2
1 1
4 5 7 6

B
A 1 12 113 1
15
8 9 11 10
1 1 114 1
1
D

Prime implicants are: A,BC, and BD 33


Another Example
 Find all prime implicants for:
F (A, B, C, D) = m (0,2,3,4,7,12,13,14,15)
CD C
AB 0 3 2
1
1 1 1
5 6
4 7
1 1
B
14
A 1
12 13 15
1
1 1
8 9 11 10

D
AB, BCD, ACD, ABD, ABC, ACD,
BCD
m= AB+ACD+ACD+ABC  c=  m+ABD+BCD+BCD 34
K-Maps, implicates
 Find all prime implicates for:
F=(w+y+z) (w’+x’+y) (x+y) (w+x+y’) (w+x’+z) (w’+x+z)
WX
YZyz=00
yz=11
Y yz=10
0
yz=01 0 0
1 3 2
wx=00
0 0
4 5 7
wx=01 0 0
6
X
W 15 14
12
wx=11 0 013
9 10
8 11 0
wx=10 0 0
Z
m= (w+x)(w’+y)(w+z)(x+z) c= m(y+z) (y’+x’)
Five Variable or More K-Maps

 For five variable problems, we use two adjacent K-


maps. It becomes harder to visualize adjacent
minterms for selecting PIs. You can extend the
problem to six variables by using four K-Maps.
V=0 V=1
YZ Y YZ Y
WX WX

X X

W W

Z Z
36
Five Variable K-Maps
 Find all prime implicants for:
G(v,w,x,y,z)=m(0,1,2,4,5,6,7,8,10,16,17,18,20,
21,24,25,26,27,29)
V=0 V=1
Y Y
1 1 1 1 1 1
1 1 1 1 1 1
X 1 X
W W
1 1 1 1 1 1
Z Z
m= w’y’+x’z’+v’w’x+vy’z+vwx’ c= m+v’w’z’
37
Don't Cares in K-Maps

 Sometimes a function table or map contains entries for


which it is known that:
• 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 to represent “don’t cares.” 38
Incompletely Specified Functions

 F = (f, d, r) : Bn  {0, 1, x}
where x represents “don’t
care”.
• f = onset function - f(x)=1  F (x)=1
• r = offset function - r(x)=1  F (x)=0
• d = don’t care function - d(x)=1  F (x)=*

(f,d,r) forms a partition of Bn. i.e.


• f + d + r = Bn
• fd = fr = dr =  (pairwise disjoint)

39
Example:Logic Minimization
 Consider F (a,b,c)=(f,d,r), where f={abc, abc,
abc} and d ={abc, abc}, and the sequence of
covers illustrated below:
c
F1= abc + abc+ abc b

On Expand abca
a

Off
F2= a+abc + abc
Don abc is
’t redundant a is
car prime
e F3= a+abc
Expand abc 
bc
F = a+bc
4

40
Example: BCD “5 or More”

 In the map below gives a function F1(w,x,y,z) which is


defined as "5 or more" over BCD inputs. With
the don'tycares used for the 6 non-BCD
0 combinations:
0 0 0
0 1 3 2
F1(w, x,y, z) = w x z + w x y + w x
0 1 1
4
1 6 yF2 (w,x,y,z) = w + x z + x y
x
G=7
5 7
X X X X
12 13 15 14

w 1 1 X X This is much lower in cost than F1


8 9 11 10
where the “don't cares” were treated
z as "0s" having G = 12
For this particular function, cost G
for the POS solution for F1(w,x,y,z) is
not changed by using the don't cares.
F3 (w,x,y,z) = (w + x) (w + y + z) G= 41
Product of Sums Example

 Find the optimum POS solution:


F (A,B,C,D)=m(3,9,11,12,13,14,15) +m (1,4,6)
• Hint: Use F‘ and complement it to get the
result.
C C C
x 1 1 x 1 0 x 0
x x x 1 1 x x 0 0 x
B B B
1 1 1 1 A A
A 1 1 1 0
1 0
D D
D
F = A B+B' D F' = B' D' + A' B F = (B + D)(A + B')
F = (B + D)(A + B') 42
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
F=A’B+A’CD +AC’D+B’C’D’
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 x x 1
1 B B

A A
1 1 x x
1 1

D D
Minterms covered by essential prime implicants
F = A’ B + AB’D + B’C F = A’ B + AB’D + A’C 44
Combinational Circuits
 A combinational logic circuit has:
• A set of m Boolean inputs,
• A set of n Boolean outputs, and
• n switching functions, each mapping the 2
input m

combinations to an output such that the


current output depends only on the current
input values
 A block diagram:
COMBINATORIAL
LOGIC
CIRCUIT

m Boolean Inputs n Boolean Outputs


Design Procedure
 Specification
• Write a specification for the circuit
 Formulation
• Derive a truth table or initial Boolean equations that
define the required relationships between the inputs and
outputs
 Optimization
• Apply 2-level and multiple-level optimization
• Draw a logic diagram for the resulting circuit using
ANDs, ORs, and inverters
 Technology Mapping
• Map the logic diagram to the implementation technology
selected
 Verification
• Verify the correctness of the final design
Design Example BCD to Excess-3 code converter

 Specification
• BCD to Excess-3 code converter
 Transforms BCD code for the decimal digits to
Excess-3 code
• BCDfor the words
code decimalfor
digits
digits 0 through 9
 4-bit patterns 0000 to 1001, respectively
• Excess-3 code words for digits 0 through 9
 4-bit patterns consisting of 3 (binary 0011) added to each BCD
code word
• Implementation:
 multiple-level circuit
 NAND gates (including inverters)
Specification of BCD-to-Excess3

 Inputs: a BCD input, A,B,C,D with A as the most


significant bit and D as the least significant
bit.
 Outputs: an Excess-3 output W,X,Y,Z that
corresponds to the BCD input.
 Internal operation – circuit to do the conversion in
combinational logic.
W X Y Z

BCD to
Excess-3
converter

A B C D

48
Formulation of BCD-to-Excess-3

 Excess-3 code is easily formed by adding a binary


3 to the binary or BCD for the digit.
 There are 16 possible inputs for both BCD and
Excess-3.
 It can be assumed that only valid BCD inputs will
appear so the six combinations not used can be
treated as don’t cares.

49
BCD-to-Excess-3 Code converter

50
Expressions for W X Y Z
 W(A,B,C,D) = Σm(5,6,7,8,9) + d(10,11,12,13,14,15)
 X(A,B,C,D) = Σm(1,2,3,4,9) + d(10,11,12,13,14,15)
 Y(A,B,C,D) = Σm(0,3,4,7,8) + d(10,11,12,13,14,15)
 Z(A,B,C,D) = Σm(0,2,4,6,8) + d(10,11,12,13,14,15)

51
Optimization – BCD-to-Excess-3

 Lay out K-maps for each output, W X Y Z


Σm (5,6,7,8,9)

W = A + BC + BD
52
Optimization – BCD-to-Excess-3

 Lay out K-maps for each output, W X Y Z


Σm (1,2,3,4,9)

X = BC’D’+B’C+B’D
53
Optimization – BCD-to-Excess-3

Σm (0,3,4,7,8)

Y = C’D’ + CD
Minimize K-Maps

 Z minimization
Σ (0,2,4,6,8)
m

Z = D’

55
Two level versus multi-level circuit implementation

 Have equations
• W = A + BC + BD
• X = B’C + B’D + BC’D’
• Y = CD + C’D’
• Z = D’
 Call T= C+D, then T’ = (C+D)’ = C’D’
• W = A + BT
• X = B’T + BT’
• Y = CD + T’
• Z = D’

56
Create the digital circuit

 Implementing the
second set of
equations where
T=C+D results in a
lower gate count.
 This gate has a
fanout of 3

57

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