ECE 20B, Winter 2003 Introduction to Electrical Engineering, II LECTURE NOTES #2 Instructor: Andrew B. Kahng (lecture) Email: abk@ucsd.edu Telephone: 858-822-4884 office, 858-353-0550 cell Office: 3802 AP&M Class Website: http://vlsicad.ucsd.edu/courses/ece20b/ Login: ece20b Password: b02ece
Goals for Lecture Binary logic and gates Boolean Algebra Canonical forms for function representation Function simplification Eamples Corresponds to MK, 2.1-2.4 (some 2.5) 2
Binary Logic and Gates (MK 2.1) Binary variables take on one of two values. Logical operators operate on binary values and binary variables. Basic logical operators are the logic functions AND, OR and NOT. Logic gates implement logic functions. Boolean Algebra: a useful mathematical system for specifying and transforming logical functions. We study Boolean Algebra as foundation for designing digital systems. 3
Binary Variables The two binary values have different names: True/False On/Off Yes/No 1/0 We will use 1 and 0 to denote the two values. Variable identifiers: A, B, y, or z for now RESET, START_IT, or ADD1 later 4
Logical Operations The three basic logical operations are: AND OR NOT AND is denoted by a dot ( ). OR is denoted by a plus (+). NOT is denoted by a bar ( ) over, a single quote mark (') after, or ~ before the variable. 5
Notation Eamples Eamples: Y = A B is read Y is equal to A and B. z = + y is read z is equal to OR y. X = A is read X is equal to NOT A. Note: The statement: 1 + 1 = 2 (read one plus one is equal to two ) is not the same as 1 + 1 = 1 (read 1 or 1 is equal to 1 ). 6
Operator Definitions Operations are defined on the values "0" and "1" for each Operator: AND 0 0 = 0 0 1 = 0 1 0 = 0 1 1 = 1 OR 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 1 NOT 0 = 1 1 = 0 7
Truth Tables Truth tables list the output value of a function for all possible input values Truth tables for basic logic operations: AND OR NOT X 0 Y 0 Z = X Y 0 X 0 Y 0 Z = X+Y 0 X 0 Z = X 1 0 1 0 0 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 1 8
Logic Function Implementation Using Switches For inputs: logic 1 is switch closed logic 0 is switch open For outputs: logic 1 is light on logic 0 is light off. For NOT, a switch such that for inputs: logic 1 is switch open logic 0 is switch closed Switches in parallel => OR Switches in series => AND 9
Logic Gates In the earliest computers, switches were opened and closed by energizing coils to produce magnetic fields. The switches in turn opened and closed current paths. Later, vacuum tubes that open and close current paths replaced the relays. Today, transistors are used as electronic switches that open and close current paths. Transistor or tube based implementations of logic functions are called logic gates or just gates 10
Logic Gate Symbols and Behavior Logic gates have special symbols: And waveform behavior in time as follows: 11
Logic Diagrams and Epressions X Y Z 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 Truth Table F = X + 0 1 0 0 1 1 1 1 Y Z X Y Z Logic Diagram Epression Boolean epressions, truth tables and logic diagrams describe the same function! Truth tables are unique; epressions and logic diagrams are not. This gives fleibility in implementing functions. F = X + Y Z F 12
Boolean Algebra (MK 2.2) An algebraic structure defined on a set of at least two elements, B, together with two binary operators (denoted + and ) that satisfies the following identities: Closure of B with respect to +, (see slide 6) Identity elements 0 and 1 such that: 1. X + 0 = X 2. X 1 = X 3. X + 1 = 1 4. X 0 = 0 5. X + X = X 6. X X = X For each element X, an element X (inverse) s.t.: 7. X + X = 1 8. X X = 0 9. X = X 13
Boolean Algebra (cont.) 10. X + Y = Y + X 11. X Y = Y X 12. X + (Y + Z) = (X + Y) + Z 13. X (Y Z) = (X Y) Z 14. X (Y + Z) = X Y + X Z 15. X + Y Z = (X + Y) (X + Z) 16. X Y = X + Y 17. X + Y = X Y The identities are organized into dual pairs. These pairs have names as follows: 1-4 Eistence of 0 and 1 5-6 Idempotence 7-8 Eistence of complement 9 Involution 10-11 Commutative Laws 12-13 Associative Laws 14-15 Distributive Laws 16-17 DeMorgan s Laws If the meaning is unambiguous, we leave out the symbol 14
Duality The dual of an algebraic epression is obtained by interchanging + and and interchanging 0 s and 1 s. The identities appear in dual pairs. When there is only one identity on a line the identity is self-dual, i. e., the dual epression = the original epression. Unless it happens to be self-dual, the dual of an epression does not equal the epression itself. 15
Boolean Algebraic Proofs - Eample 1 X + X Y = X (Absorption Theorem) Proof Steps Justification (identity or theorem) X + X Y = X 1 + X Y (identity 2) = X (Y + Y) + X Y (identity 7) = X Y + X Y + X Y (identity 14) = X Y + X Y (identity 5, applied to X Y) = X (Y + Y) (identity 14) = X 1 = X (identity 5, identity 2) 16
Boolean Algebraic Proofs - Eample 2 XY + XZ + YZ = XY + XZ (Consensus Theorem) Proof Steps Justification (identity or theorem) YZ = YZ(X + X) (identity 2, identity 7) = XYZ + XYZ (identity 14) XY + XZ + XYZ + XYZ = XY(1 + Z) + XZ(1 + Y) (identity 2, identity 7) = XY + XZ (identity 3, identity 2) 17
Boolean Operator Precedence The order of evaluation in Boolean Epressions is: Parentheses NOT AND OR Because AND takes precedence over OR, parentheses must be placed around the OR operator more frequently. 18
19 Eercise: Prove DeMorgan s Laws ( )( ) Minimization y y y y y y = + + = + ( ) tion y Simplifica y y y = + + = + ( ) n Absorptio y y = + = + Consensus z y z y z y + = + + ( ) ( ) ( ) ( ) ( ) z y z y z y + + = + + + s Laws DeMorgan' y y y y + = = + Useful Theorems
Boolean Function Evaluation F1= yz y z F1 F2 F3 F4 F2 F3 = = + yz yz + y z + y 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0 F4 = y + z 0 1 1 0 0 1 1 1 0 0 0 1 1 1 1 0 1 0 1 1 1 1 1 0 1 1 0 0 1 1 1 0 1 0 0 20
Epression Simplification Simplify to contain the smallest number of literals (complemented and uncomplemented variables): A B + AC D + A B D + AC D + A BC D = = AB + A C + A BD = AB + A (C + BD) or = AB + A C + BC D = A C + B(A + C D) 21
Complementing Functions Use DeMorgan's Theorem to complement a function: 1. Interchange AND and OR operators 2. Complement each literal Eample: Complement yz + yz 22
Canonical Forms (MK 2.3) It is useful to specify Boolean functions in a form that: Allows comparison for equality. Has a correspondence the truth tables Canonical forms: Sum of Minterms (SOM) or Sum of Products (SOP) Product of Materms (POM) or Product of Sums (POS) 23
Minterms Minterms are AND terms with every variable in true or complemented form. Each binary variable may appear in uncomplemented (e.g., ) or complemented (e.g., ) form there are 2 n minterms for n variables. EXAMPLE: Two variables, combined with an AND operator, X Y have 2*2 or 4 combinations: XY (both normal) XY (X normal, Y complemented) XY (X complemented, Y normal) XY (both complemented) There are four minterms of two variables. 24
Materms Materms are OR terms with every variable in true or complemented form. Each binary variable may appear in uncomplemented (e.g., ) or complemented (e.g., ) form there are 2 n materms for n variables. Two variables, combined with an OR operator, X + Y, have 2*2 or 4 combinations: X + Y X + Y (both normal) ( normal, y complemented) X + Y ( complemented, y normal) X + Y (both complemented) 25
Materms and Minterms Eamples: Two variable minterms and materms. Inde Materm Minterm 0 + y y 1 + y y 2 + y y 3 + y y The inde above is important for describing which variables in the terms are true and which are complemented. 26
Standard Order Minterms and materms are designated with a subscript The subscript is a number, corresponding to a binary pattern The bits in the pattern represent the complemented or normal state of EVERY variable, listed in a STANDARD order. All variables will be present in a minterm or materm and will be listed in the same order (usually alphabetically) Eample: For variables a, b, c: Materms: (a + b + c), ( a + b + c) Minterms: a b c, a b c, a b c Terms: (b + a + c), a c b, and (c + b + a) are NOT in standard order. Terms: (a + c), b c, and (a + b) do not contain all variables 27
Purpose of the Inde The inde for the minterm or materm, epressed as a binary number, is used to determine whether each variable occurs in true form or complemented form. For Minterms: 1 means the variable is Not Complemented and 0 means the variable is Complemented. For Materms: 0 means the variable is Not Complemented and 1 means the variable is Complemented. 28
Inde Eample in Three Variables Eample: (for three variables) Assume the variables are called X, Y, and Z. the standard order is X, then Y, then Z. The Inde 0 (base 10) = 000 (base 2 to three digits) so all three variables are complemented for minterm 0 ( X,Y,Z ) and no variables are complemented for Materm 0 (X,Y,Z) Minterm 0, called m 0 is. XYZ Materm 0, called M 0 is (X + Y + Z). 29
Four Variables Inde Eamples Inde Binary Minterm Materm i Pattern m i 0 0000 abcd 1 0001 abcd 3 0011 abcd 5 0101 abcd 7 0111 abcd 10 1010 abcd 13 1101 abcd 15 1111 abcd M i a + b + c + a + b + c + a + b + c + a + b + c + a + b + c + a + b + c + a + b + c + a + b + c + d d d d d d d d 30
Minterm and Materm Relationship DeMorgan's Theorem: y = + y and + y = y Two-variable eample: M 2 = + y and m 2 = y Thus M 2 is the complement of m 2 and viceversa. Since DeMorgan's Theorem holds for n variables, the above holds for terms of n variables giving: M i = and m = M mi i i Thus M i is the complement of m i. 31
Function Tables for Both Minterms of Materms of 2 variables 2 variables y m 0 m 1 m 2 m 3 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 1 1 0 0 0 1 y M 0 M 1 M 2 M 3 0 0 0 1 1 1 0 1 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1 0 Each column in the materm function table is the complement of the column in the minterm function table since M i is the complement of m i. 32
Observations In the function tables: Each minterm has one and only one 1 present in the 2 n terms (a minimum of ones). All other entries are 0. Each materm has one and only one 0 present in the 2 n terms All other entries are 1 (a maimum of ones). We can implement any function by "ORing" the minterms corresponding to a "1" in the function table. We can implement any function by "ANDing" the materms corresponding to a "0" in the function table. This gives us two canonical forms: Sum of Minterms (SOM), and Product of Materms (POM) for stating any Boolean function. 33
Minterm Function Eample Eample: Find F 1 = m 1 + m 4 + m 7 F1 = y z + y z + y z y z inde m 1 + m 4 + m 7 = F 1 0 0 0 0 0 + 0 + 0 = 0 0 0 1 1 1 + 0 + 0 = 1 0 1 0 2 0 + 0 + 0 = 0 0 1 1 3 0 + 0 + 0 = 0 1 0 0 4 0 + 1 + 0 = 1 1 0 1 5 0 + 0 + 0 = 0 1 1 0 6 0 + 0 + 0 = 0 1 1 1 7 0 + 0 + 1 = 1 34
Minterm Function Eample F(A, B, C, D, E) = m 2 + m 9 + m 17 + m 23 35
Materm Function Eample Eample: Implement F1 in materms: F 1 = M 0 M 2 M 3 M 5 M 6 F1 = ( + y + z) ( + y + z) ( + y + z) ( + y + z) ( + y + z) y z i M 0 M 2 M 3 M 5 M 6 = F1 0 0 0 0 0 1 1 1 1 = 0 0 0 1 1 1 1 1 1 1 = 1 0 1 0 2 1 0 1 1 1 = 0 0 1 1 3 1 1 0 1 1 = 0 1 0 0 4 1 1 1 1 1 = 1 1 0 1 5 1 1 1 0 1 = 0 1 1 0 6 1 1 1 1 0 = 0 1 1 1 7 1 1 1 1 1 = 1 36
Materm Function Eample F(A, B,C, D) = M3 M8 M11 M14 37
Canonical Sum of Minterms Any Boolean Function can be epressed as a Sum of Minterms. For the function table, the minterms used are the terms corresponding to the 1's For epressions, epand all terms first to eplicitly list all minterms. Do this by ANDing any term missing a variable v with a term ( ). Eample: Implement as a sum of minterms. First epand terms: Then distribute terms: v + v f = + Epress as sum of minterms: f = m 3 +m 2 +m 0 y f = (y + y) + y f = y + y + y 38
Another SOM Eample F = A + B C Eample: There are three variables, A, B, and C which we take to be the standard order. Epanding the terms with missing variables: F = A (B + B)(C + C) + B C(A + A) F = ABC + ABC + ABC + ABC + ABC + ABC Collect terms (removing all but one of duplicate terms): Epress as SOM: F = ABC + ABC + ABC + ABC + ABC 39
Shorthand SOM Form From the previous eample, we started with: F = A + B C We ended up with: F = m 1 +m 4 +m 5 +m 6 +m 7 This can be denoted in the formal shorthand: F(A, B,C) = Σm(1,4,5,6,7) (We eplicitly show the standard variables in order and drop the m designators.) 40
Canonical Product of Materms Any Boolean Function can be epressed as a Product of Materms (POM). For the function table, the materms used are the terms corresponding to the 0's. For an epression, epand all terms first to eplicitly list all materms. Do this by first applying the second distributive law, ORing terms missing variable v with a term equal to and then applying the distributive law again. Eample: Convert to product of materms: First apply the distributive law: v v f (, y, z) = + y Add missing variable z: + y = ( + )( + y) = 1 ( + y) = + y Epress as POM: f = M 2 M 3 ( + y z) + y + z z = (z + y + z) + 41
Complements and Conversion To complement a function epressed as SOm (or, POM), just select the missing minterms (Materms) Or, the complement of the SOm (POM) function is given by the POM (SOm) with the same indices. To convert SOM SOP, find the missing indices, and then use the other form Eample: F(,y,z) = Σ m (1,3,5,7) F (,y,z) = Σ m (0,2,4,6) F (,y,z) = Π M (1,3,5,7) F(,y,z) = Π M (0,2,4,6) 42
Standard Sum-of-Products (SOP) A Sum of Minterms form for n variables can be written down directly from a truth table. Implementation of this form is a two-level network of gates such that: The first level consists of n-input AND gates, and The second level is a single OR gate (with fewer than 2n inputs). This form: is usually not a minimum literal epression, and leads to a more epensive implementation (in terms of two levels of AND and OR gates) than needed. 43
Standard Sum-of-Products (SOP) Try to combine terms to get a lower literal cost epression less epensive implementation. Eample: F(A, B,C) = Σm(1,4,5,6,7) 44
SOP AND/OR Two-level Implementation Which implementation is simpler? A B C A B C A B C A B C A B C F A B C F 45
Standard Product-of-Sums (POS) A Product of Materms form for n variables can be written down directly from a truth table. Implementation of this form is a two-level network of gates such that: The first level consists of n-input OR gates, and The second level is a single AND gate (with fewer than 2n inputs). This form: is usually not a minimum literal epression, and leads to a more epensive implementation (in terms of two levels of AND and OR gates) than needed. 46
Standard Product-of-Sums (POS) Try to combine terms to get a lower literal cost epression less epensive implementation. Eample: F ( A, B,C) = ΠM(0,2,3) 47
OR/AND Two-level Implementation Which implementation is simpler? A B C A B C A B C F A C A B F 48
Cost of Implementation Canonical SOP, POS representations can differ in literal cost Boolean algebra: manipulate equations into simpler forms reduces the (two-level) implementation cost Is there only one minimum-cost circuit? Is there a systematic procedure to obtain a minimum-cost circuit? 49