Introduction to Electrical Engineering, II LETURE NOTES #2 Instructor: Email: Telephone: Office: ndrew. Kahng (lecture) abk@ucsd.edu 858-822-4884 office 3802 P&M lass Website: http://vlsicad.ucsd.edu/courses/ece20b/wi04/ Goals for Lecture inary logic and gates oolean lgebra anonical forms for function representation unction simplification Examples orresponds to MK, 2.-2.4 (some 2.5) 2 inary Logic and Gates (MK 2.) inary Variables inary variables take on one of two values. Logical operators operate on binary values and binary variables. asic logical operators are the logic functions ND, OR and NOT. Logic gates implement logic functions. oolean lgebra: a useful mathematical system for specifying and transforming logical functions. We study oolean lgebra as foundation for designing digital systems. The two binary values have different names: True/alse On/Off Yes/No /0 We will use and 0 to denote the two values. Variable identifiers:,, y, or z for now RESET, STRT_IT, or DD later 3 4 Logical Operations Notation Examples The three basic logical operations are: ND OR NOT ND 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. Examples: Y = is read Y is equal to and. z = x + y is read z is equal to x OR y. = is read is equal to NOT. Note: The statement: + = 2 (read one plus one is equal to two ) is not the same as + = (read or is equal to ). 5 6
Operator Definitions Truth Tables Operations are defined on the values "0" and "" for each Operator: ND 0 0 = 0 0 = 0 0 = 0 = OR 0 + 0 = 0 0 + = + 0 = + = NOT 0 = = 0 Truth tables list the output value of a function for all possible input values Truth tables for basic logic operations: ND Y Z = Y 0 0 0 0 0 0 0 Y 0 0 0 0 OR Z = +Y 0 NOT Z = 0 0 7 8 Logic unction Implementation Logic Gates Using Switches or inputs: logic is switch closed logic 0 is switch open or outputs: logic is light on logic 0 is light off. or NOT, a switch such that for inputs: logic is switch open logic 0 is switch closed Switches in parallel => OR Switches in series => ND 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. 9 0 Logic Gates (continued) Logic Gate Symbols and ehavior Implementation of logic functions with transistors (See text website Supplement 2-8) logic +V Logic gates have special symbols: 2 n using p-type transistors using n-type transistors Y rom G +V G = + Y Y +V. Y +V nd waveform behavior in time as follows: logic 0 rom G2 (a) General structure (b) NOR (c) NND Transistor or tube based implementations of logic functions are called logic gates or just gates (d) NOT 2 2
Logic Diagrams and Expressions oolean lgebra (MK 2.2) Truth Table Logic Diagram Y Z 0 0 0 = + Y Z 0 0 0 Y 0 0 0 Z 0 0 0 0 Expression 0 0 = + Y Z oolean expressions, truth tables and logic diagrams describe the same function! Truth tables are unique; expressions and logic diagrams are not. This gives flexibility in implementing functions. 3 n algebraic structure defined on a set of at least two elements,, together with two binary operators (denoted + and ) that satisfies the following identities: losure of with respect to +, (see slide 6) Identity elements 0 and such that:. + 0 = 2. = 3. + = 4. 0 = 0 5. + = 6. = or each element, an element (inverse) s.t.: 7. + = 8. = 0 9. = 4 oolean lgebra (cont.) 0. + Y = Y +. Y = Y 2. + (Y + Z) = ( + Y) + Z 3. (Y Z) = ( Y) Z 4. (Y + Z) = Y + Z 5. + Y Z = ( + Y) ( + Z) 6. Y = + Y 7. + Y = Y The identities are organized into dual pairs. These pairs have names as follows: -4 Existence of 0 and 5-6 Idempotence 7-8 Existence of complement 9 Involution 0- ommutative Laws 2-3 ssociative Laws 4-5 Distributive Laws 6-7 DeMorgan s Laws If the meaning is unambiguous, we leave out the symbol Duality The dual of an algebraic expression is obtained by interchanging + and and interchanging 0 s and s. The identities appear in dual pairs. When there is only one identity on a line the identity is selfdual, i. e., the dual expression = the original expression. Unless it happens to be self-dual, the dual of an expression does not equal the expression itself. 5 6 oolean lgebraic Proofs - Example oolean lgebraic Proofs - Example 2 + Y = (bsorption Theorem) Y + Z + YZ = Y + Z (onsensus Theorem) Proof Steps Justification (identity or theorem) + Y = + Y (identity 2) = (Y + Y) + Y (identity 7) = Y + Y + Y (identity 4) = Y + Y (identity 5, applied to Y) = (Y + Y) (identity 4) = = (identity 5, identity 2) Proof Steps Justification (identity or theorem) YZ = YZ( + ) (identity 2, identity 7) = YZ + YZ (identity 4) Y + Z + YZ + YZ = Y( + Z) + Z( + Y) (identity 2, identity 7) = Y + Z (identity 3, identity 2) 7 8 3
oolean Operator Precedence The order of evaluation in oolean Expressions is: Parentheses NOT ND OR ecause ND takes precedence over OR, parentheses must be placed around the OR operator more frequently. Useful Theorems ( )( ) n x y + x y = y x + y x + y = y Minimizatio x + x y = x x ( x + y) = x bsorption x + x y = x + y x ( x + y) = x y Simplification x y + x z + y z = x y + x z onsensus ( x + y) ( x + z) ( y + z) = ( x + y) ( x + z) x + y = x y x y = x + y DeMorgan's Laws Exercise: Prove DeMorgan s Laws 9 20 oolean unction Evaluation Expression Simplification = xyz 2 = x + yz 3 = xyz + x y z + xy 4 = xy + x z x y z 2 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Simplify to contain the smallest number of literals (complemented and uncomplemented variables): + D + D + D + D = = + + D = + ( + D) or = + + D = + ( + D) 2 22 omplementing unctions anonical orms (MK 2.3) Use DeMorgan's Theorem to complement a function:. Interchange ND and OR operators 2. omplement each literal Example: omplement x yz + xyz It is useful to specify oolean functions in a form that: llows comparison for equality. Has a correspondence the truth tables anonical forms: Sum of Minterms (SOM) or Sum of Products (SOP) Product of Maxterms (POM) or Product of Sums (POS) 23 24 4
Minterms Minterms are ND terms with every variable in true or complemented form. Each binary variable may appear in uncomplemented (e.g., x) or complemented (e.g., x ) form there are 2 n minterms for n variables. EMPLE: Two variables, combined with an ND operator, Y have 2*2 or 4 combinations: (both normal) Y Y ( normal, Y complemented) Y ( complemented, Y normal) Y (both complemented) There are four minterms of two variables. 25 Maxterms Maxterms are OR terms with every variable in true or complemented form. Each binary variable may appear in uncomplemented (e.g., x) or complemented (e.g., x ) form there are 2 n maxterms for n variables. Two variables, combined with an OR operator, + Y, have 2*2 or 4 combinations: + Y (both normal) + Y (x normal, y complemented) + Y (x complemented, y normal) + Y (both complemented) 26 Maxterms and Minterms Standard Order Examples: Two variable minterms and maxterms. Index Maxterm Minterm 0 x + y x y x + y x y 2 x + y x y 3 x + y x y The index above is important for describing which variables in the terms are true and which are complemented. 27 Minterms and maxterms 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 STNDRD order. ll variables will be present in a minterm or maxterm and will be listed in the same order (usually alphabetically) Example: or variables a, b, c: Maxterms: (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 28 Purpose of the Index The index for the minterm or maxterm, expressed as a binary number, is used to determine whether each variable occurs in true form or complemented form. or Minterms: means the variable is Not omplemented and 0 means the variable is omplemented. or Maxterms: 0 means the variable is Not omplemented and means the variable is omplemented. Index Example in Three Variables Example: (for three variables) ssume the variables are called, Y, and Z. the standard order is, then Y, then Z. The Index 0 (base 0) = 000 (base 2 to three digits) so all three variables are complemented for minterm 0 (, Y, Z) and no variables are complemented for Maxterm 0 (,Y,Z) Minterm 0, called m 0 is YZ. Maxterm 0, called M 0 is ( + Y + Z). 29 30 5
our Variables Index Examples Index inary Minterm Maxterm i Pattern m i M i 0 0000 abcd 000 abcd 3 00 abcd 5 00 abcd 7 0 abcd 0 00 abcd 3 0 abcd 5 abcd Minterm and Maxterm Relationship DeMorgan's Theorem: x y = x + y and x + y = x y Two-variable example: M 2 = x + y and m 2 = x y Thus M 2 is the complement of m 2 and vice-versa. Since DeMorgan's Theorem holds for n variables, the above holds for terms of n variables giving: M and i = mi m i = M i Thus M i is the complement of m i. 3 32 unction Tables for oth Observations Minterms of Maxterms of 2 variables 2 variables x y m 0 m m 2 m 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x y M 0 M M 2 M 3 0 0 0 0 0 0 0 0 Each column in the maxterm function table is the complement of the column in the minterm function table since M i is the complement of m i. In the function tables: Each minterm has one and only one present in the 2 n terms (a minimum of ones). ll other entries are 0. Each maxterm has one and only one 0 present in the 2 n terms ll other entries are (a maximum of ones). We can implement any function by "ORing" the minterms corresponding to a "" in the function table. We can implement any function by "NDing" the maxterms corresponding to a "0" in the function table. This gives us two canonical forms: Sum of Minterms (SOM), and Product of Maxterms (POM) for stating any oolean function. 33 34 Minterm unction Example Minterm unction Example Example: ind = m + m 4 + m 7 = x y z + x y z + x y z (,,, D, E) = m 2 + m 9 + m 7 + m 23 x y z index m + m 4 + m 7 = 0 0 0 0 0 + 0 + 0 = 0 0 0 + 0 + 0 = 0 0 2 0 + 0 + 0 = 0 0 3 0 + 0 + 0 = 0 0 0 4 0 + + 0 = 0 5 0 + 0 + 0 = 0 0 6 0 + 0 + 0 = 0 7 0 + 0 + = 35 36 6
Maxterm unction Example Maxterm unction Example Example: Implement in maxterms: = M 0 M 2 M 3 M 5 M 6 = (x + y + z) (x + y + z) (x + y + z) ( x + y + z) (x + y + z) x y z i M 0 M 2 M 3 M 5 M 6 = 0 0 0 0 0 = 0 0 0 = 0 0 2 0 = 0 0 3 0 = 0 0 0 4 = 0 5 0 = 0 0 6 0 = 0 7 = 37 (,,, D) = M3 M8 M M4 38 anonical Sum of Minterms nother SOM Example ny oolean unction can be expressed as a Sum of Minterms. or the function table, the minterms used are the terms corresponding to the 's or expressions, expand all terms first to explicitly list all minterms. Do this by NDing any term missing a variable v with a term ( v + v). Example: Implement f = x + x y as a sum of minterms. irst expand terms: f = x(y + y) + x y Then distribute terms: f = xy + xy + x y Express as sum of minterms: f = m 3 +m 2 +m 0 Example: = + There are three variables,,, and which we take to be the standard order. Expanding the terms with missing variables: ollect terms (removing all but one of duplicate terms): Express as SOM: 39 40 Shorthand SOM orm anonical Product of Maxterms rom the previous example, we started with: = + We ended up with: = m +m 4 +m 5 +m 6 +m 7 This can be denoted in the formal shorthand: (,,) = Σm(,4,5,6,7) (We explicitly show the standard variables in order and drop the m designators.) ny oolean unction can be expressed as a Product of Maxterms (POM). or the function table, the maxterms used are the terms corresponding to the 0's. or an expression, expand all terms first to explicitly list all maxterms. 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. Example: onvert to product of maxterms: irst apply the distributive law: dd missing variable z: Express as POM: f = M 2 M 3 v v f (x, y, z) = x + x y x + x y = (x + x)(x + y) = (x + y) = x + y ( x + y z) x + y + z z = (z + y + z) + 4 42 7
omplements and onversion To complement a function expressed as SOm (or, POM), just select the missing minterms (Maxterms) 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 Example: (x,y,z) = Σ m (,3,5,7) (x,y,z) = Σ m (0,2,4,6) (x,y,z) = Π M (,3,5,7) (x,y,z) = Π M (0,2,4,6) Standard Sum-of-Products (SOP) 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 ND gates, and The second level is a single OR gate (with fewer than 2n inputs). This form: is usually not a minimum literal expression, and leads to a more expensive implementation (in terms of two levels of ND and OR gates) than needed. 43 44 Standard Sum-of-Products (SOP) SOP ND/OR Two-level Implementation Try to combine terms to get a lower literal cost expression less expensive implementation. Example: (,,) = Σm(,4,5,6,7) 45 Which implementation is simpler? 46 Standard Product-of-Sums (POS) Product of Maxterms 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 ND gate (with fewer than 2n inputs). This form: is usually not a minimum literal expression, and leads to a more expensive implementation (in terms of two levels of ND and OR gates) than needed. Standard Product-of-Sums (POS) Try to combine terms to get a lower literal cost expression less expensive implementation. Example: (,,) = ΠM(0,2,3) 47 48 8
OR/ND Two-level Implementation ost of Implementation Which implementation is simpler? anonical SOP, POS representations can differ in literal cost oolean 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 50 9