Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
THE ISLAMIC UNIVERSITY OF GAZA ENGINEERING FACULTY DEPARTMENT OF COMPUTER ENGINEERING DIGITAL LOGIC DESIGN DISCUSSION – ECOM 2012 Eng. Huda M. Dawoud September, 2015 DIGITAL LOGIC DESIGN 1.1 ECOM 2012 ENG. HUDA M. DAWOUD List the octal and hexadecimal numbers from 16 to 32. Using A and B for the last two digits, list the numbers from 8 to 28 in base 12. Answer: Decimal 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Octal 20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37 40 Hexadec… 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 Decimal 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Base 12 8 9 A B 10 11 12 13 14 15 16 17 18 19 1A 1B 20 21 22 23 24 1.2 What is the exact number of bytes in a system that contains (a) 32K bytes, (b) 64M bytes, and (c) 6.4G bytes? Answer: (a) (b) (c) 1.3 32 * 210 = 32768 bytes 64 * 220 = 67108864 bytes 6.4 * 230 = 6871947674 bytes Convert the following numbers with the indicated bases to decimal: (a) (4310) 5 (b) (198) 12 (c) (435) 8 (d) (345) 6 Answer: (a) (b) (c) (d) 4 * 53 + 3 * 52 + 1 * 51 + 0 * 50 = (580)10 1* 122 + 9 * 121 + 8 * 120 = (260)10 4 * 82 + 3 * 81 + 5 * 80 = (285)10 3 * 62 + 4 * 61 + 5 * 60 = (137)10 2 DIGITAL LOGIC DESIGN 1.4 ECOM 2012 ENG. HUDA M. DAWOUD What is the largest binary number that can be expressed with 16 bits? What are the equivalent decimal and hexadecimal numbers? Answer: The largest number of any k-digits binary number is that with all digits being 1, such that the largest number of 16-digit binary number is (1111 1111 1111 1111)2 = (65535)10 = (FFFF)16 To calculate the largest number of k bits we can simply use the formula 2k -1 In this question 216 -1 = 65536 1.5 Determine the base of the numbers in each case for the following operations to be correct: (a) 14/2 = 5 (b) 54/4 = 13 (c) 24 + 17 = 40. Answer: (a) (b) (c) 1.6 (1 * b1 + 4 * b0 1) / 2 * b0 1 = 5 * b0 1 (b + 4) / 2 = 5 b/2 + 4/2 = 5 b = 6 (5 * b1 + 4 * b0 1) / 4 * b0 1 = 1 * b1 + 3 * b0 1 (5b + 4) / 4 = 1b + 3 5b/4 + 4/4 = 1b + 3 b = 8 (2 *b + 4) + (b + 7) = 4b b = 11 The solutions to the quadratic equation x2 - 11x + 22 = 0 are x = 3 and x = 6. What is the base of the numbers? Answer: Notice that the solutions to the equation x2 - 11x + 22 in decimal system are 8.37 and 2.62, which means that this equation is in another system, we are asked to get the base of it. 3 DIGITAL LOGIC DESIGN ECOM 2012 ENG. HUDA M. DAWOUD (x – 3) (x - 6) = x2 – 9x + 18 (x2 - 11x + 22)b = (x2 – 9x + 18)10 (11)b = (9)10 (1 * b1 + 1 * b0 1) = 9 b=8 1.7 Convert the hexadecimal number 64CD to binary, and then convert it from binary to octal. Answer: (64CD)16 = (0110 0100 1100 1101)2 (110 010011 001 101)2 = (62315)8 1.8 Convert the decimal number 431 to binary in two ways: (a) convert directly to binary; (b) convert first to hexadecimal and then from hexadecimal to binary. Which method is faster? Answer: (a) Integer Remainder 431/2 215 107 53 26 13 6 3 1 0 1 1 1 1 0 1 0 1 1 431 = (110101111)2 4 DIGITAL LOGIC DESIGN (b) Integer ECOM 2012 ENG. HUDA M. DAWOUD Remainder 431/16 26 F 1 A 0 1 431 = (1AF)16 = (110101111)2 The second method is faster than the first one. 1.9 Convert Express the following numbers in decimal: (a) (10110.0101) 2 (b) (16.5) 16 (c) (26.24) 8 Answer: (a) (b) (c) (10110.0101) 2 = 1 * 24 + 0 * 23 + 1 * 22 + 1 * 21 + 0 * 20 + 0 * 2-1 + 1 * 2-2 + 0 * 2-3 + 1 * 2-4 = 22.3125 (16.5) 16 = 1 * 161 + 6 * 160 + 5 * 16-1 = 22.3125 (26.24) 8 = 2 * 81 + 6 * 80 + 2 * 8-1 + 4 * 8-2 = 22.3125 1.10 Convert the following binary numbers to hexadecimal and to decimal: (a) 1.10010, (b) 110.010. Explain why the decimal answer in (b) is 4 times that in (a). Answer: (a) (b) 1.100102 = 0001.10012 = 1.916 = 1 + 9/16 = 1.56310 110.0102 = 0110.01002 = 6.416 = 6 + 4/16 = 6.2510 Reason: 110.0102 is the same as 1.100102 shifted to the left by two places. 5 DIGITAL LOGIC DESIGN ECOM 2012 ENG. HUDA M. DAWOUD 1.11 Perform the following division in binary: 111011 ÷ 101. Answer: 1011.11 101 111011.00 101 01001 101 1001 101 1000 101 0110 101 001 1.12 Add and multiply the following numbers without converting them to decimal. (a) Binary numbers 1011 and 101. (b) Hexadecimal numbers 2E and 34. Answer: a) Addition 1 1001 0101 + 1110 Multiplication 1001 0101 × 1001 00000 100100 101101 6 DIGITAL LOGIC DESIGN ECOM 2012 b) Addition ENG. HUDA M. DAWOUD Multiplication 1 2E 34 2E + 34 × 38 + 80 62 B8 + 2A0 600 958 1.13 Do the following conversion problems: (a) Convert decimal 27.315 to binary. Answer: a) Integer Remainder Fraction Integer 27/2 13 6 3 1 0 0.315*2 0.36 0.26 0.52 0.04 0.08 0.16 0.32 0 1 0 1 0 0 0 1 1 0 1 1 27.31510 = 11011.01012 1.14 Obtain the 1’s and 2’s complements of the following binary numbers: (a) 00010000 (b) 00000000 (c) 11011010 (d) 10101010 Answer: 1st complement 2nd complement 00010000 11101111 11110000 00000000 11111111 00000000 11011010 00100101 00100110 10101010 01010101 01010110 7 DIGITAL LOGIC DESIGN ECOM 2012 ENG. HUDA M. DAWOUD 1.15 Find the 9’s and the 10’s complement of the following decimal numbers: (a) 25,478,036 (b) 63, 325, 600 (c) 25,000,000 (d) 00,000,000. Answer: 9’s complement 10’s complement 25478036 74521963 74521964 63325600 36674399 36674400 25000000 74999999 75000000 00000000 99999999 00000000 1.16 (a) Find the 16’s complement of C3DF. (b) Convert C3DF to binary. (c) Find the 2’s complement of the result in (b). (d) Convert the answer in (c) to hexadecimal and compare with the answer in (a). Answer: a) b) c) d) FFFF – C3DF + 1 = 3C21 1100 0011 1101 1111 0011 1100 0010 0001 3C21 1.17 Perform subtraction on the given unsigned numbers using the 10’s complement of the subtrahend. Where the result should be negative, find its 10’s complement and affix a minus sign. Verify your answers. (a) 4,637 - 2,579 (b) 125 - 1,800 Answer: a) 10’s complement of 2579 = 9999 - 2579 + 1 = 7421 4637 + 7421 = 12058 here, the result should be positive; we discard the 1. result = + 2058 b) 10’s complement of 1800 = 8200 8 DIGITAL LOGIC DESIGN ECOM 2012 ENG. HUDA M. DAWOUD 125 + 8200 = 8325 here, the result should be negative; we find its 10’s complement and affix a minus sign. result= - 1675 1.18 Perform subtraction on the given unsigned binary numbers using the 2’s complement of the subtrahend. Where the result should be negative, find its 2’s complement and affix a minus sign. (a) 10011 – 10010 (b) 100010 – 100110 Answer: a) 10011 + 01110 = 100001 Result = + 00001, as we discard 1 b) 100010 + 011010 = 111100 Result= - 000100, as the result should be negative. 1.22 Convert decimal 6,514 to both BCD and ASCII codes. For ASCII, an even parity bit is to be appended at the left. Answer: 6514 = ( 0110 0101 0001 0100 )BCD = ( 0 0110110 0110101 0110001 0110100)ASCII 1.23 Represent the unsigned decimal numbers 791 and 658 in BCD, and then show the steps necessary to form their sum. Answer: 1 1 1 0111 1001 0001 + 0110 0101 1000 1 1 1 11 1 1 = (1449)BCD 1101 1110 1001 0110 0110 0001 0100 0100 1001 + 9