1 / 46

Hardened or Softened by Afflictions

Hardened or Softened by Afflictions. Alma 62:41

lavender
Download Presentation

Hardened or Softened by Afflictions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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. Discussion #21 – Boolean Algebra

  2. Lecture 21 – Binary Numbers & Boolean Algebra Discussion #21 – Boolean Algebra

  3. Signed Binary Integers 3 common representations for signed integers: • Sign magnitude • 1’s compliment • 2’s compliment For all 3 the MSB encodes the sign: 0 = + 1 = - Most common for computers Discussion #21 – Boolean Algebra

  4. Sign-Magnitude Range: Representations • 01111binary => 15decimal • 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 = - Discussion #21 – Boolean Algebra

  5. 1’s Complement Range: Representations • 00110binary => 6decimal • 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 = - Discussion #21 – Boolean Algebra

  6. Two’s Complement • Problems with sign-magnitude and 1’s complement • two representations of zero (+0 and –0) • arithmetic circuits are complex • Two’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) Discussion #21 – Boolean Algebra

  7. 00101 (5)01001 (9) 11010 (1’s comp)(1’s comp) + 1+ 1 11011 (-5)(-9) 10110 10111 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 MSB still encodes the sign: 0 = + 1 = - Discussion #21 – Boolean Algebra

  8. 2’s Complement • Positional number representation with a twist • MSB has a negativeweight 0110 = 22 + 21 = 6 1110 = -23 + 22 + 21 = -2 Discussion #2 – Chapter 2

  9. 2’s Complement • Positional number representation with a twist • MSB has a negativeweight 0110 = 22 + 21 = 6 1110 = -23 + 22 + 21 = -2 –MSB Discussion #2 – Chapter 2

  10. 2’s Complement • Positional number representation with a twist • MSB has a negativeweight 0110 = 22 + 21 = 6 1110 = -23 + 22 + 21 = -2 –MSB + remaining bits Discussion #2 – Chapter 2

  11. 2’s Complement • Positional number representation with a twist • MSB has a negativeweight 0110 = 22 + 21 = 6 1110 = -23 + 22 + 21 = -2 –MSB + remaining bits 11111111 Discussion #2 – Chapter 2

  12. 2’s Complement • Positional number representation with a twist • MSB has a negativeweight 0110 = 22 + 21 = 6 1110 = -23 + 22 + 21 = -2 –MSB + remaining bits 11111111 Discussion #2 – Chapter 2

  13. 2’s Complement • Positional number representation with a twist • MSB has a negativeweight 0110 = 22 + 21 = 6 1110 = -23 + 22 + 21 = -2 –MSB + remaining bits = –1 11111111 = -27 + 26 + 25 + 24 + 23 + 22 + 21 + 20 Discussion #2 – Chapter 2

  14. Two’s Complement Shortcut • To take the two’s complement of a number: • copy bits from right to left until (and including) the first 1 • flip remaining bits to the left 011010000011010000 100101111 (1’s comp) + 1 100110000 100110000 (flip) (copy) Discussion #21 – Boolean Algebra

  15. Two’s Complement Example 3: What is 01101012 in decimal? What is it’s 2’s complement? Discussion #21 – Boolean Algebra

  16. Two’s Complement Example 3: What is 01101012 in decimal? What is it’s 2’s complement? 01101012 = 026 + 125+ 124 + 023+ 122+ 021+ 120 = 5310 Discussion #21 – Boolean Algebra

  17. Two’s Complement Example 3: What is 01101012 in decimal? What is its 2’s complement? 01101012 = -026 + 125+ 124 + 023+ 122+ 021+ 120 = 5310 0110101 (53) 1001010 (1’s comp) + 1 1001011 (-53) Discussion #21 – Boolean Algebra

  18. Two’s Complement Negation • To negate a number, invert all the bits and add 1 (or use shortcut) 6 1010 7 1001 0 0000 -1 0001 4 1100 -8 1000 (??) Discussion #21 – Boolean Algebra

  19. Signed Binary Numbers Discussion #25 – Final Review

  20. Addition with 2’s Complement numbers • With 2’s complement, addition of negative numbers is the same as regular addition • To do subtraction, take 2’s complement and add 0011 (3) + 1111(-1 in 2’s comp) 0010 (2) 1111 (-1 in 2’s comp) + 1111(-1 in 2’s comp) 1110 (-2 in 2’s comp) (discard carry) (discard carry) 0011 (3) + 1101(-3 in 2’s comp) 0000 (0) 0001 (1) + 1101(-3 in 2’s comp) 1110 (-2 in 2’s comp)

  21. Addition with 2’s Complement numbers • Overflow or underflow can occur is sum is larger than largest value that can be represented • Use sign bit consistency to identify (flag) error 0111 (7) + 0001(1) 1000 (-8)! 1001 (-7 in 2’s comp) + 1110(-2 in 2’s comp) 0111 (7)! 0011 (3) + 0110(6) 1001 (-7)! 1101 (-3 in 2’s comp) + 1010(-6 in 2’s comp) 0111 (7)!

  22. 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. Discussion #21 – Boolean Algebra

  23. Decimal to Binary Conversion 0101 0110 01111011 00100011 1011101 01111101111 Discussion #21 – Boolean Algebra

  24. 0x is a common prefix for writing numbers which means hexadecimal Hexadecimal Notation • Binary is hard to read and write by hand • Hexadecimal is a common alternative • 16 digits are 0123456789ABCDEF Binary Hex Dec 0000 0 00001 1 10010 2 20011 3 30100 4 40101 5 50110 6 60111 7 71000 8 81001 9 91010 A 101011 B 111100 C 121101 D 131110 E 141111 F 15 0100 0111 1000 1111 = 0x478F 1101 1110 1010 1101 = 0xDEAD 1011 1110 1110 1111 = 0xBEEF 1010 0101 1010 0101 = 0xA5A5 • Separate binary code into groups of 4 bits (starting from the right) • Translate each group into a single hex digit Discussion #21 – Boolean Algebra

  25. Binary to Hex Conversion • Every four bits is a hex digit. • start grouping from right-hand side 011101010001111010011010111 3 A 8 F 4 D 7 This is not a new machine representation,just a convenient way to write the number. Discussion #21 – Boolean Algebra

  26. Boolean Algebra Discussion #21 – Boolean Algebra

  27. 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 Discussion #21 – Boolean Algebra

  28. Logic Functions 3 different ways to represent logic functions: Equation: a mathematical representation of a logic function A bar over a variable represent an inverting or a NOT operation 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 Discussion #21 – Boolean Algebra

  29. Logic Functions 3 different ways to represent logic functions: Gates: a visual block representation of the function Top-level inputs Final output Four 3-input AND gates feeding into one 4-input OR gate Discussion #21 – Boolean Algebra

  30. Logic Functions 3 different ways to represent logic functions: Truth Table: indicates what the output will be for every possible input combination There will always be at least one output (right-hand columns) If there are n inputs (left-hand columns) there will be 2n entries (rows) in the table EX: 3 inputs require 23 = 8 rows For each input combination (row) outputs will be either 0 or 1 Discussion #21 – Boolean Algebra

  31. The Inverter OUT IN OUT IN Gate Inverter Symbols Usually abbreviated with just a ‘bubble’ next to another gate input/output Truth-table Equation Discussion #21 – Boolean Algebra

  32. AND Symbol The AND Gate A OUT B Gate Truth Table Equation NB: multiplication operation → AND Discussion #21 – Boolean Algebra

  33. OR Symbol The OR Gate A OUT B Gate Truth Table Equation NB: addition operation → OR Discussion #21 – Boolean Algebra

  34. NAND Symbols The NAND Gate (NOT-AND) A A OUT OUT B B Gate Truth Table Equation Discussion #21 – Boolean Algebra

  35. NOR Symbols The NOR Gate (NOT-OR) A A OUT OUT B B Gate Truth Table Equation Discussion #21 – Boolean Algebra

  36. You should know how to Translate These are three different ways of representing logical information You can convert any one of them to any other LogicEquations LogicGates TruthTables Discussion #21 – Boolean Algebra

  37. Equations to Gates OR Discussion #21 – Boolean Algebra

  38. Equations to Gates OR y s y a OR b y Discussion #21 – Boolean Algebra

  39. out Gates to Equations Discussion #21 – Boolean Algebra

  40. out Gates to Equations OR Discussion #21 – Boolean Algebra

  41. Truth Tables to Gates • Each row of truth table is an AND gate • Each output column is an OR gate Discussion #21 – Boolean Algebra

  42. Truth Tables to Gates • Each row of truth table is an AND gate • Each output column is an OR gate s a b s a b out s a b s a b Discussion #21 – Boolean Algebra

  43. Truth Table to Equations • Write out truth table a combination of AND’s and OR’s • equivalent to gates • easily converted to gates Discussion #21 – Boolean Algebra

  44. Truth Table to Equations • Write out truth table a combination of AND’s and OR’s • equivalent to gates • easily converted to gates Discussion #21 – Boolean Algebra

  45. Equations to Truth Tables • For each AND term • fill in the proper row on the truth table Discussion #21 – Boolean Algebra

  46. Equations to Truth Tables • For each AND term • fill in the proper row on the truth table Discussion #21 – Boolean Algebra

More Related