Logic and Computer Design Fundamentals Chapter 2 Combinational Logic Circuits Part 2 Circuit Optimization
Overview Part Gate Circuits and Boolean Equations Binary Logic and Gates Boolean Algebra Standard Forms Part 2 Circuit Optimization Two-Level Optimization Map Manipulation Part 3 Additional Gates and Circuits Other Gate Types Exclusive-OR Operator and Gates High-Impedance Outputs Chapter 2 - P 2 IT32 2
Circuit Optimization Goal: To obtain the simplest implementation for a given function Introduce a graphical technique using Karnaugh maps (K-maps, for short) Chapter 2 - P 2 IT32 3
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 The K-map can be viewed as A reorganized version of the truth table Chapter 2 - P 2 IT32 4
Use of K-Maps Provide a means for: Finding optimum or near optimum SOP and POS standard forms, and two-level AND/OR and OR/AND circuit implementations Chapter 2 - P 2 IT32 5
Two Variable K-Maps A 2-variable Karnaugh Map: Note that:. m0 and m are adjacent and differ in the value of the y variable. 2. m0 and m2 differ in the x variable. 3. m and m3 differ in the x variable. 4. m2 and m3 differ in the value of the variable y. y = 0 y = x = 0 x = x y x y x y x y Chapter 2 - P 2 IT32 6
Two Variable K-Maps Every 2 adjacent cells differ in the value of variable only. Chapter 2 - P 2 IT32 7
K-Map and Truth Tables The K-Map is just a different form of the truth table. Example Two variable function: F each of a, b, c, d can be either 0 or Function Table Input Values (x,y) Function Value F(x,y) 0 0 a 0 b 0 c d Minterm m 0 m m 2 m 3 K-Map y = 0 y = x = 0 a b x = c d Chapter 2 - P 2 IT32 8
K-Map Function Representation Example: F(x,y) = x F = x y = 0 y = x = 0 0 0 x = For function F(x,y), the two adjacent cells containing s can be combined using the Minimization Theorem: F ( x, y ) = x y + x y = x Chapter 2 - P 2 IT32 9
K-Map Function Representation Example: G(x,y) = x + y G = x+y y = 0 y = x = 0 0 x = For G(x,y), two pairs of adjacent cells containing s can be combined using the Minimization Theorem: ( x y + x y ) + ( xy + x y ) = x y G ( x, y ) = + Duplicate x y Chapter 2 - P 2 IT32 0
Three Variable Maps A three-variable K-map: yz=00 yz=0 yz= yz=0 x=0 m 0 m m 3 m 2 x= m 4 m 5 m 7 m 6 Where each minterm corresponds to the product terms: Note that if the binary value for an index differs in one bit position, the minterms are adjacent on the K-Map Chapter 2 - P 2 IT32
Alternative Map Labeling Map use largely involves: Entering values into the map, and Reading off product terms from the map. Alternate labeling are useful: x x z y 0 3 2 4 z y 5 7 6 z x y z x Chapter 2 - P 2 IT32 2 0 z y 0 3 2 4 00 0 0 5 7 6
Example Functions By convention, we represent the minterms of F by a "" in the map and leave the minterms of F blank Example: F(x, y, F =? Example: G =? z) = Learn the locations of the 8 indices based on the variable order shown (x, most significant and z, least significant) on the map boundaries m G(a, b,c) = (2,3,4,5) m (3,4,6,7) Chapter 2 - P 2 IT32 3 x a y 0 3 2 4 5 7 6 z b 0 3 2 4 5 7 6 c
Example Functions Chapter 2 - P 2 IT32 4
Combining Squares By combining squares, we reduce number of literals in a product term On a 3-variable K-Map: # of adjacent squares represents A minterm with three variables 2 A product term with two variables 4 A product term with one variable 8 The function of all ones (no variables) = Chapter 2 - P 2 IT32 5
Combining Squares Groupings to select product-terms must be:. Rectangular in shape 2. In powers of twos (, 2, 4, 8, etc.) 3. Always select largest possible groupings of minterms (i.e. prime implicants) 4. Eliminate redundant groupings Chapter 2 - P 2 IT32 6
Simplest SOP Expressions To find the simplest possible sum of products (SOP) expression from a K-map, you need to obtain: minimum number of literals per product term; and minimum number of product terms This is achieved in K-map using bigger groupings of minterms (prime implicants) where possible; and no redundant groupings (look for essential prime implicants) Implicant: a product term that could be used to cover minterms of the function. Chapter 2 - P 2 IT32 7
Example: Combining Squares Example: Let F = m(2,3,6,7) Applying the Minimization Theorem three times: F ( x, y, z ) = x y z + x y z + x y z + = yz + y z = y x y z Thus the four terms that form a 2 2 square correspond to the term "y". x y 0 3 2 4 5 7 6 z Chapter 2 - P 2 IT32 8
Three-Variable Maps Reduced literal product terms for SOP standard forms correspond to rectangles on 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. Rectangles can contain non-adjacent cells as illustrated by the pairwise adjacent ring above. Chapter 2 - P 2 IT32 9
Chapter 2 - P 2 IT32 20
Three-Variable Maps Example Shapes of 2-cell Rectangles: y 0 3 2 x 4 5 7 6 Read off the product terms for the rectangles shown z Chapter 2 - P 2 IT32 2
Three-Variable Maps Example Shapes of 4-cell Rectangles: y 0 3 2 x 4 5 7 6 Read off the product terms for the rectangles shown z Chapter 2 - P 2 IT32 22
Three Variable Maps K-Maps can be used to simplify Boolean functions by systematic methods. Terms are selected to cover the s in the map. Example: Simplify F(x, y, z) = m(,2,3,5,7) z y x y x F(x,y,z)= xy+z z Chapter 2 - P 2 IT32 23
Four-Variable Maps Chapter 2 - P 2 IT32 24
Four Variable Terms Four variable maps can have rectangles corresponding to: A single = 4 variables, (i.e. Minterm) Two s = 3 variables, Four s = 2 variables Eight s = variable, Sixteen s = zero variables (i.e. Constant "") Chapter 2 - P 2 IT32 25
Four-Variable Maps Example Shapes of Rectangles: Y 0 3 2 5 6 4 7 W 2 3 5 4 8 9 0 X Z Chapter 2 - P 2 IT32 26
Four-Variable Maps Example Shapes of Rectangles: Y 0 3 2 W 5 6 4 7 2 3 5 4 8 9 0 X Z Chapter 2 - P 2 IT32 27
K-maps Possible valid groupings of a 4-variable K-map include: Chapter 2 - P 2 IT32 28
K-maps Groups of minterms must be () rectangular, and (2) have size in powers of 2 s. Otherwise they are invalid groups. For examples: Chapter 2 - P 2 IT32 29
Systematic Simplification A Prime Implicant is 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 that set includes the minterm. Chapter 2 - P 2 IT32 30
Example of Prime Implicants Find ALL Prime Implicants CD C B D ESSENTIAL Prime Implicants C B D BD A A B B BD A B Chapter 2 - P 2 D AD B C Minterms covered by single prime implicant IT32 3 D
Prime Implicant Practice Find all prime implicants for: F(A, B,C, D) = m (0,2,3,8,9,0,,2,3,4,5) Prime implicants are: Chapter 2 - P 2 IT32 32
Another Example Find all prime implicants for: G(A, B,C,D) = Hint: There are seven prime implicants! m (0,2,3,4,7,2,3,4,5) Prime Implicants are : AB, B C' D', A' C' D', A' B' D', A' B' C, A' C D, B C D Chapter 2 - P 2 IT32 33
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 = Y Y X X W W Z Z Chapter 2 - P 2 IT32 34
Optimization Algorithm. Find all prime implicants. 2. Include all essential prime implicants in the solution (optimum function F). 3. Select a minimum cost set of non-essential prime implicants to cover all minterms not yet covered: Obtaining a good simplified solution: Use the Selection Rule Chapter 2 - P 2 IT32 35
Prime Implicant Selection Rule Minimize the overlap among prime implicants as much as possible. In particular, in the final solution, make sure that each prime implicant selected includes at least one minterm not included in any other prime implicant selected. Chapter 2 - P 2 IT32 36
Selection Rule Example Simplify F(A, B, C, D) given on the K-map. Selected Essential C C A B A B D F=? In SOP and POS Minterms covered by essential prime implicants D Chapter 2 - P 2 IT32 37
Don't Cares in K-Maps Sometimes a function table or map contains : Input values for the minterm will never occur, or Output value for the minterm is not used In these cases, the output value is defined as a don't care ( an x entry). By doing that the cost of the logic circuit of that function may be lowered. Chapter 2 - P 2 IT32 38
Don't Cares in K-Maps 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, 00 through never occur, so the output values for these codes are x to represent don t cares. Chapter 2 - P 2 IT32 39
Don't Cares in K-Maps Ultimately, each x entry may take on either a 0 or value in resulting solutions. For example, an x may take on value 0 in an SOP solution and value in a POS solution (If not covered), or vice-versa (If covered). Any minterm with value x need not be covered by a prime implicant. Chapter 2 - P 2 IT32 40
Example: BCD 5 or More w The map below gives a function F(w,x,y,z) which is defined as "5 or more" over BCD inputs. With the don't cares used for the 6 non-bcd combinations: y F (w,x,y,z) = w + x z + x y This 0 0 0 0 is much simpler than F2 where the 0 3 2 don't cares were treated as "0s. 0 4 5 7 6 X X 2 3 5 4 8 9 0 z X X X X x F 2 (w, x, y, z) = w x z + w x y + w x y For this particular function, cost for the POS solution for F(w,x,y,z) is not changed by using the don't cares. Chapter 2 - P 2 IT32 4
Selection Rule Example with Don't Cares Simplify F(A, B, C, D) given on the K-map. C Selected Essential C x x A x x x x B x A x x x B D Minterms covered by essential prime implicants D Chapter 2 - P 2 IT32 42
Product of Sums Example Find the optimum POS solution: F(A, B,C,D) = m (3,9,,2,3,4,5) + d (,4,6) Hint: Use F it to get the result. and complement Chapter 2 - P 2 IT32 43