Please find the attached files.
Carefully read the question, making sure you understand what is being asked in each item.
Clearly mark your answers to each question on the homework, making sure it is clear what
answer goes to which question/item. Also, organize your answers in the correct order.
Make sure the scan/pictures of the work are easily readable. Preferably do not use pencils.
You must submit a pdf file with the answers of questions 1 and 2 and a ‘.s’ or ‘.asm’ file for question 3. All HW files must be submitted on Canvas.
CS 3339 : Computer Architecture SPRING 2023 HOMEWORK 03 Instructions: • Carefully read the question, making sure you understand what is being asked in each item. • Clearly mark your answers to each question on the homework, making sure it is clear what answer goes to which question/item. Also, organize your answers in the correct order. • Make sure the scan/pictures of the work are easily readable. Preferably do not use pencils. • You must submit a pdf file with the answers of questions 1 and 2 and a ‘.s’ or ‘.asm’ file for question 3. All HW files must be submitted on Canvas. 1 (Q.1) Division 1.a) Using the hardware described in the figure below, calculate 74 divided by 21. # Remainder-Left (input 1 ALU) Remainder-Right (input 2 ALU) Subtraction Control? Action 1 2 3 4 5 6 7 8 9 10 1.b) Check your results. Are the results correct? How many cycles of the algorithm are necessary to obtain the result? How is this number related to the operands and their size in bits? 2 (Q.2) Floating Point: The IEEE standard representation has three fields: S (signal) is one bit representing the sign of the number, E (exponent) is an 8-bit biased integer representing the exponent, and F (fraction) is an unsigned integer. The decimal value represented is: (−1)S × f × 2e where e = E − bias and f = (F/(2n)) + 1. For single precision representation n = 23 and bias = 127. For double precision repre- sentation (a 64-bit representation), n = 52 (there are 52 bits for the mantissa field) and bias = 1023 (there are 11 bits for the exponent field). The IEEE standard requires the use of 3 extra bits of less significance than the 24 bits (of mantissa/ fraction) implied in the single precision representation: guard bit (g), round bit (r), and sticky bit (s), as shown below. This is the format used internally (on many, not all processors) for a single precision floating point value. 1 .XXXXXXXXXXXXXXXXXXXXXXX 0 0 0 ˆ ˆ ˆ ˆ ˆ | | | | | | | | | − s t i c k y b i t ( s ) | | | − round b i t ( r ) | | − guard b i t ( g ) | − 23 b i t mantissa from a r ep r e s en t a t i on − hidden b i t • When a mantissa is to be shifted in order to align radix points, the bits that fall off the least significant end of the mantissa go into these extra bits (guard, round, and sticky bits). • The guard and round bits are just 2 extra bits of precision that are used in calcu- lations. • Sticky bit: A bit used in rounding to guard and round that is set whenever there are nonzero bits to the right of the round bit. The sticky bit is an indication of what is/could be in lesser significant bits that are not kept. If a value of 1 ever is shifted into the sticky bit position, that sticky bit remains a 1 (”sticks”at 1), despite further shifts. There are MANY ways of rounding: • round toward 0 (also called truncation) - Remove all digits beyond those supported. ex.: 1.00100 → 1.00 • round up to the next value - ex.: 1.00100 → 1.01 • round down to the previous value - ex.: 1.00100 → 1.00 3 • round to nearest even or rounds to the even value (the one with an LSB of 0) - 1.00100 → 1.00, 1.01100 → 1.10. When rounding a binary fraction, the least significant digit of rounded result will be either 1 or 0. Nearest even mode always rounds the number so that the lsb is 0. Hence, the name. (If we omit the binary point, the rounded number would be even.) In this question we use the rounding to even method. 2.a) IEEE 754 2008 (16 bits) contains a half precision that is only 16 bits wide. The leftmost bit is still the sign bit, the exponent is 5 bits wide and has a bias of 15, and the mantissa is 10 bits long. Write down the bit pattern to represent 1.5625 × 10−1 assuming a version of this format, which uses an excess-16 format to store the exponent. Comment on how the range and accuracy of this 16-bit floating point format compares to the single precision IEEE 754 standard (32 bits). 2.b) Calculate the sum of 2.6125×101 and 4.150390625×10−1 by hand, assuming A and B are stored in the 16-bit half precision described in 2.a). Assume 1 guard, 1 round bit, and 1 sticky bit, and round to the nearest even. Show all the steps. 2.c) Calculate the product of −8.0546875 × 100 and 1.79931640625 × 10−1 by hand, assuming A and B are stored in the 16 bit half precision format. Assume 1 guard, 1 round bit, and 1 sticky bit, and round to the nearest even. Show all the steps. Indicate if there is overflow or underflow. Write your answer in both the 16-bit floating point format and also as a decimal number. How accurate is your result? How does it compare to the number you get if you do the multiplication on a calculator? 4 (Q.3) Assembly - FP Operations The Taylor series expansions for ex is given by: ex = 1 + x+ x2 2! + x3 3! + x4 4! + x5 5! + . . . = ∞∑ n=0 xn n! . We can use the first few terms of this series to get an approximate value for ex. For example, by picking N terms in the above equation, we get the following expression: ex ≈ N∑ n=0 xn n! . In this question, you are asked to implement a MIPS assembly program that computes an approximation of ex for N = 3, i.e. ex ≈ 1 + x+ x22! + x3 3! . • Your program should receive the value of x as input and return the approximation of ex as output. • You should read x from the command lines as a floating point number and print the output ex as a floating point number. • To compute the approximation equation you should use floating-point instructions and registers. • You do not need to use a factorial function. It is only necessary to compute 2! and 3! for this question. 5