EE 345 MicroControllers Boolean Algebra and Logic Gates
EE 345 - Micro-Controllers Boolean Algebra and Logic Gates Prof. Ahmad Abu-El-Haija
Acknowledgement n This presentation is a modified version of lecture notes prepared by Dr. Pradondet Nilagupta, Kasetsart University. The latter is also a modified version based upon presentations by Prof. Maciej Ciesielski and Prof. Tilman Wolf, University of Massachusetts Amherst, and original slides from the publisher. Digital System Design 21 December 2021 2
Algebras n What is an Algebra? ¡ Mathematical system consisting of n n Why is it important? ¡ n Defines rules of “calculations” Example: arithmetic on natural numbers ¡ ¡ ¡ n Set of elements Set of operators Axioms or postulates Set of elements: N = {1, 2, 3, 4, …} Operator: +, –, * Axioms: associativity, distributivity, closure, identity elements, etc. Note: operators with two inputs are called binary ¡ ¡ Does not mean they are restricted to binary numbers! Operator(s) with one input are called unary EE 345 – Micro-Controllers 21 December 2021 3
George Boole n n n Father of Boolean algebra He came up with a type of linguistic algebra, the three most basic operations of which were (and still are) AND, OR and NOT. It was these three functions that formed the basis of his premise, and were the only operations necessary to perform comparisons or basic mathematical functions. Boole’s system (detailed in his 'An Investigation of the Laws of Thought, on Which Are Founded the Mathematical Theories of Logic and Probabilities', 1854) was based on a binary approach, processing only two objects - the yes-no, true-false, on-off, zero-one approach. n n Surprisingly, given his standing in the academic community, Boole's idea was either criticized or completely ignored by the majority of his peers. Eventually, one bright student, Claude Shannon (19162001), picked up the idea and ran with it EE 345 – Micro-Controllers 21 December 2021 George Boole (1815 - 1864) 4
Axioms of Algebraic Structures n A set of elements B and two binary operators + and‧ 1. 2. 3. Closure w. r. t. the operator(‧) + x, y ∈B ∋ x+y ∈B Associative w. r. t. + (‧) (x+y)+z =x+ (y+z) (x‧y) ‧z =x‧ (y‧z) Commutative w. r. t(‧) +. x+y = y+x x‧y = y‧x EE 345 – Micro-Controllers 21 December 2021 5
Axioms of Algebraic Structures 4. 5. 6. ¡ An identity element w. r. t. + (‧) 0+x = x+0 = x ‧ 1 x = x‧ 1= x ∀x ∈ B, ∃ x' ∈ B (complement of x( ∈x+x'=1 and x‧x'=0 ‧is distributive over +: x‧(y+z)=(x‧y)+(x‧z( +is distributive over‧: x+(y‧z)=(x+y)‧(x+z( Note the associative law can be derived no additive and multiplicative inverses complement EE 345 – Micro-Controllers 21 December 2021 6
Boolean Algebra n We need to define algebra for binary values ¡ n Developed by George Boole in 1854 Huntington postulates for Boolean algebra (1904): ¡ ¡ ¡ Closure with respect to operator + and operator · Identity element 0 for operator + and 1 for operator · Commutativity with respect to + and · x+y = y+x, x·y = y·x ¡ Distributivity of · over +, and + over · x·(y+z) = (x·y)+(x·z) and x+(y·z) = (x+y)·(x+z) ¡ ¡ Complement for every element x is x’ with x+x’=1, x·x’=0 There at least two elements x, y B such that x y EE 345 – Micro-Controllers 21 December 2021 7
Boolean Algebra n n VERY good tool used to manipulate (simplify) Boolean functions Terminology: ¡ ¡ ¡ Literal: A variable or its complement Product term: literals connected by • Sum term: literals connected by + EE 345 – Micro-Controllers 21 December 2021 8
Two-valued Boolean Algebra n Two-valued Boolean is defined as ¡ A set of elements B = {0, 1} + operator: · operator: x y x+y 0 0 0 0 1 1 0 1 0 1 1 0 0 1 1 1 inverse: n Observation? + is OR, · is AND, ’ is NOT EE 345 – Micro-Controllers 21 December 2021 x y x·y x x' 0 1 1 0 9
Boolean Algebra Properties Let X: boolean variable, 0, 1: constants 1. 2. 3. 4. 5. 6. 7. 8. 9. X+0=X X • 1 =X X+1 =1 X • 0 =0 X+X=X X • X =X X + X’ = 1 X • X’ = 0 (X’)’ = X EE 345 – Micro-Controllers -- Zero Axiom -- Unit Property -- Zero Property -- Idepotence -- Complement -- Involution 21 December 2021 10
Duality n n n The principle of duality is an important concept. This says that if an expression is valid in Boolean algebra, the dual of that expression is also valid. To form the dual of an expression, replace all + operators with. operators, all. operators with + operators, all ones with zeros, and all zeros with ones. Form the dual of the expression a + (bc) = (a + b)(a + c) n Following the replacement rules… a(b + c) = ab + ac n Be careful not to alter the location of the parentheses if they are present. EE 345 – Micro-Controllers 21 December 2021 11
Basic Theorems and Properties of Boolean Algebra n Duality ¡ ¡ the binary operators are interchanged; AND <-> OR the identity elements are interchanged; 1 <-> 0 EE 345 – Micro-Controllers 21 December 2021 12
Boolean Theorems n Huntington’s postulates define some rules n Need more rules to modify algebraic expressions Post. ¡ n closure (a) x+0=x, (b) x· 1=x (a) x+y=y+x, (b) x·y=y·x (a) x(y+z) = xy+xz, (b) x+yz = (x+y)(x+z) Post. 5: (a) x+x’=1, (b) x·x’=0 Theorems that are derived from postulates What is a theorem? ¡ n 1: 2: 3: 4: A formula or statement that is derived from postulates (or other proven theorems) Basic theorems of Boolean algebra ¡ ¡ Theorem 1 (a): x + x = x (b): x · x = x Looks straightforward, but needs to be proven ! EE 345 – Micro-Controllers 21 December 2021 13
Proof of x+x=x n n We can only use Huntington postulates: Post. 2: (a) x+0=x, (b) x· 1=x Post. 3: (a) x+y=y+x, (b) x·y=y·x Post. 4: (a) x(y+z) = xy+xz, (b) x+yz = (x+y)(x+z) Post. 5: (a) x+x’=1, (b) x·x’=0 Show that x+x=x. x+x n Huntington postulates: = (x+x)· 1 = (x+x)(x+x’) = x+xx’ = x+0 =x Q. E. D. by 2(b) by 5(a) by 4(b) by 5(b) by 2(a) We can now use Theorem 1(a) in future proofs EE 345 – Micro-Controllers 21 December 2021 14
Proof of x·x=x n n Similar to previous proof Huntington postulates: Post. 2: (a) x+0=x, (b) x· 1=x Post. 3: (a) x+y=y+x, (b) x·y=y·x Post. 4: (a) x(y+z) = xy+xz, (b) x+yz = (x+y)(x+z) Post. 5: (a) x+x’=1, (b) x·x’=0 Th. 1: (a) x+x=x Show that x·x = x. x·x EE 345 – Micro-Controllers = xx+0 = xx+xx’ = x(x+x’) = x· 1 =x Q. E. D. by 2(a) by 5(b) by 4(a) by 5(a) by 2(b) 21 December 2021 15
Absorption Property (Covering) 1. 2. n x + x • y = x x • (x+y) = x (dual) Proof: x + x • y = x • 1 + x • y = x • (1+y) = x • 1 =x QED (2 true by duality) EE 345 – Micro-Controllers 21 December 2021 16
Consensus Theorem 1. 2. n xy + x’z + yz = xy + x’z (x+y) • (x’+z) • (y+z) = (x+y) • (x’+z) -- (dual) Proof: xy + x’z + yz = xy + x’z + (x+x’)yz = xy + x’z + xyz + x’yz = (xy + xyz) + (x’z + x’zy) = xy + x’z QED (2 true by duality). EE 345 – Micro-Controllers 21 December 2021 17
Theorems to Apply to Exclusive-OR EE 345 – Micro-Controllers 21 December 2021 18
Boolean Functions n Elements and operators can express a function ¡ ¡ n Value of function determined by value of variables Complete function is evaluated for all possible values Function can be represented by truth table ¡ E. g. , F 1 = x + y’z n Evaluate in steps ¡ E. g. , y’ and y’z EE 345 – Micro-Controllers x y z y' y'z x+y'z 0 0 0 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 0 1 1 0 0 1 21 December 2021 19
Logic Circuit Diagram of Function n Logic function can be expressed as circuit diagram ¡ Direct translation from algebraic expression n Example: F 1 = x + y’z n Problem: possibly multiple equivalent algebraic expressions ¡ Difficult to compare Boolean functions EE 345 – Micro-Controllers 21 December 2021 20
Design Problem n Design the control logic for a fan in a greenhouse. The logic must sense three environmental conditions: 1. 2. 3. It is raining outside (variable x) It is humid inside (variable y) It is hot inside (variable z) F The fan should turn on when n It is humid AND it is not raining AND it is hot yx’z OR n It is not humid AND ((its not raining AND it is hot) OR it is raining) y’ (x’z+x) n Create a Boolean function that controls the fan. F 1 = yx’z + y’(x’z+x) ¡ F 2 = x’y’z+x’yz+xy’; F 3 = x’z+xy’ Question: How to evaluate these solutions (equivalent functions)? ¡ n EE 345 – Micro-Controllers 21 December 2021 21
Boolean Function Representations Greenhouse example function can be expressed as: n Analytically, as sum of minterms: yx’z + y’(x’z+x) § = x’yz+x’y’z+xy’(z+z’) = x’yz+x’y’z+xy’z’ As a truth table x y z F 2 0 0 0 1 1 1 1 0 0 1 1 1 0 EE 345 – Micro-Controllers = yx’z+y’x § As a logic network § How to derive different solutions ? § How to evaluate these solutions ? 21 December 2021 22
Comparison of Boolean Functions n n How to compare expressions? From the Greenhouse Example: ¡ ¡ n Is yx’z + y’(x’z+x) = x’z+xy’ ? (are these functions equivalent? ) yx’z + y’(x’z+x) = yx’z+y’x = (y+y’)x’z+y’x = x’z+xy’ Yes, both expressions describe the same function (equivalent) Problem: hard to compare algebraic expressions ¡ Easier with gate level comparison? EE 345 – Micro-Controllers 21 December 2021 23
Comparison of Boolean functions n Comparison by algebraic expression ¡ ¡ n Comparison on gate level ¡ ¡ n Bad: same as algebraic expression Bad: hard to modify for comparison Comparison by truth table ¡ ¡ ¡ n Good: can handle many variables Bad: not clear how to get one expression from another Good: Only one representation in truth table Bad: cumbersome for 4 or more variables Bad: hard to derive gate level implementation Comparison with canonical form ¡ ¡ Good: standardized form for algebraic expression Bad: not necessarily solution with least number of gates EE 345 – Micro-Controllers 21 December 2021 24
Canonical Forms n A form is canonical if representation of a function in this form is unique ¡ ¡ n A minterm is a product (ANDing) of all variables ¡ ¡ n n Truth table is canonical representation Uses minterms as basic component Each variable of function appears in minterm Variable is in normal form (x) or in complemented form (x’) Example: minterms for 3 -variable function x y z 0 0 0 x'y'z' m 0 0 0 1 x'y'z m 1 0 x'yz' m 2 0 1 1 x'yz m 3 1 0 0 xy'z' m 4 1 0 1 xy'z m 5 1 1 0 xyz' m 6 1 1 xyz m 7 1 All algebraic expressions can be converted into canonical form EE 345 – Micro-Controllers 21 December 2021 minterm designation 25
Canonical Forms Function is expressed as sum of minterms Greenhouse example: yx’z + y’(x’z+x) = n n yx’z+y’x minter m designation x y z F 0 0 x'y'z' m 0 0 0 1 1 x'y'z m 1 0 0 x'yz' m 2 0 1 1 1 x'yz m 3 1 0 0 1 xy'z' m 4 1 0 1 1 xy'z m 5 1 1 0 0 xyz' m 6 1 1 1 0 xyz m 7 = x’yz+x’y’z+xy’(z+z’) = x’yz+x’y’z+xy’z’ = m 3 + m 1 + m 5 + m 4 § Function = sum of all minterms where truth table is 1 EE 345 – Micro-Controllers 21 December 2021 26
Canonical Forms n n Canonical form: Sum of minterms Example: F=A+B’C ¡ ¡ Expansion of minterms: A = ABC+ABC’+AB’C’ B’C = AB’C+A’B’C F = ABC+ABC’+AB’C+ AB’C’+A’B’C n Alternate forms: ¡ ¡ n F=m 1+m 4+m 5+m 6+m 7 F=∑(1, 4, 5, 6, 7) A B C F minterm designation 0 0 A'B'C' m 0 0 0 1 1 A'B'C m 1 0 0 A'BC' m 2 0 1 1 0 A'BC m 3 1 0 0 1 AB'C' m 4 1 0 1 1 AB'C m 5 1 1 0 1 ABC' m 6 1 1 ABC m 7 Is this the only canonical form? ¡ No, other forms exist (dual form, etc. ) EE 345 – Micro-Controllers 21 December 2021 27
De. Morgan’s Theorem n n A key theorem in simplifying Boolean expressions De. Morgan’s theorem expresses duality: ¡ For two variables: (x + y)’ = x’ y’ (x y)’ = x’ + y’ ¡ Can be generalized to arbitrary number of variables (a+b+c+ …+z)’ = a’ b’ c’… z’ , or ( xi)’ = xi’ (a b c z)’ = a’+b’+c’+…+z’ , or ( xi)’ = xi’ where: n = OR, = AND Proof for De. Morgan’s theorem by truth tables ¡ See Mano p. 59 EE 345 – Micro-Controllers 21 December 2021 28
Dual Canonical Form n Sum of minterms can be converted to product of maxterms ¡ ¡ ¡ n Due to duality: ¡ n mj ’ = M j Example: ¡ ¡ ¡ n Maxterms contain every variable in the function Each maxterm is an OR of variables in different polarities Function is a product (ANDing) of maxterms where truth table is 0 F = M 0·M 2·M 3 = = (A+B+C)(A+B’+C’) From De. Morgan: F’ = A’B’C’+A’BC = = m 0+m 2+m 3 Complement on both sides: F = m 1+m 4+m 5+m 6+m 7 A B C F Maxterm Designation 0 0 A+B+C M 0 0 0 1 1 A+B+C’ M 1 0 0 A+B’+C M 2 0 1 1 0 A+B’+C’ M 3 1 0 0 1 A’+B+C M 4 1 0 1 1 A’+B+C’ M 5 1 1 0 1 A’+B’+C M 6 1 1 A’+B’+C’ M 7 Both canonical forms express same function EE 345 – Micro-Controllers 21 December 2021 29
Dual Canonical Form n Sum of minterms can be converted to product of maxterms n Recall: ¡ ¡ n A minterm is a product (AND) of all variables in respective polarities (positive or complemented) e. g. , a’ b c’ is a minterm for a 3 -variable function Note: a b’ is not a minterm in a 3 -variable function (it is a product term) Function is OR of minterms where F = 1 A maxterm is a sum (OR) of all variables in respective polarities ¡ ¡ ¡ Maxterm contains every variable in the function All the variables are OR-ed together in a maxterm Function is product (AND) of maxterms where F = 0 EE 345 – Micro-Controllers 21 December 2021 30
Dual Canonical Form n Duality (De. Morgan): ¡ ( xi)’ = xi’ ¡ n Example: F = (m 1, m 4, m 5, m 6, m 7) ¡ ¡ ¡ n m’j = Mj Examine the complement of F: F’ = m 0+m 2+m 3 = A’B’C’ + A’BC Take a complement (De. Morgan): (F’)’ = (A+B+C)(A+B’+C’) = M 0·M 2·M 3 Since (F’)’ = F : F = M 0·M 2·M 3 = m 1+m 4+m 5+m 6+m 7 A B C F Maxterm Designation 0 0 A+B+C M 0 0 0 1 1 A+B+C’ M 1 0 0 A+B’+C M 2 0 1 1 0 A+B’+C’ M 3 1 0 0 1 A’+B+C M 4 1 0 1 1 A’+B+C’ M 5 1 1 0 1 A’+B’+C M 6 1 1 A’+B’+C’ M 7 Both canonical forms express same function: ¡ F = mi = Mi EE 345 – Micro-Controllers 21 December 2021 31
Example n n Truth table for f 1(a, b, c) at right The canonical sum-of-products form for f 1 is f 1(a, b, c) = m 1 + m 2 + m 4 + m 6 = a’b’c + a’bc’ + ab’c’ + abc’ The canonical product-of-sums form for f 1 is f 1(a, b, c) = M 0 • M 3 • M 5 • M 7 = (a+b+c) • (a+b’+c’) • (a’+b’+c’). Observe that: mj = Mj’ EE 345 – Micro-Controllers 21 December 2021 a b c f 1 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 0 32
Shorthand: ∑ and ∏ n n n f 1(a, b, c) = ∑ m(1, 2, 4, 6), where ∑ indicates that this is a sum-of-products form, and m(1, 2, 4, 6) indicates that the minterms to be included are m 1, m 2, m 4, and m 6. f 1(a, b, c) = ∏ M(0, 3, 5, 7), where ∏ indicates that this is a product-of-sums form, and M(0, 3, 5, 7) indicates that the maxterms to be included are M 0, M 3, M 5, and M 7. Since mj = Mj’ for any j, ∑ m(1, 2, 4, 6) = ∏ M(0, 3, 5, 7) = f 1(a, b, c) EE 345 – Micro-Controllers 21 December 2021 33
Conversion between Canonical Forms n n Replace ∑ with ∏ (or vice versa) and replace those j’s that appeared in the original form with those that do not. Example: f 1(a, b, c) = a’b’c + a’bc’ + ab’c’ + abc’ = m 1 + m 2 + m 4 + m 6 = ∑(1, 2, 4, 6) = ∏(0, 3, 5, 7) = (a+b+c) • (a+b’+c’) • (a’+b’+c’) EE 345 – Micro-Controllers 21 December 2021 34
Standard Forms (NOT Unique) n n n Standard forms are “like” canonical forms, except that not all variables need to appear in the individual product (SOP) or sum (POS) terms. Example: f 1(a, b, c) = a’b’c + bc’ + ac’ is a standard sum-of-products form f 1(a, b, c) = (a+b+c) • (b’+c’) • (a’+c’) is a standard product-of-sums form. EE 345 – Micro-Controllers 21 December 2021 35
Conversion of SOP from standard to canonical form n n n Expand non-canonical terms by inserting equivalent of 1 in each missing variable x: (x + x’) = 1 Remove duplicate minterms f 1(a, b, c) = a’b’c + bc’ + ac’ = a’b’c + (a+a’)bc’ + a(b+b’)c’ = a’b’c + abc’ + a’bc’ + ab’c’ = a’b’c + abc’ + a’bc + ab’c’ EE 345 – Micro-Controllers 21 December 2021 36
Conversion of POS from standard to canonical form n n n Expand noncanonical terms by adding 0 in terms of missing variables (e. g. , xx’ = 0) and using the distributive law Remove duplicate maxterms f 1(a, b, c) = (a+b+c) • (b’+c’) • (a’+c’) = (a+b+c) • (aa’+b’+c’) • (a’+bb’+c’) = (a+b+c) • (a+b’+c’) • (a’+b+c’) • (a’+b’+c’) =(a+b+c) • (a+b’+c’) • (a’+b+c’) EE 345 – Micro-Controllers 21 December 2021 37
Sum of Product (SOP) Form n Any function can be expressed as Sum of Products (SOP) ¡ ¡ ¡ n A product term is a product (AND) of the variables in respective polarities Minterm is a special case of product term (has all variables) SOP is not canonical, many SOP forms exist for same function Greenhouse example: § SOP table (list only for F=1) x y z F 0 0 1 1 1 1 0 -- 1 EE 345 – Micro-Controllers yx’z + y’(x’z+x) = x’yz + x’y’z + x y’ = x’z + xy’ SOP has natural representation in practice, as two-level logic network 21 December 2021 38
Counting Boolean Functions n Now we can express algebraic functions uniquely ¡ n Unique sum of minterms or product of maxterms representations How many binary Boolean functions exist? ¡ ¡ ¡ How many different combinations of minterms can one pick? There are 4 minterms in a binary function Each minterm can be present in the sum or not n ¡ n Two choices for each minterm Total 24=16 combinations How many Boolean functions exist with n variables? ¡ 2 n minterms ¡ Total: 22 n combinations EE 345 – Micro-Controllers 21 December 2021 39
Truth Table of Two Binary Variables EE 345 – Micro-Controllers 21 December 2021 40
Possible combinations of Binary Boolean Functions EE 345 – Micro-Controllers 21 December 2021 41
Digital Logic Gates Name EE 345 – Micro-Controllers Graphics Symbols 21 December 2021 Algebraic Function Truth Table 42
Digital Logic Gates Name EE 345 – Micro-Controllers Graphics Symbols Algebraic Function 21 December 2021 Truth Table 43
Multiple-input Gates n NOR does not extend easily Associativity does not hold ¡ z n Multiple-input gate: EE 345 – Micro-Controllers 21 December 2021 44
Multiple Input NAND and NOR n n Multiple NOR = a complement of OR gate Multiple NAND = a complement of AND gate The cascaded NAND operations = sum of products The cascaded NOR operations = product of sums EE 345 – Micro-Controllers 21 December 2021 45
Multiple-input XOR n Extension of exclusive-OR not straightforward ¡ n Turns into “odd” function ¡ n What is the definition for 3 variables? Function is 1 when there is an odd number of 1’s Uncommon in hardware implementations EE 345 – Micro-Controllers 21 December 2021 46
Positive and Negative Logic n Signal levels are represented as H (high) and L (low) ¡ n Positive logic ¡ ¡ n H corresponds to logic 1 L corresponds to logic 0 Negative logic ¡ ¡ n e. g. , H is 5 V and L is 0 V H corresponds to logic 0 L corresponds to logic 1 User has choice of logic used EE 345 – Micro-Controllers 21 December 2021 47
Positive and Negative Logic n Truth table with H and L n In positive logic: AND n In negative logic: OR Arrows indicate negative logic EE 345 – Micro-Controllers 21 December 2021 48
Integrated Circuits n Small-scale integration (SSI) ¡ ¡ n Medium-scale integration (MSI) ¡ ¡ n ¡ 1000’s – 10, 000’s of logic gates Mid 1970’s Very large-scale integration (VLSI) ¡ ¡ n 100’s – 1000’s of logic gates Late 1960’s Large-scale integration (LSI) ¡ n 10’s of logic gates Early 1960’s 100, 000’s of logic gates 1980’s Ultra large-scale integration (ULSI) ¡ ¡ Millions of logic gates 1990’s and 2000’s EE 345 – Micro-Controllers 21 December 2021 49
EE 345 – Micro-Controllers 21 December 2021 50
Logic Families n TTL: transistor-transistor Logic ¡ ¡ n ECL: emitter-coupled logic ¡ n High speed of operation MOS: metal-oxide semiconductor ¡ n Standard family, very familiar Used for a long time Suitable for circuits that need high component density CMOS: complementary metal-oxide semiconductor ¡ Suitable for systems requiring low power consumption, such as digital cameras and hand-held digital devices EE 345 – Micro-Controllers 21 December 2021 51
Characteristics of Digital Logic Families n n n Fan-out: number of standard loads that the ouput of a typical gate can drive Fan-in: number of inputs available in a gate Power dissipation: power consumed by gate Propagation delay: average transition delay time for the signal to propagate from input to output Noise margin: minimum external noise voltage added to input signal that caused an undesirable change in the circuit output EE 345 – Micro-Controllers 21 December 2021 52
Chip Design n Why is it better to have more gates on a single chip? ¡ ¡ ¡ n What are the drawbacks of large circuits? ¡ ¡ ¡ n Easier to build systems Lower power consumption Higher clock frequencies Complex to design Chips have design constraints Hard to test Need tools to help develop integrated circuits ¡ ¡ Computer Aided Design (CAD) tools Automate tedious steps of design process Hardware description language (HDL) describe circuits VHDL is one such system (approved as standard by IEEE) EE 345 – Micro-Controllers 21 December 2021 53
- Slides: 53