ECEN 301Discussion #21 – Boolean Algebra1 DateDayClass No. TitleChaptersHW Due date Lab Due date Exam 12 NovWed21Boolean Algebra13.2 – 13 EXAM 2 13 NovThu 14 NovFriRecitation 15 NovSat 16 NovSun 17 NovMon22Combinational Logic13.3 – 13.5 LAB NovTue 19 NovWed23Sequential Logic14.1 Schedule…
ECEN 301Discussion #21 – Boolean Algebra2 Hardened or Softened by Afflictions Alma 62:41 41 But behold, because of the exceedingly great length of the war between the Nephites and the Lamanites many had become hardened, because of the exceedingly great length of the war; and many were softened because of their afflictions, insomuch that they did humble themselves before God, even in the depth of humility.
ECEN 301Discussion #21 – Boolean Algebra3 Lecture 21 – Binary Numbers & Boolean Algebra
ECEN 301Discussion #21 – Boolean Algebra4 Signed Binary Integers 3 common representations for signed integers: 1.Sign magnitude 2.1’s compliment 3.2’s compliment Most common for computers For all 3 the MSB encodes the sign: 0 = + 1 =
ECEN 301Discussion #21 – Boolean Algebra5 Sign-Magnitude Range: Representations Ù01111 binary => 15 decimal Ù11111=> -15 Ù00000=> 0 Ù10000=> -0 Problem ÙDifficult addition/subtraction check signs convert to positive use adder or subtractor as required ÙHow to add two sign-magnitude numbers? Ex: 1 + (-4) The MSB encodes the sign: 0 = + 1 =
ECEN 301Discussion #21 – Boolean Algebra6 1’s Complement Range: Representations Ù00110 binary => 6 decimal Ù11001=> -6 Ù00000=> 0 Ù11111=> -0 Problem ÙDifficult addition/subtraction no need to check signs as before cumbersome logic circuits end-around-carry ÙHow to add to one’s complement numbers? Ex: 4 + (-3) To negate a number, Invert it, bit-by-bit. MSB still encodes the sign: 0 = + 1 =
ECEN 301Discussion #21 – Boolean Algebra7 Two’s Complement uProblems with sign-magnitude and 1’s complement Ùtwo representations of zero (+0 and –0) Ùarithmetic circuits are complex uTwo’s complement representation developed to make circuits easy for arithmetic. Ùonly one representation for zero Ùjust ADD the two numbers to get the right answer (regardless of sign)
ECEN 301Discussion #21 – Boolean Algebra8 Two’s Complement Range: Representation: ÙIf number is positive or zero, normal binary representation, zeroes in upper bit(s) ÙIf number is negative, start with positive number flip every bit (i.e., take the one’s complement) then add one (5) (9) (1’s comp)(1’s comp) (-5)(-9) MSB still encodes the sign: 0 = + 1 =
ECEn/CS 124Discussion #2 – Chapter 29 2’s Complement uPositional number representation with a twist ÙMSB has a negative weight 0110 = = = = -2
ECEn/CS 124Discussion #2 – Chapter 210 2’s Complement uPositional number representation with a twist ÙMSB has a negative weight 0110 = = = = -2 –MSB
ECEn/CS 124Discussion #2 – Chapter 211 2’s Complement uPositional number representation with a twist ÙMSB has a negative weight 0110 = = = = -2 –MSB + remaining bits
ECEn/CS 124Discussion #2 – Chapter 212 2’s Complement uPositional number representation with a twist ÙMSB has a negative weight 0110 = = = = -2 –MSB + remaining bits
ECEn/CS 124Discussion #2 – Chapter 213 2’s Complement uPositional number representation with a twist ÙMSB has a negative weight 0110 = = = = -2 –MSB + remaining bits
ECEn/CS 124Discussion #2 – Chapter 214 2’s Complement uPositional number representation with a twist ÙMSB has a negative weight 0110 = = = = -2 –MSB + remaining bits = = –1
ECEN 301Discussion #21 – Boolean Algebra15 Two’s Complement Shortcut uTo take the two’s complement of a number: 1.copy bits from right to left until (and including) the first 1 2.flip remaining bits to the left (1’s comp) (copy)(flip)
ECEN 301Discussion #21 – Boolean Algebra16 Two’s Complement Example3: What is in decimal? What is it’s 2’s complement?
ECEN 301Discussion #21 – Boolean Algebra17 Two’s Complement Example3: What is in decimal? What is it’s 2’s complement? = 0 2 0 = 53 10
ECEN 301Discussion #21 – Boolean Algebra18 Two’s Complement Example3: What is in decimal? What is it’s 2’s complement? = 0 2 0 = (53) (1’s comp) (-53)
ECEN 301Discussion #21 – Boolean Algebra19 Two’s Complement Negation uTo negate a number, invert all the bits and add 1 (or use shortcut) (??)
ECEN 301Discussion #25 – Final Review20 Signed Binary Numbers Binary Sign-magnitude1’s compliment2’s complement
ECEN 301Discussion #21 – Boolean Algebra21 Decimal to Binary Conversion Positive numbers start with empty result if decimal number is odd, prepend ‘ 1 ’ to result else prepend ‘ 0 ’ divide number by 2, throw away fractional part (INTEGER divide) if number is non-zero, go back to else you are done Negative numbers do above for positive version of number and negate result.
ECEN 301Discussion #21 – Boolean Algebra22 Decimal to Binary Conversion
ECEN 301Discussion #21 – Boolean Algebra23 Hexadecimal Notation uBinary is hard to read and write by hand uHexadecimal is a common alternative 16 digits are ABCDEF = 0x478F = 0xDEAD = 0xBEEF = 0xA5A5 Binary Hex Dec A B C D E F15 0x is a common prefix for writing numbers which means hexadecimal 1.Separate binary code into groups of 4 bits (starting from the right) 2.Translate each group into a single hex digit
ECEN 301Discussion #21 – Boolean Algebra24 Binary to Hex Conversion uEvery four bits is a hex digit. Ùstart grouping from right-hand side D4F8A3 This is not a new machine representation, just a convenient way to write the number.
ECEN 301Discussion #21 – Boolean Algebra25 Boolean Algebra
ECEN 301Discussion #21 – Boolean Algebra26 Boolean Algebra Boolean Algebra: the mathematics associated with binary numbers ÙDeveloped by George Boole in 1854 Variables in boolean algebra can take only one of two possible values: 0 → FALSE 1 → TRUE
ECEN 301Discussion #21 – Boolean Algebra27 Logic Functions 3 different ways to represent logic functions: 1.Equation: a mathematical representation of a logic function Final logic output Each letter variable represents a top-level input to the logic function Mathematical operations (i.e. addition and multiplication) are boolean algebra operations A bar over a variable represent an inverting or a NOT operation
ECEN 301Discussion #21 – Boolean Algebra28 Logic Functions 3 different ways to represent logic functions: 2.Gates: a visual block representation of the function Four 3-input AND gates feeding into one 4-input OR gate Top-level inputs Final output
ECEN 301Discussion #21 – Boolean Algebra29 Logic Functions 3 different ways to represent logic functions: 3.Truth Table: indicates what the output will be for every possible input combination ABCZ If there are n inputs (left-hand columns) there will be 2 n entries (rows) in the table EX: 3 inputs require 2 3 = 8 rows There will always be at least one output (right-hand columns) For each input combination (row) outputs will be either 0 or 1
ECEN 301Discussion #21 – Boolean Algebra30 The Inverter INOUT Truth-table Inverter Symbols Gate Equation IN OUT IN OUT Usually abbreviated with just a ‘bubble’ next to another gate input/output
ECEN 301Discussion #21 – Boolean Algebra31 The AND Gate ABOUT AND Symbol Truth Table Gate Equation NB: multiplication operation → AND A B OUT
ECEN 301Discussion #21 – Boolean Algebra32 The OR Gate OR Symbol Equation Truth Table Gate ABOUT NB: addition operation → OR A B OUT
ECEN 301Discussion #21 – Boolean Algebra33 The NAND Gate ( NOT-AND ) NAND Symbols Equation Truth Table Gate ABOUT A B A B
ECEN 301Discussion #21 – Boolean Algebra34 The NOR Gate ( NOT-OR ) Equation Truth Table Gate ABOUT NOR Symbols A B OUT A B
ECEN 301Discussion #21 – Boolean Algebra35 You should know how to Translate Logic Equations Logic Gates Truth Tables These are three different ways of representing logical information You can convert any one of them to any other ABOUT
ECEN 301Discussion #21 – Boolean Algebra36 Equations to Gates OR
ECEN 301Discussion #21 – Boolean Algebra37 Equations to Gates s a b y y y OR
ECEN 301Discussion #21 – Boolean Algebra38 Gates to Equations out
ECEN 301Discussion #21 – Boolean Algebra39 Gates to Equations out OR
ECEN 301Discussion #21 – Boolean Algebra40 Truth Tables to Gates uEach row of truth table is an AND gate uEach output column is an OR gate SABOUT
ECEN 301Discussion #21 – Boolean Algebra41 Truth Tables to Gates uEach row of truth table is an AND gate uEach output column is an OR gate SABOUT out s a b s a b s a b s a b
ECEN 301Discussion #21 – Boolean Algebra42 Truth Table to Equations uWrite out truth table a combination of AND’s and OR’s Ùequivalent to gates Ùeasily converted to gates SABOUT
ECEN 301Discussion #21 – Boolean Algebra43 Truth Table to Equations uWrite out truth table a combination of AND’s and OR’s Ùequivalent to gates Ùeasily converted to gates SABOUT
ECEN 301Discussion #21 – Boolean Algebra44 Equations to Truth Tables uFor each AND term Ùfill in the proper row on the truth table
ECEN 301Discussion #21 – Boolean Algebra45 Equations to Truth Tables uFor each AND term Ùfill in the proper row on the truth table SABOUT