<<

Homework # 2 (Due date: 9/20, Wednesday)

1) Consider the operation of a machine with the data path of figure 2-2. Suppose that loading the ALU input registers takes 5 nsec, running the ALU takes 10 nsec, and storing the result back in the register scratchpad takes 5 nsec. What is the maximum number of MIPS this machine is capable of in the absence of pipelining?

Solution: The cycle time = 5+10+5 = 20 nsec. Since there is no pipelining, the best the machine can do is 1/20nsec = 50 * 10^6 instructions. So the maximum number of instructions is 50 MIPS.

2) On computer 1, all instructions take 10 nsec to execute. On computer 2, they all take 5 nsec to execute. Can you say for certain that computer is faster? Discuss.

Solution: You cannot say anything for sure. Different factors such as pipelining can change the execution time significantly. For example, if computer 1 has a five-stage pipeline, it can issue up to 500 MIPS where if computer 2 is not pipelined it cannot do any better than 200 MIPS. Thus without more information, we cannot say which is faster.

3) Imagine you are designing a single-chip computer for an embedded system. The chip is going to have all its memory on chip and running at the same speed as the CPU with no access penalty. Examine each of the principles discussed in Sec. 2.1.4 at page 64 and tell whether they are so important (assuming that high performance is still desired).

Solution: On-chip memory does not affect the first three principles. Having only LOADs and STOREs touch memory is no longer required. There is no particular reason not to have a memory-to-memory architecture if memory references are as fast as register references. Likewise, the need for many registers becomes less in this environment.

4). To compete with the newly invented printing press, a medieval monastery decided to mass-produce handwritten paperback books by assembling a vast number of scribes in a huge hall. The head monk would then call out the first word of the book to be produced and all the scribes would copy it down. Then the head monk would call out the second word and all the scribes would copy it down. This process was repeated until the entire book had been read aloud and copied. Which of the parallel processor systems discussed in Sec. 2.1.6 does this system resemble most closely?

Solution: The monastery resembles Fig. 2-7, an array processor (SIMD).

5) Sociologists can get three possible answers to a typical survey question such as ‘‘Do you believe in the tooth fairy?’’—namely, yes, no, and no opinion. With this in mind, the Sociomagnetic Computer Company has decided to build a computer to process survey data. This computer has a trinary memory—that is, each byte (tryte?) consists of 8 trits, with a trit holding a 0, 1, or 2. How many trits are needed to hold a 6-bit number? Give an expression for the number of trits needed to hold n bits.

Solution: Sixty-four 6-bit numbers exist, so 4 trits are needed. In general, the number of trits, k, needed to hold n bits is the smallest value of k such that 3k >= 2n.

6) Construct the even-parity for 4-bit numbers 0010 and 0111 according to the Hamming algorithm. To be able to correct single bit error, how many number of check bits we need? Give the construction process.

Solution: 3 check bits. 0010 - 0101010; 0111  0001111

7) Devise a code for the digits 0 to 9 whose Hamming is 4. Maximally how many simultaneous errors in a code can be detected and how many can be corrected?

According to detection and correction rules, if you have Hamming distance of 4, then you can detect 3 errors and correct 1 error.

8) In a Hamming code, some bits are ‘redundant’ in the sense that they are used for checking and not information. What is the percentage of the redundant bits for a message that has been Hamming-coded and with a total length (data + check bits) of 2^r -1? Evaluate this expression numerically for values of r from 3 to 10?

Solution: For a total length of (2^r – 1) bits, there are r check bits. Consequently, the percentage of wasted bits is r/(2^r − 1) × 100%. Numerically for r from 3 to 10 we get: 42.9%, 26.7%, 16.1%, 9.5%, 5.5%, 3.1%, 1.8%, and 1.0%.

9)An extended ASCII character is represented by an 8-bit quantity. The associated Hamming encoding of each character can then be represented by a string of three hex digits. Encode the following extended five-character ASCII text using an even-parity Hamming code: Earth. Show your answer as a string of hex digits. [Hint: Read Section 2.4.8 about ASCII code]

Solution: Each 8-bit character is put into a 12-bit codeword where positions 1, 2, 4, and 8 are check positions. After calculating the check digits and grouping each consecutive 4 bits into a hex digit, the 5 character ASCII string is encoded in hex as:

C85 DD1 DF2 5F4 4D8.

10)The following string of hex digits encodes extended ASCII characters in an even-parity Hamming code: 0D3 DD3 0F2 5C1 1C5 CE3. Decode this string and write down the characters that are encoded. [Hint: Refer to Fig 2-44 for the ASCII coding table]

Solution: Each 8-bit ASCII character is encoded into three hex digits. The first set of hex digits: 0D3, has an error in bit 12 (as indicated by the fact that bit 4 and bit 8 have the wrong parity). The next set, DD3 has bit 11 wrong; the set 0F2 has bit 7 wrong; the set 5C1 has bit 9 wrong; the set 1C5 has bit 1 wrong; the last set CE3 does not contain any errors. After the bit positions are corrected and the data extracted from the code words and looked up in the ASCII table, the encoded characters are: babies.