Digital Systems Department of Computer Science and Information

  • Slides: 14
Download presentation
數位系統 Digital Systems Department of Computer Science and Information Engineering, Chaoyang University of Technology

數位系統 Digital Systems Department of Computer Science and Information Engineering, Chaoyang University of Technology 朝陽科技大學資 系 Speaker: Fuw-Yi Yang 楊伏夷 伏夷非征番, 道德經 察政章(Chapter 58) 伏者潛藏也 道紀章(Chapter 14) 道無形象, 視之不可見者曰夷 Fuw-Yi Yang 1

Text Book: Digital Design 5 th ed. Chapter 1 Problems 1. 9 Express the

Text Book: Digital Design 5 th ed. Chapter 1 Problems 1. 9 Express the following numbers in decimal: (a) (11010. 0101)2 24 + 23 + 21 + 2 -2 + 2 -4 = 26. 3125 (b) (A 6. 5)16 10*161 + 6*160 + 5*16 -1 = 166. 3125 (c) (276. 24)8 2*82 + 7*81 + 6*80 + 2*8 -1 + 4*8 -2 = … (d) (BABA. B)16 11*163 + 10*162 + 11*161 + 10*160 + 11*16 -1 =… (e) (10110. 1101)2 24 + 22 + 21 + 2 -2 + 2 -4 =… Fuw-Yi Yang 2

Text Book: Digital Design 5 th ed. Chapter 1 Problems 1. 13 Do the

Text Book: Digital Design 5 th ed. Chapter 1 Problems 1. 13 Do the following conversion problems: (a) Convert decimal 35. 125 to binary. (b) Calculate the binary equivalent of 1/3 out to eight places. Then convert from binary to decimal. How close is the result to 1/3? (c) Convert the binary result in (b) into hexadecimal. Then convert the result to decimal. Is the answer the same? Fuw-Yi Yang 3

Text Book: Digital Design 5 th ed. Chapter 1 Problems Solution to 1. 13

Text Book: Digital Design 5 th ed. Chapter 1 Problems Solution to 1. 13 (a) Convert decimal 37. 125 to binary. Ans: 100101. 001 Integer Remainder 37 Fraction Coefficient 0. 125 18 1 0. 25 0 9 0 0. 5 0 4 1 0 1 2 0 1 0 0 1 Fuw-Yi Yang 4

Text Book: Digital Design 5 th ed. Chapter 1 Problems Fraction Coefficient 0. 3333

Text Book: Digital Design 5 th ed. Chapter 1 Problems Fraction Coefficient 0. 3333 0. 6666 0 0. 33333332 1 0. 66666664 0 0. 33333328 1 0. 66666656 0 0. 33333321 1 0. 66666642 0 0. 33333284 1 Fuw-Yi Yang 5

Text Book: Digital Design 5 th ed. Chapter 1 Problems Solution to 1. 13

Text Book: Digital Design 5 th ed. Chapter 1 Problems Solution to 1. 13 (b) Calculate the binary equivalent of 1/3 out to eight places. Then convert from binary to decimal. How close is the result to 1/3? Ans: (1/3)10 = (0. 0101)2 Ans: (0. 0101)2 = 0. 25 + 0. 0625 + 0. 015625 +. 00390625 = (0. 33203125)10 Ans: ((0. 33203125 - 0. 3333333) / (0. 3333)) *100% = -0. 39% How to make the result more close to the true value? Fuw-Yi Yang 6

Text Book: Digital Design 5 th ed. Chapter 1 Problems Solution to 1. 13

Text Book: Digital Design 5 th ed. Chapter 1 Problems Solution to 1. 13 (c) Convert the binary result in (b) into hexadecimal. Then convert the result to decimal. Is the answer the same? Ans: (0. 0101)2 = (0. 55)16 = 5 * 16 -1 + 5 * 16 -2 = 5 * 0. 0625 + 5 * 0. 00390625 = (0. 33203125)10 Ans: The result is the same. Fuw-Yi Yang 7

Text Book: Digital Design 5 th ed. Chapter 1 Problems 1. 19 The following

Text Book: Digital Design 5 th ed. Chapter 1 Problems 1. 19 The following decimal numbers are shown in sign-magnitude form: +9, 081 and +954. Convert them to signed-10’s-complement form and perform the following operations (note that the sum is +10, 035 and requires five digits and a sign). Definition and solution: next pages Fuw-Yi Yang 8

Text Book: Digital Design 5 th ed. Chap 1 1. 5 Complements Diminished Radix

Text Book: Digital Design 5 th ed. Chap 1 1. 5 Complements Diminished Radix Complement Given a number N in base r having n digits, the (r - 1)’s complement of N is defined as (rn - 1) - N. N = 9286, r = 10, n = 5 The 9’s complement of N is (105 - 1) - 9286 = 90713 Radix Complement Given a number N in base r having n digits, the r’s complement of N is defined as rn - N for N 0 and as 0 for N = 0. The 10’s complement of N is 105 - 9286 = 90714 Fuw-Yi Yang 9

Text Book: Digital Design 5 th ed. Chapter 1 Problems Sol. 1 -19 (a)

Text Book: Digital Design 5 th ed. Chapter 1 Problems Sol. 1 -19 (a) (+9081) + (+ 801) = 009081 + 000801 = Signed bit = 0 , answer = (+9881) 009081 + 000801 009881 Signed bit (b) (9286) + (-954) = (009286) + (999046) = Signed bit = 0 , answer = (+8332) (Discard the carry out of signed bit) Fuw-Yi Yang 009286 +999046 1008332 10

Text Book: Digital Design 5 th ed. Chapter 1 Problems Sol. 1 -19 1.

Text Book: Digital Design 5 th ed. Chapter 1 Problems Sol. 1 -19 1. (c) (-9081) + (+ 801) = 990919 + 000801 991720 Signed bit = 1 , answer is a negative Number represented in 10’s-complement Signed bit form (991720), Or = -(100000 - 91720) = -8280 990714 (d) (-9286) + (-954) = (990714) + (999046) = +999046 1989760 Signed bit = 1 , answer is a negative number represented in 10’s-complement form (989760), Or = -(100000 - 89760) = -10240 (Discard the carry out of signed bit) Fuw-Yi Yang 11

Text Book: Digital Design 5 th ed. Chapter 1 Problems Next page shows an

Text Book: Digital Design 5 th ed. Chapter 1 Problems Next page shows an implementation of adder-subtractor using 2’s complement form (1 sign bit and 3 -bit magnitude). No overflow can occur in the cases: (+ number) + (- number) and (- number) + (+ number) Overflow may occur in the cases: (+ number) + (+ number) and (- number) + (- number) (+5) + (+6) = 0101 + 0110 1011 (-5) + (-6) = 1011 + 10101 Carry in the signed bit position, Carry out of signed bit position Fuw-Yi Yang 12

Text Book: Digital Design 4 th Ed. Chap 4. 5 Binary Adder-Subtractor Binary Adder

Text Book: Digital Design 4 th Ed. Chap 4. 5 Binary Adder-Subtractor Binary Adder Signed bit position Over flow occurs when either Carry in the signed bit position or Carry out of signed bit position but not both or none of them. Fuw-Yi Yang 13

Text Book: Digital Design 5 th ed. Chapter 1 Problems 1. 29 Decode the

Text Book: Digital Design 5 th ed. Chapter 1 Problems 1. 29 Decode the following ASCII code: 1000100 1101001 1100111 1101001 1110100 1100001 1101100 D i g i t a l 1010011 11110011 1110100 1100101 1101101 0101110. S y s t e m. Fuw-Yi Yang 14