Sunteți pe pagina 1din 4

COMP 5414

Homework #1 Due Date: Oct. 27, 2011 (Total Marks: 110 Marks) (Note: 1. Submit a hardcopy when you attend the lecture. 2. The detailed procedures are needed. You will get zero if you only give the final answer without showing how you get it. 3. Except the last question, handwriting is okay but try your best to keep it READABLE. ) Part A: (16 pt (2 pt each)) 1. Convert the following decimal numbers to binary, octal and hexadecimal numbers. (a) 250.8 2. Convert the following binary numbers to decimal, octal and hexadecimal numbers. (a) 10110110.001 4. Convert the following octal numbers to decimal, binary and hexadecimal numbers. (a) 240.51 5. Convert the following hexadecimal numbers to decimal, binary and octal numbers (a) F8.A7 6. With the twos complement representation, find the counterpart of each of the following binary numbers assuming n=8 (n is the number of the available bits to represent a number). (a) 11111111 (b) 1101011 (c) 0 (d) 11000 Part B: (44 pt) 1. Convert the following decimal numbers to single and double binary floating point numbers. (12 pt) (a) -65.79 (b) 12.86 [Note: For fraction part, when converting to binary, calculate up to 5 digits] 2. Encode the following numbers in BCD ( 2 pt) (a) 39 (b) 94047 3. Encode the following character strings in ASCII code. (4 pt) (a) 1980 (b) C omputing

4. Determine the parity bit (P) to establish odd-0 parity for each number. Explain why the parity code can used for 1 bit error detection. (8 pt) (a) P10011001 (b) P01011010

5.

Hamming code. (18 pt)

The above figure illustrates a typical error detection process in memory. When data are read into the memory, based on the inputted data with M bits (called M-bit data word), a function f calculates and produces a K-bit code (called K-bit code word). Both the inputted data word (M bits) and the generated code word (K bits) will be stored into the memory, and the stored word is M+K bits. When the previous stored word is read out, the K-bit code word is used to detect and possibly correct errors. To achieve this, a new K-bit code word is generated from the M-bit data word (read out from the memory) based on the function f. Then the new code word is compared with the code word read out from the memory, and it will yield one of three results: (1) They are same. No error detects. (2) They are different. We can detect and possible correct errors. Then the corrected data (M bits) will be sent out, or an error will be reported. The Hamming code is one of the simplest error-correction code schemes. Basically, for a given M-bit data word, suppose a K-bit code word will be generated based on the hamming coding scheme. Then a bit-by-bit comparison is done by taking the exclusive-OR of the two K-bit code words (the newly-generated and old code words), and the result is called the syndrome word. For single error detection, there are three cases: (1) If the syndrome contains all 0s, no error has been detected (the case when the old code word is the same as the new code word). (2) If the syndrome contains one 1, then one error has occurred in one bit of the

code word. No correction is needed. (3) If the syndrome contains more than one bit set to 1, then there is one-bit error occurring in the data word, and the numerical value of the syndrome indicates the position of the data bit in error. This data can then be inverted for correction. For simplicity, the following functions are used to generate a 4-bit code word for an 8-bit data word based on the following functions (the Hamming code): C1 = D1 D2 D4 D5 D7 C2 = D1 D3 D4 D6 D7 C4= D2 D3 D4 D8 C8= D5 D6 D7 D8 Here, we assume the 8-bit data word is D8 D7 D6 D4 D5 D4 D3 D2 D1, and the 4-bit code word is C8 C4 C2 C1. And the layout of data bits in an 8-bit data word and code bit in a 4-bit code word is listed in the following table:
Bit 12 Position Syndrome Data D8 Word Code C8 Word C4 C2 C1 D7 D6 D5 D4 D3 D2 D1 1100 1011 1010 1001 1000 0111 0110 0101 0100 0011 0010 0001 11 10 9 8 7 6 5 4 3 2 1

Based on the above, please answer the following questions: (1) Calculate the 4-bit code word for the following data words: (a) 1101 1110 (b) 1000 0010 (8 pt) (2) For each of the above data words, suppose that the single-bit error occurs at the 6th bit (D6), where 0 becomes 1, or 1 becomes 0, calculate the corresponding new code word and syndrome word. (8 pt) (3) Illustrate how the single-bit error can be corrected based on above the old and new code words obtained in (1) and (2). (2 pt)

Part C: (42 pt) Textbook, pp. 717 B.1 (8 pt) B.2 (8 pt)

B.3 (4 pt)

B.4 (14 pt)

B.5 (4 pt)

B.6 (4 pt)

B5. Construct the operation XOR from the basic Boolean operations AND, OR and NOT. B6. Given a NOR gate and NOT gates, draw a logic diagram that will perform the three input AND function.

Part D: (8 pt) Write an assembly program to calculate the dot product of two arrays with LC-2 (the computer we study in the lab 1 and lab 2): The size of each array is 15 (a[0], , a[14]; b[0], , b[14]) that are stored in the memory. The dot product result is obtained by: a[0]*b[0] + a[1]*b[1] + + a[14]*b[14] and the obtained result is stored in the memory as well. Compile your assembly program and test the result with the assembler and simulator. Submit your source code.

S-ar putea să vă placă și