1 / 56

Digital Logic & Design Lecture 03

Digital Logic & Design Lecture 03. Recap. Number System Conversion Sum-of-Weights for converting to decimal Repeated division for converting from decimal Binary Arithmetic Similar to Decimal Arithmetic Multiplying by a constant by shifting left Dividing by a constant by shifting right.

Download Presentation

Digital Logic & Design Lecture 03

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. Digital Logic & Design Lecture 03

  2. Recap • Number System Conversion • Sum-of-Weights for converting to decimal • Repeated division for converting from decimal • Binary Arithmetic • Similar to Decimal Arithmetic • Multiplying by a constant by shifting left • Dividing by a constant by shifting right

  3. Recap • Representing Numbers • Unsigned • Signed Magnitude • 2’s Complement

  4. 2’s Complement form • 1’s complement form • 2’s complement form Binary number 01101 (13) 1’s complement 10010 + 1 2’s complement 10011 (-13)

  5. Addition and Subtraction with 2’s Complement 0101 +5 0101 +5 0010 +21110 -2 0111 +7 10011 +3 1011 -5 1011 -5 1110 -20010 +2 11001 -7 1101 -3

  6. Addition and Subtraction2’s complement vs. Signed 2’s Complement Signed Binary 0101 +5 0101 +5 0010 +20010 +2 0111 +7 0111 +7 1011 -5 1101 -5 1110 -21010 -2 11001 -7 10111 -7

  7. Addition and Subtraction2’complement vs. Signed 0101 +5 0101 +5 1110 -21010 -2 10011 +3 1111 +3 1011 -5 1101 -5 0010 +20010 +2 1101 -3 1111 -3

  8. Range of Numbers • Unsigned • Positive Numbers Only (0 to 7) • 3-bit • Signed Magnitude • Positive & Negative Numbers (-7 to 7) • 4-bit • 2’s Complement • Positive & Negative Numbers (-8 to 7) • 4-bit

  9. Range & Overflow • 2 + 7 using 3-bit unsigned binary? • 9 overflow? • 2 – 7? • Can not represent -7 in unsigned binary

  10. Range and Overflow 1011 -5 1101 -3 11000 -8 1011 -5 0101 +5 1100 -40100 +4 10111 -9 1001 +9

  11. Range of Binary Numbers • Processors can handle 64-bit unsigned binary values. • Maximum unsigned decimal number is 18.446 x 1018 • How to represent larger numbers? • How to represent very small numbers? • How to represent numbers with integer part and fraction part?

  12. Floating Point Representation38 • 32-bit Floating Point Representation • ANSI/IEEE Standard 754 defines • 32-bit Single-Precision Floating Point • Sign Bit 1 • Exponent Bits 8 • Mantissa Bits 23 • 64-bit Double-Precision Floating Point

  13. Floating Point Format • 15 digit decimal number format • Sign digit 1 • Exponent digits 2 • Mantissa digits 12 • 6918.3125 = 6.9183125 x 103 • Magnitude 69183125 • Exponent 3

  14. Floating Point Format • Normalized form 0.69183125 x 104 • Magnitude 69183125 • Exponent 4 • Max Number 0.999,999,999,999 x 1099 • No negative exponent

  15. Floating Point Format • Option I • Increase exponent field to 3 digits • 1099 to10-99 • Option II • Biased 50 Exponent • add 50 1049→ 99 10-50→ 0

  16. Floating Point Format • Zero ? • Infinity (∞) ?

  17. Floating Point Format • Allow 1048→ 98 10-49→ 1 • Exponent 99 → ∞ • Exponent 0 → 0 • Decrease Bias to 49 • 1049→ 98 10-48→ 1 • Exponent 99 → ∞ • Exponent 0 → 0

  18. Single-Precision F.P. format • Representing 6918.3125 • 6918.3125 = 1101100000110.01012 • Normalized form • 1.1011000001100101 x 212 • S = 0 • E = 10001011 (127 + 12 = 139) • M = 10,110,000,011,001,010,000,000 • Hidden 1

  19. Floating Point Numbers +1.101 x 25 S=0 Exponent=10000100 Mantissa 101 0000 0000 0000 0000 0000 -1.01011 x 2-126 S=1 Exponent=00000001 Mantissa 010 1100 0000 0000 0000 0000 0 S=0 Exponent=00000000 Mantissa 000 0000 0000 0000 0000 0000 ∞ S=0 Exponent=11111111 Mantissa 000 0000 0000 0000 0000 0000

  20. Hexadecimal Number System • Base 16 • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F • Representing Binary in compact form • 11011000001102 = 1B06 H

  21. Counting in Hexadecimal

  22. Counting in Hexadecimal

  23. Binary-Hexadecimal Conversion • Binary to Hexadecimal Conversion • 11010110101110010110 • 1101 0110 1011 1001 0110 • D 6 B 9 6 • Hexadecimal to Binary Conversion • FD13 • 1111 1101 0001 0011

  24. Decimal-Hexadecimal Conversion • Decimal to Hexadecimal Conversion • Indirect Method • Decimal →Binary → Hexadecimal • Repeated Division by 16

  25. Decimal-Hexadecimal Conversion • Hexadecimal to Decimal Conversion • Indirect Method • Hexadecimal →Binary → Decimal • Sum-of-Weights

  26. Hexadecimal Addition & Subtraction • Hexadecimal Addition • Carry generated • Hexadecimal Subtraction • Borrow weight 16

  27. Repeated Division by 16

  28. Sum-of-Weights CA02 (C x 163) + (A x 162) + (0 x 161) + (2 x 160) (12 x 163) + (10 x 162) + (0 x 161) + (2 x 160) (12 x 4096) + (10 x 256) + (0 x 16) + (2 x 1) 49152 + 2560 + 0 + 2 51714

  29. Hexadecimal Addition Carry 1 2AC6 6+5=11d Bh + 92B5 C+B=23d 17h BD7B A+2+1=13d Dh 2+9=11d Bh

  30. Hexadecimal Subtraction Borrow 111 92B5 21-6=15d Fh - 2AC6 26-C=14d Eh 67EF 17-A=7d 7h 8-2=6d 6h

  31. Octal Number System • Base 8 • 0, 1, 2, 3, 4, 5, 6, 7 • Representing Binary in compact form • 11011000001102 = 154068

  32. Counting in Octal

  33. Counting in Octal

  34. Binary-Octal Conversion • Binary to Octal Conversion • 11010110101110010110 • 011 010 110 101 110 010 110 • 3 2 6 5 6 2 6 • Octal to Binary Conversion • 1726 • 001 111 010 110

  35. Decimal-Octal Conversion • Decimal to Octal Conversion • Indirect Method • Decimal →Binary → Octal • Repeated Division by 8

  36. Decimal-Octal Conversion • Octal to Decimal Conversion • Indirect Method • Octal →Binary → Decimal • Sum-of-Weights

  37. Octal Addition & Subtraction • Octal Addition • Carry generated • Octal Subtraction • Borrow weight 8

  38. Repeated Division by 8

  39. Sum-of-Weights 4033 (4 x 83) + (0 x 82) + (3 x 81) + (3 x 80) (4 x 512) + (0 x 64) + (3 x 8) + (3 x 1) 2048 + 0 + 24 + 3 2075

  40. Octal Addition Carry 1 7602 2+1=3d 3O + 5771 0+7=7d 7O 15573 6+7=13d 15O 1+7+5=13d 15O

  41. Octal Subtraction Borrow 11 7602 2-1=1d 1O - 5771 8-7=1d 1O 1611 13-7=6d 6O 6-5=1d 1O

  42. Alternate Representations • BCD Code • BCD Addition • Gray Code

  43. Alternate Representations • BCD (Binary Coded Decimal) Code

  44. BCD Addition • Multi-digit BCD numbers can be added together 23 0010 0011 45 0100 0101 68 0110 1000 23 0010 0011 48 0100 1000 71 0110 1011 • 1011 is illegal BCD number

  45. BCD Addition • Add a 0110 (6) to an invalid BCD number • Carry added to the most significant BCD digit 23 0010 0011 48 0100 1000 71 0110 1011 0110 0111 0001

  46. Gray Code • Binary Code more than 1 bit change • Electromechanical applications of digital systems restrict bit change to 1 • Shaft encoders • Braking Systems • Un-Weighted Code

  47. Gray Code

  48. Gray Code Application

  49. Alphanumeric Code • Numbers, Characters, Symbols • ASCII 7-bit Code • American Standard Code for Information Interchange • 10 Numbers (0-9) • 26 Lower Case Characters (a-z) • 26 Upper Case Characters (A-Z) • Punctuation and Symbols • 32 Control Characters

  50. ASCII Code • Numbers 0 to 9 • ASCII 0110000 (30h) to 0111001 (39h) • Alphabets a to z • ASCII 1100001 (61h) to 1111010 (7Ah) • Alphabets A to Z • ASCII 1000001 (41h) to 1011010 (5Ah) • Control Characters • ASCII 0000000 (0h) to 0011111 (1Fh)

More Related