The Universit Of Alabama in Huntsville Computer Science Chapter 2: Boolean Algebra and Logic Gates The Universit Of Alabama in Huntsville Computer Science Boolean Algebra The algebraic sstem usuall used to work with binar logic epressions Postulates: 1. Closure: An defined operation on (0, 1) gives (0,1) 2. Identit: 0 + = ; 1. = 3. Commutative: + = + ; = 4. Distributive: ( + ) = + ; + () = ( + )( + ) 5. Def of Complement: + = 1; = 0 6. At least 2 elements (0 and 1) Precedence rule: (1) parentheses (2) NOT (3) AND (4) OR 1
The Universit Of Alabama in Huntsville Computer Science The Dualit Principle A Boolean epression that is alwas true is still true if we echange OR with AND and 0 with 1 Eamples: + = 1 so: = 0 + = + so: = Note that we cannot use Dualit to sa that + =1, so = 0 Wh not? The Universit Of Alabama in Huntsville Computer Science Useful Postulates and Theorems (a) Postulate 2 + 0 =. 1 = Postulate 5 + = 1 = 0 Theorem 1 + = = Theorem 2 + 1 = 1. 0 = 0 Theorem 3 (involution) ( ) = Postulate 3 (commutative) + = + = Theorem 4 (associative) + ( + ) = ( + ) = () = () Postulate 4 (distributive) ( + ) = + + = ( + )( + ) Theorem 5 (demorgan s Law) ( + ) = () = + Theorem 6 (absorption) + = ( + ) = (b) 2
The Universit Of Alabama in Huntsville Computer Science Eample: Theorem 1: + = ; = Proving the Theorems Proof: + = ( + ) 1 postulate 2(b) = ( + )( + ) 5(a) = + 4(b) = + 0 5(b) = 2(a) = b dualit The Universit Of Alabama in Huntsville Computer Science Proving b Truth Table Two Boolean epressions are equal in all cases if and onl if the have the same Truth Table. (You ma use this to prove the epressions are equal unless I sa otherwise). Eample: Prove demorgan s Law: ( + ) = ( + ) ( + ) 0 0 0 1 1 1 1 0 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 1 0 0 0 0 The Truth Table of ( + ) is equal to the Truth Table of, so we know that ( + ) = for all values of and. 3
The Universit Of Alabama in Huntsville Computer Science Boolean functions and circuit equivalents The Universit Of Alabama in Huntsville Computer Science Implementing a Boolean epression as a circuit F1 = + F1 F1 F1 4
The Universit Of Alabama in Huntsville Computer Science Simplifing epressions There are man different was to write the same epression Eample: + + = + Different forms of the epression will require different numbers of gates to implement Proof? See page 45 in tet Generall, longer epressions with more terms require more gates and/or more comple gates More gates higher power, higher cost, larger sie, So finding a wa to simplif epressions will pa off in terms of the circuits we design The Universit Of Alabama in Huntsville Computer Science A metric for use in simplifing epressions Define a literal as each occurrence of a variable in the epression Eample: F2 = + + 8 literals If we can write the epression with fewer literal, we will consider it to be simpler (and to take fewer gates). Note that this is a rule of thumb and does not alwas give an optimum answer 5
The Universit Of Alabama in Huntsville Computer Science Simplifing epressions using the postulates and theorems of Boolean Algebra From page 46-47 of tet 1. ( + ) (3 literals) = + p4a = 0 + p5b = p2a (2 literals) 2. + = + The dual of (1) 3. ( + )( + ) (4 literals) = + p4b = + 0 p5b = p2a (1 literal) 4. + + (6 literals) = + + (1) p2b = + + ( + ) p5a = + + + p4a = + + + p3b twice = + + + p3a twice = 1 + + 1 + p2b twice = (1 + ) + (1 + ) p4a twice = 1 + 1 T2a twice = + p2a twice (4 literals) 5. (+)( +)(+) = (+)( +) The dual of (4) The Consensus Theorem The Universit Of Alabama in Huntsville Computer Science Complementing a function demorgan s Law sas: ( + ) = To take (A + B + C) Let = B+C Then (A + B + C) = (A + ) = A = A (B + C) = A B C In general: (A+B+C+D+ ) = A B C D ; (ABCD ) = A +B +C +D A more comple function: F = + F = ( + ) = ( ) ( ) = ( + + )( + + ) 6
The Universit Of Alabama in Huntsville Computer Science A shortcut for complementing a function To complement a function, ou can take the dual of the function, and complement each literal. For the previous eample: F = + dual of F = ( + + )( + + ) so F = ( + + )( + + ) The Universit Of Alabama in Huntsville Computer Science Standard forms of Boolean Epressions 7
The Universit Of Alabama in Huntsville Computer Science Definitions Product term a term consisting of literals ANDed together» Eample: AB F Minterm a Product term in which all variables appear» Eample: ABC D where A,B,C, and D are the variables of the function Sum term a term consisting of literals ORed together» Eample: A + B + F Materm a Sum term in which all variables appear» Eample: A + B + C + D where A, B, C, and D are the variables of the function The Universit Of Alabama in Huntsville Computer Science SOP and Canonical SOP Form A function is in Sum of Products (SOP) form if it is written as product terms ORed together Eample: f( ) = + + A function is in Canonical SOP form if it is in SOP form and all terms are minterms Eample: g( ) = + + 8
The Universit Of Alabama in Huntsville Computer Science POS and Canonical POS form A function is in Product of Sums (POS) form if it is written as sum terms ANDed together Eample: f( ) = ( + + ) ( + ) () A function is in Canonical POS form if it is written in POS form and all terms are Materms Eample: g( ) = ( + + ) ( + + ) The Universit Of Alabama in Huntsville Computer Science Minterms and the Truth Table Each row of a Truth Table corresponds to a minterm f( ) minterm 0 0 0 0 m 0 0 0 1 1 m 1 0 1 0 0 m 2 0 1 1 0 m 3 1 0 0 1 m 4 1 0 1 1 m 5 1 1 0 0 m 6 1 1 1 1 m 7 f( ) = + + + Minterm List Form: f( ) = Σm(1, 4, 5, 7) The 1 s of the Truth Table show the minterms that are in the Canonical SOP epression 9
The Universit Of Alabama in Huntsville Computer Science f() 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 f( ) = + + = Σm(1,4,7) Eamples A B C D g(abcd) 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 1 0 0 0 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 0 1 0 1 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 1 0 0 1 1 1 1 0 g(a B C D) = A B C D + AB CD + ABC D = Σm(1, 10, 13) The Universit Of Alabama in Huntsville Computer Science Materms and the Truth Table Each row of a Truth Table corresponds to a materm f( ) Materm 0 0 0 0 M 0 + + 0 0 1 1 M 1 + + 0 1 0 1 M 2 + + 0 1 1 0 M 3 + + 1 0 0 1 M 4 + + 1 0 1 1 M 5 + + 1 1 0 0 M 6 + + 1 1 1 1 M 7 + + f( ) = (++)(+ +)( + + ) Materm List Form: f( ) = ΠM(0,3,6) Note the differences from the wa minterms are complemented The 0 s of the Truth Table show the materms that are in the Canonical POS epression 10
The Universit Of Alabama in Huntsville Computer Science f() 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 Eample f( ) = (++)(+ +)(+ + )( ++ )( + +) = ΠM(0, 2, 3, 5, 6) Note that the Minterm List and Materm List taken together include the number of ever row of the Truth Table. That means that if ou determine either one of the lists, ou can determine the other one b simpl writing the row numbers that are not in the first one. Eamples: If F(ABC) = Σm(0-3), then F(ABC) = ΠM(4-7) if G(w) = ΠM(0,12,15), then G(w) = Σm(1-11, 13, 14) The Universit Of Alabama in Huntsville Computer Science Basic Combinational Circuit Designs 11
The Universit Of Alabama in Huntsville Computer Science SOP to AND-OR An SOP epression can be directl implemented in a two-level combinational circuit with an AND gate for each product term and an OR gate to combine the terms Eample: f() = + + f() The Universit Of Alabama in Huntsville Computer Science POS to OR-AND A POS epression can be directl implemented in a two-level combinational circuit with an OR gate for each sum term and an AND gate to combine the terms Eample: f(w) = (+)(w+) w f(w) 12
The Universit Of Alabama in Huntsville Computer Science Circuits for mied-form epressions Combinational circuits for mied-form epressions ma have more than two levels Eample: f(abcde) = AB + C(D + E) A B C D E f(abcde) The Universit Of Alabama in Huntsville Computer Science NAND NAND 0 0 1 0 1 1 1 0 1 1 1 0 Other common gate tpes () = + Eclusive-OR (XOR) XOR 0 0 0 0 1 1 1 0 1 1 1 0 + = + NOR NOR 0 0 1 0 1 0 1 0 0 1 1 0 (+) = 13
The Universit Of Alabama in Huntsville Computer Science You can use NAND and NOR to do anthing ou can do with AND, OR, and NOT () = (() ) = ( ) = + NOT AND OR (+) = ( + ) = = ((+) ) = + The Universit Of Alabama in Huntsville Computer Science SOP to NAND (1) We alread determined that we can go directl from SOP form to an AND-OR implementation f() = + + f() We can substitute the NAND equivalents for the AND and OR gates f() 14
The Universit Of Alabama in Huntsville Computer Science SOP to NAND (2) The circled gates are just 2 inverters in series the do nothing So leave them out f() f() The Universit Of Alabama in Huntsville Computer Science Check: Is this still the original f()? SOP to NAND (3) The circuit produces: ( ( ) ( )) = + ( ) + ( ) = + + f() 15
The Universit Of Alabama in Huntsville Computer Science SOP to NAND (4) We can use NAND gates to directl implement an SOP epression: One NAND for each Product term One NAND to sum the terms Invert an single inputs Wh do we do this? The NAND integrated circuit design is ver simple. We can use this one simple gate tpe for an epression. The Universit Of Alabama in Huntsville Computer Science SOP to NAND (5) Eample: f(a,b,c,d) = A B + AC + ABD A B A C A B D f(a,b,c,d) 16
The Universit Of Alabama in Huntsville Computer Science Cascading 2-input NANDs to implement larger NAND functions Think of a multiple-input NAND as an AND followed b an INVERTER () () We can easil build a multiple-input AND out of 2-input ANDs And we know how to build a 2-input AND from 2-input NANDs Substituting ( () ) = () () = What happened to the Inverters at the output? 17