Boolean Logic  NOT, AND, OR

Boolean Logic  NOT, AND, OR

Boolean Algebra Based on syyg,gygmbolic logic, designed by George Boole Boolean variables take values as 0 or 1. Boolean expressions created from: Boolean logic NOT, AND, OR Introduction to Computer Yung-Yu Chuang with slides by Sedgewick & Wayne (introcs.cs.princeton.edu), Nisan & Schocken (www.nand2tetris.org) and Harris & Harris (DDCA) 2 NOT AND XY XY X X’ Digital gate diagram for NOT: Digital gate diagram for AND: NOT AND 3 4 OR Operator Precedence Examples showing the order of operations: X+Y NOT > AND > OR Dig ita l ga te diagram for OR: OR Use parentheses to avoid ambiguity 5 6 Defining a function Defining a function Description: square of x minus 1 Description: number of days of the x-th month of a Algebraic form : x2-1 non-leappy year x f(x) Enumeration: Algebraic form: ? xf(x) 131 Enumeration: 228 1 0 331 23 430 38 531 415 630 731 524 831 : : 930 10 31 11 30 12 31 7 8 Truth Table Proving the equivalence of two functions Truth table. Prove that x2-1=(x+1)(x-1) Systematic method to describe Boolean function. One row for each possible input combination. Using algebra: (you need to follow some rules) N N inputs 2 rows. (x+1)(x-1) = x2+x-x-1= x2-1 2 Using enumeration: x (x+1)(x-1) x -1 x y x y 1 0 0 0 0 0 23 3 0 1 0 1 0 0 38 8 1 1 1 4 15 15 AND truth table 52424 : : : 9 10 Important laws Simplifying Boolean Equations x + 1 = 1 x + y = y + x Example 1: x + 0 = x x + (y+z))( = (x+y) + z x + x = 1 • Y = AB + AB x.1 = x x.y = y.x x.0 = 0 x.(y.z) = (x.y).z x.x = 0 x.(y+z) = xy + xz DMDeMorgan Law x.y = x + y Chapter 2 <12> 11 Simplifying Boolean Equations Simplifying Boolean Equations Example 1: Example 2: • Y = AB + AB • Y = A(AB + ABC) = B(A + A) = B(1) = B Chapter 2 <13> Chapter 2 <14> Simplifying Boolean Equations DeMorgan’s Theorem A Example 2: • Y = AB = A + B Y B • Y = A(AB + ABC) A Y = A(AB(1 + C)) B = A(AB(1)) = A(AB) A (AA)B Y = (AA)B • Y = A + B = AB B = AB A Y B Chapter 2 <15> Chapter 2 <16> Bubble Pushing Bubble Pushing • Backward: • What is the Boolean expression for this – Body changes circuit? – Adds bubbles to inputs A A Y Y A B B B Y • Forward: C – Body changes D – Adds bubble to output A A Y Y B B Chapter 2 <17> Chapter 2 <18> Bubble Pushing Bubble Pushing Rules • What is the Boolean expression for this • Begin at output, then work toward inputs circuit? • Push bubbles on final output back • Draw gates in a form so bubbles cancel A B A Y B C D C Y D Y = AB + CD Chapter 2 <19> Chapter 2 <20> Bubble Pushing Example Bubble Pushing Example no output A A bubble B B C Y C Y D D Chapter 2 <21> Chapter 2 <22> Bubble Pushing Example Bubble Pushing Example no output no output A bubble A bubble B B C Y C Y D D bubble on bubble on A input and output A input and output B B C Y C Y D D no bubble on input and output A B C Y D Y = ABC + D Chapter 2 <23> Chapter 2 <24> Truth Tables (1 of 3) Truth Tables (2 of 3) A Boolean function has one or more Boolean Example: X Y inputs, and returns a single Boolean output. A truth table shows all the inputs and outputs of a Boolean function Example: X Y 25 26 Truth Tables (3 of 3) S Truth Table for Functions of 2 Variables When s=0, return x; otherwise, X mux Z Truth table. Y every 4-bit value represents one return y. 16 Boolean functions of 2 variables. Example: (Y S) (X S) Two-input multiplexer x y ZERO AND x y XOR OR 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 1 0 0 0 1 1 0 0 1 1 1 1 0 1 0 1 0 1 0 1 Truth table for all Boolean functions of 2 variables x y NOR EQ y' x' NAND ONE 0 0 1 1 1 1 1 1 1 1 0 1 0 0 0 0 1 1 1 1 1 0 0 0 1 1 0 0 1 1 1 1 0 1 0 1 0 1 0 1 Truth table for all Boolean functions of 2 variables 27 28 All Boolean functions of 2 variables Truth Table for Functions of 3 Variables Truth table. every 4-bit value represents one 16 Boolean functions of 2 variables. every 8-bit value represents one 256 Boolean functions of 3 variables. every 2n-bit value represents one 2^(2^n) Boolean functions of n variables! x y z AND OR MAJ ODD 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 1 0 1 0 0 0 1 0 1 1 0 1 0 1 1 0 1 1 0 0 1 1 0 1 1 1 1 1 1 1 some functions of 3 variables Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 29 30 Sum-of-Products Universality of AND, OR, NOT Sum-of-products. Systematic procedure for Fact. Any Boolean function can be expressed reppgresenting a Boolean function using g, AND, usingg,, AND, OR, NOT. proves that { AND, OR, NOT } Notation Meaning OR, NOT. are universal { AND, OR, NOT } are universal. x' NOT x Form AND term for each 1 in Boolean function. Ex: XOR(x,y) = xy' + x'y. xyx y x AND y OR terms together. x + y x OR y x y z MAJ x'yz xy'z xyz' xyz x'yz + xy'z + xyz' + xyz Expressing XOR Using AND, OR, NOT 0 0 0 0 0 0 0 0 0 x y x' y' x'y xy' x'''y + xy' x XOR y 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 1 0 1 1 0 1 1 1 1 0 0 0 1 1 0 0 1 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 1 1 0 1 0 0 1 Exercise. Show {AND, NOT}, {OR, NOT}, {NAND}, 1 1 0 1 0 0 1 0 1 1 1 1 1 0 0 0 1 1 {NOR} are universal. expressing MAJ using sum-of-products HH.int. DDMeMorg an's law w(: (x'y y)')' = x + y. 31 32 From Math to Real-World implementation Implementation of gates We can implement any Boolean function using Fluid switch (http://www.cs.princeton.edu/introcs/lectures/fluid-computer.swf NAND ggyates only. We talk about abstract Boolean algebra (logic) so far. Is it possible to realize it in real world? The tech nol ogy needs to permit switc hing and conducting. It can be built using magnetic, optica l, bio log ica l, hy drau lic and pneumatic mechanism. 33 Digital Circuits Wires What is a digital system? Wires. Analoggg: signals vary continuously . On (1): connected to power. Digital: signals are 0 or 1. 0 1 0 Off (0): not connected to power. 3.3V If a wire is connected to a wire that is on, that 2.8V wire is also on. 0.5V Typical drawing convention: "flow" from top, left 0.0V Whyyg digital sy stems? to bottom, ri ght. Accuracy and reliability. 1 Staggeringly fast and cheap. power connection 1 Basic abstractions. 1 On, off. Wire: propagates on/off value. 0 Swwppgf/ffuitch: controls propagation of on/off values through wires. 35 36 Controlled Switch Relay Controlled switch. [relay implementation] 3 connections: inppput, output, control. Magnetic force pulls on a contact that cuts electrical flow. Control wire affects output wire, but output does not affect control; establishes forward flow of informati on over ti me. X X 37 38 Circuit Anatomy Logic Gates: Fundamental Building Blocks 39 40 NOT NOT 0 1 1 0 41 42 OR Series relays = NOR 0 0 0 1 1 0 1 0 1 1 0 0 43 44 OR AND 45 46 AND Logic Gates: Fundamental Building Blocks 47 48 What about parallel relays? =NAND Can we implement AND/OR using parallel relays? Now we know how to implement AND,OR and 0 0 NOT. We can just use them as black boxes without knowing how they were implemented. Princippgle of information hiding. 1 1 0 1 49 50 Multiway Gates Multiway Gates Multiway gates. Multiway gates. OR: 1 if anyyp input is 1; 0 otherwise. OR: 1 if anyyp input is 1; 0 otherwise. AND: 1 if all inputs are 1; 0 otherwise. AND: 1 if all inputs are 1; 0 otherwise. Generalized: negate some inputs. Generalized: negate some inputs. 51 52 Multiway Gates Translate Boolean Formula to Boolean Circuit Multiway gates. Sum-of-products. XOR. Can also be built from 2-wayyg gates (less efficient but implementation independent) Example: build 4-way OR from 2-way ORs 53 54 Translate Boolean Formula to Boolean Circuit Translate Boolean Formula to Boolean Circuit Sum-of-products.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    27 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us