Gate-Level Minimization section instructor: Ufuk Çelikcan
Compleity of Digital Circuits Directly related to the compleity of the algebraic epression we use to build the circuit. Truth table may lead to different implementations Question: which one to use? Optimization techniques of algebraic epressions So far, ad hoc. Need more systematic (algorithmic) way Karnaugh (K-) map technique Quine-McCluskey Espresso 2
Two variables: and y 4 minterms: m = y m = y m 2 = y m 3 = y Two-Variable K-Map y m m m 2 m 3 y y y y y 3
Eample: Two-Variable K-Map y F = m + m + m 2 = y + y + y F = F = F = 4
Remember the Shortcuts + = = + = = + y = y = [Absorption] ( + y) = y (.y) = +y [DeMorgan]
Eample: Two-Variable K-Map y F = m + m + m 2 = y + y + y F = F = F = F = + y We can do the same optimization by combining adjacent cells. 6
Three-Variable K-Map yz m m m 3 m 2 m 4 m 5 m 7 m 6 Adjacent squares: they differ by only one variable, which is primed in one square and not primed in the other m 2 m 6, m 3 m 7 m 2 m, m 6 m 4 7
Eample: Three-Variable K-Map F (, y, z) = (2, 3, 4, 5) yz F (, y, z) = F 2 (, y, z) = (3, 4, 6, 7) yz F 2 (, y, z) = 8
Eample: Three-Variable K-Map F (, y, z) = (2, 3, 4, 5) yz F (, y, z) = F 2 (, y, z) = (3, 4, 6, 7) yz F 2 (, y, z) = 9
Eample: Three-Variable K-Map F (, y, z) = (2, 3, 4, 5) yz F (, y, z) = y + y F 2 (, y, z) = (3, 4, 6, 7) yz F 2 (, y, z) = z + yz
In 3-Variable Karnaugh Maps alone square represents one minterm with 3 literals 2 adjacent squares represent a term with 2 literals 4 adjacent squares represent a term with literal 8 adjacent squares produce a function that is always equal to.
F (, y, z) = (, 2, 4, 5, 6) Eample y yz z F (, y, z) = 2
F (, y, z) = (, 2, 4, 5, 6) Eample y yz z F (, y, z) = 3
F (, y, z) = (, 2, 4, 5, 6) Eample y yz z F (, y, z) = 4
Finding Sum of Minterms If a function is not epressed in sum of minterms form, it is possible to get it using K-maps Eample: F(, y, z) = z + y + y z + yz yz 5
Finding Sum of Minterms If a function is not epressed in sum of minterms form, it is possible to get it using K-maps Eample: F(, y, z) = z + y + y z + yz yz F(, y, z) = y z + yz + yz + y z + yz 6
Four-Variable K-Map Four variables:, y, z, t 4 literals 6 minterms z zt y m m m 3 m 2 m 4 m 5 m 7 m 6 m 2 m 3 m 5 m 4 m 8 m 9 m m y t 7
Eample: Four-Variable K-Map F(,y,z,t) = (,, 2, 4, 5, 6, 8, 9, 2, 3, 4) zt y F(,y,z,t) = 8
Eample: Four-Variable K-Map F(,y,z,t) = (,, 2, 4, 5, 6, 8, 9, 2, 3, 4) zt y F(,y,z,t) = 9
Eample: Four-Variable K-Map F(,y,z,t) = (,, 2, 4, 5, 6, 8, 9, 2, 3, 4) zt y F(,y,z,t) = 2
Eample: Four-Variable K-Map F(,y,z,t) = y z + y zt + yzt + y z zt y F(,y,z,t) = 2
Eample: Four-Variable K-Map F(,y,z,t) = y z + y zt + yzt + y z zt y F(,y,z,t) = 22
Eample: Four-Variable K-Map F(,y,z,t) = y z + y zt + yzt + y z zt y F(,y,z,t) = 23
Prime Implicants Prime Implicant: is a product term obtained by combining maimum possible number of adjacent squares in the map If a minterm can be covered by only one prime implicant, that prime implicant is said to be an essential prime implicant. A single on the map represents a prime implicant if it is not adjacent to any other s. Two adjacent s form a prime implicant, provided that they are not within a group of four adjacent s. So on 24
Eample: Prime Implicants F(,y,z,t) = (, 2, 3, 5, 7, 8, 9,,, 3, 5) zt y 25
Eample: Prime Implicants F(,y,z,t) = (, 2, 3, 5, 7, 8, 9,,, 3, 5) zt y 26
Eample: Prime Implicants F(,y,z,t) = (, 2, 3, 5, 7, 8, 9,,, 3, 5) zt y F(,y,z,t) = y t + yt + y + zt Which ones are the essential prime implicants? 27
Eample: Prime Implicants F(,y,z,t) = (, 2, 3, 5, 7, 8, 9,,, 3, 5) zt y Why are these the essential prime implicants? 28
Eample: Prime Implicants F(,y,z,t) = (, 2, 3, 5, 7, 8, 9,,, 3, 5) zt zt y y m m m 3 m 2 m 4 m 5 m 7 m 6 m 2 m 3 m 5 m 4 m 8 m 9 m m y t essential since m is covered only in it yt - essential since m 5 is covered only in it They together cover m, m 2, m 8, m, m 5, m 7, m 3, m 5 29
Eample: Prime Implicants zt y zt y m m m 3 m 2 m 4 m 5 m 7 m 6 m 2 m 3 m 5 m 4 m 8 m 9 m m m 3, m 9, m are not yet covered. How do we cover them? There is actually more than one way. 3
Eample: Prime Implicants zt y 2 3 4 Both y z and zt covers m 3 and m. m 9 can be covered in two different prime implicants: t or y m 3, m zt or y z m 9 y or t 3
32 Eample: Prime Implicants F(, y, z, t) = yt + y t + zt + t or F(, y, z, t) = yt + y t + zt + y or F(, y, z, t) = yt + y t + y z + t or F(, y, z, t) = yt + y t + y z + y Therefore, what to do. Find out all the essential prime implicants 2. Then find the other prime implicants that cover the minterms that are not covered by the essential prime implicants. There are more than one way to choose those. 3. Simplified epression is the logical sum of the essential implicants plus the other implicants
Five-Variable Map Downside: Karnaugh maps with more than four variables are not simple to use anymore. 5 variables 32 squares, 6 variables 64 squares Somewhat more practical way for F(, y, z, t, w) : tw yz m m m 3 m 2 m 4 m 5 m 7 m 6 m 2 m 3 m 5 m 4 m 8 m 9 m m tw yz m 6 m 7 m 9 m 8 m 2 m 2 m 23 m 22 m 28 m 29 m 3 m 3 m 24 m 25 m 27 m 26 33 = =
Many-Variable Maps Adjacency: Each square in the = map is adjacent to the corresponding square in the = map. For eample, m 4 m 2 and m 5 m 3 6-variables: Use four 4-variable maps to obtain 64 squares required for si variable optimization Alternative way: Use computer programs Quine-McCluskey method Espresso method 34
Eample: Five-Variable Map F(, y, z, t, w) = (, 2, 4, 6, 9, 3, 2, 23, 25, 29, 3) tw yz tw yz F(,y,z,t,w) = = = 37
Eample: Five-Variable Map F(, y, z, t, w) = (, 2, 4, 6, 9, 3, 2, 23, 25, 29, 3) tw yz tw yz F(,y,z,t,w) = = = 38
Product of Sums Simplification So far simplified epressions from Karnaugh maps are in sum of products form. Simplified product of sums can also be derived from Karnaugh maps. Method: A square with actually represents a minterm Similarly an empty square (a square with ) represents a materm. Treat the s in the same manner as we treat s The result is a simplified epression in product of sums form. 39
Eample: Product of Sums F(, y, z, t) = (,, 2, 5, 8, 9, ) Simplify this function in a. sum of products b. product of sums zt y F(, y, z, t) = 4
Eample: Product of Sums F(, y, z, t) = (,, 2, 5, 8, 9, ) Simplify this function in a. sum of products b. product of sums zt y F(, y, z, t) = 4
Eample: Product of Sums F(, y, z, t) = (,, 2, 5, 8, 9, ) Simplify this function in a. sum of products b. product of sums zt y F(,y,z,t) = y t + y z + z t 42
Eample: Product of Sums. Find F (,y,z,t) in Sum of Products form by grouping s 2. Apply DeMorgan s theorem to F (use dual theorem) to find F in Product of Sums form zt y 43
Eample: Product of Sums. Find F (,y,z,t) in Sum of Products form by grouping s 2. Apply DeMorgan s theorem to F (use dual theorem) to find F in Product of Sums form zt y 44
Eample: Product of Sums. Find F (,y,z,t) in Sum of Products form by grouping s 2. Apply DeMorgan s theorem to F (use dual theorem) to find F in Product of Sums form zt y 45 F = yt + zt + y
Eample: Product of Sums. Find F (,y,z,t) in Sum of Products form by grouping s 2. Apply DeMorgan s theorem to F (use dual theorem) to find F in Product of Sums form zt y 46 F(,y,z,t) = (y +t)(z +t )( +y )
Eample: Product of Sums y t y F z z t F(,y,z,t) = y t + y z + z t: sum of products implementation y t y z F t F = (y + t)( + y )(z + t ): product of sums implementation 47
Product of Materms If the function is originally epressed in the product of materms canonical form, the procedure is also valid Eample: F(, y, z) = (, 2, 5, 7) yz F(, y, z) = 48
Product of Materms If the function is originally epressed in the product of materms canonical form, the procedure is also valid Eample: F(, y, z) = (, 2, 5, 7) yz F(, y, z) = 49
Product of Materms If the function is originally epressed in the product of materms canonical form, the procedure is also valid Eample: F(, y, z) = (, 2, 5, 7) yz 5 F(, y, z) = F(, y, z) = z + z
Product of Sums To enter a function F, epressed in product of sums, in the map. take its complement, F 2. Find the squares corresponding to the terms in F, 3. Fill these square with s and others with s. Eample: F(, y, z, t) = ( + y + z )(y + t) F (, y, z, t) = 5
Product of Sums To enter a function F, epressed in product of sums, in the map. take its complement, F 2. Find the squares corresponding to the terms in F, 3. Fill these square with s and others with s. Eample: F(, y, z, t) = ( + y + z )(y + t) F (, y, z, t) = zt y 52
Don t Care Conditions /2 Some functions are not defined for certain input combinations Such function are referred as incompletely specified functions therefore, the corresponding output values do not have to be defined This may significantly reduces the circuit compleity Eample: A circuit that takes the s complement of decimal digits 53
Unspecified Minterms For unspecified minterms, we do not care what the value the function produces. Unspecified minterms of a function are called don t care conditions. We use X symbol to represent them in Karnaugh map. Useful for further simplification The symbol X s in the map can be taken or to make the Boolean epression even more simplified 54
Eample: Don t Care Conditions F(, y, z, t) = (, 3, 7,, 5) function d(, y, z, t) = (, 2, 5) don t care conditions zt y X X X F = F = F 2 = or 55
Eample: Don t Care Conditions F = zt + y = (,, 2, 3, 7,, 5) F 2 = zt + t = (, 3, 5, 7,, 5) The two functions are algebraically unequal But as far as the function F is concerned: both functions are acceptable Look at the simplified product of sums epression for the same function F. zt y X X X F = F = 56
Quine-McCluskey Method - Better than kmap for computers because a computer cant break down a graphical thing like K- map, but it can easily solve by QM - It is functionally identical to Karnaugh mapping, - but the tabular form makes it more efficient for use in computer algorithms, - and it also gives a deterministic way to check that the minimal form of a Boolean function has been reached. - It is sometimes referred to as the tabulation method.
Quine-McCluskey Method F(,2,3,4)= 2,4,6,8,9,,2,3,5 mi 2 3 4 2 4 8 6 9 2 3 5
Quine-McCluskey Method List List 2 List 3 mi 2 3 4 mi 2 3 4 mi 2 3 4 2 ok 2,6-8,9,2,3 - - 4 ok 2, - 8,2,9,3 - - 8 ok 4,6 - Finished 6 ok 4,2-9 ok 8,9 - ok ok 8, - 2 ok 8,2 - ok 3 ok 9,3 - ok 5 ok 2,3 - ok 3,5 -
Quine-McCluskey Method List List 2 List 3 mi 2 3 4 mi 2 3 4 mi 2 3 4 2,6 - t2 8,9,2,3 - - t 2, - t3 4,6 - t4 Finished 4,2 - t5 8, - t6 3,5 - t7
Quine-McCluskey Method 2 4 6 8 9 2 3 5 t X X X X t2 X X t3 X X t4 X X t5 X X t6 X X t7 X X 2 4 6 t2 X X t3 X X t4 X X t5 X t6 X t5 is a subset of t4 t6 is a subset of t3 F(,2,3,4)=t+t7+t3+t4 =3 + 24 + 2 34 + 24
NAND and NOR Gates NAND and NOR gates are easier to fabricate V DD A C = (AB) B CMOS 2-input AND gates requires 6 CMOS transistors 77 CMOS 3-input NAND gates requires 6 CMOS transistors
Design with NAND or NOR Gates It is beneficial to derive conversion rules from Boolean functions given in terms of AND, OR, an NOT gates into equivalent NAND or NOR implementations ( ) = NOT y [ ( y) ] = y AND ( y ) = + y OR 78 y
New Notation y z (yz) = y z + y + z AND-invert Invert-OR Implementing a Boolean function with NAND gates is easy if it is in sum of products form. Eample: F(, y, z, t) = y + zt y z t F(, y, z, t) = y + zt y z t ALWAYS USE THIS INTERMEDIATE FORM WITH BUBBLES TO AVOID CONFUSION 79 F(, y, z, t) = ((y) ) + ((zt) )
y z t The Conversion Method y z t ((y) ) + ((zt) ) = y + zt = [ (y) (zt) ] Eample: F(, y, z) = (, 3, 4, 5, 7) yz F = z + y F = (z ) + ((y ) ) 8
Eample: Design with NAND Gates y y z F z F F = (z ) + ((y ) ) F = z + y Summary. Simplify the function 2. Draw a NAND gate for each product term 3. Draw a NAND gate for the OR gate in the 2 nd level, 4. A product term with single literal needs an inverter in the first level. Assume single, complemented literals are available. 8
Multi-Level NAND Gate Designs The standard form results in two-level implementations Non-standard forms may raise a difficulty Eample: F = (zt + y) + yz 4-level implementation z t y y z F 82
Eample: Multilevel NAND F = (zt + y) + yz z t y y F MUST COMPENSATE FOR EVERY NON- COUPLED BUBBLE z z t y y F z
Design with Multi-Level NAND Gates Rules. Convert all AND gates to NAND gates 2. Convert all OR gates to NAND gates 3. Insert an inverter (one-input NAND gate) at the output if the final operation is AND 4. Check the bubbles in the diagram. For every bubble along a path from input to output there must be another bubble. If not so, complement the input literal 84
Another (Harder) Eample Eample: F = (y + y)(z + t ) (three-level implementation) y y F z t 85
Eample: Multi-Level NAND Gates y y z t F = (y + y)(z + t ) G = [ (y + y)(z + t) ] F = (y + y)(z + t ) y y z t F = (y + y)(z + t ) 86
Design with NOR Gates NOR is the dual operation of NAND. All rules and procedure we used in the design with NAND gates apply here in a similar way. Function is implemented easily if it is in product of sums form. ( + ) = NOT y [ (+ y) ] = + y OR y ( + y ) = y AND 87
=
Eample: Design with NOR Gates F = (+y) (z+t) w y z t w F y z t w F = ( + y) (z + t) w 89
Eample: Design with NOR Gates F = (y + zt) (z + t ) y z t F z t y z t z t F = [(( + y) + (z + t ) ) + (z + t ) ] = (( + y) + (z + t ) )(z + t ) = (y + zt) (z + t )
Eample: F = (zt + y) + yz z t Harder Eample y y z F z t y y F z
Eclusive-OR Function The symbol: y = y + y ( y) = y + y Properties. = 2. = 3. = 4. = 5. y = y = ( y) - XNOR Commutative & Associative y = y 92 ( y) z = (y z)
Eclusive-OR Function XOR gate is NOT universal Only a limited number of Boolean functions can be epressed in terms of XOR gates XOR operation has very important application in arithmetic and error-detection circuits. Odd Function ( y) z = (y + y) z = (y + y) z + (y + y) z = y z + yz + (y + y ) z = y z + yz + yz + y z = (4, 2, 7, ) 93
Odd Function If an odd number of variables are equal to, then the function is equal to. Therefore, multivariable XOR operation is referred as odd function. yz Odd function yz Even function 94
Odd & Even Functions y z y z Odd function ( y z) = (( y) z) y ( y z) z 95
Adder Circuit for Integers Addition of two-bit numbers Z = X + Y X = ( ) and Y = (y y ) Z = (z 2 z z ) Bitwise addition. z = y (sum) c = y (carry) 2. z = y c c 2 = y + c + y c 3. z 2 = c 2 96
Adder Circuit z 2 = c 2 z = y c c 2 = y + c + y c z = y c = y y y FA c c 2 = z 2 z z 97
Comparator Circuit with NAND gates F(X>Y) X = ( ) and Y = (y y ) y y F(,, y, y ) = y + y + y y 98
99 Comparator Circuit - Schematic
Comparator Circuit - Simulation