CS/COE 447: Spring 2010 Lab 10 YOUR NAME: YOUR PARTNER'S NAME: Each of you should hand in a hardcopy of your own solution. This lab will give you practice with Booth's algorithm, The IEEE754 standard for floating point numbers, and with writing MIPS code handling floating point numbers. We will use a datapath of only 4 bits (while MIPS is 32 bits), to make tracing through the examples more feasible. "n" below is the size of the datapath (whatever it may be). =====PART 1: Booth's Algorithm See the flowchart of Booth's algorithm on the class schedule: http://www.cs.pitt.edu/~wiebe/courses/CS447/lectures/boothsalgo.pdf And the example on the schedule: http://www.cs.pitt.edu/~wiebe/courses/CS447/lectures/boothexample.pdf Using the format of this example, trace Booth's algorithm on the following values: A) 12 * -7 B) -8 * -6 Below are shells of the formats for you to fill in. You can either add space, print it out, and fill this in by hand, or type in your answers. Example of Booth's technique for 12 * -7 ----------------------------------------- N=8 (8 bit numbers) M=12=? -M=? R=-7=? S(step) M(multiplicand) P product Notes Example of Booth's technique for -8 * -6 ----------------------------------------- N=8 (8 bit numbers) M=-8=? -M=? R=-6=? S(step) M(multiplicand) P product Notes =====PART 2: IEEE754 Floating Point Standard ********************* Translate the following to binary: 15.25 decimal 32 171/256 decimal ********************* Represent these as single-precision IEEE 724 floating point numbers. Give the answer in binary and in hex: 15.25 decimal 32 171/256 decimal ********************* If the following is a SP floating point value, what decimal number does it represent? (It is fine to state your answer in terms of a power of 2.) 0 00000010 00000000000000000000000 ********************* If the following is a SP floating point value, what decimal number does it represent? (It is fine to state your answer in terms of a power of 2.) 0 11111110 01100000000000000000000 ********************* Please go to this page (this is the same applet on the course schedule): http://users-tima.imag.fr/cis/guyot/Cours/Oparithm/english/Flottan.htm Note that the top part has an interactive floating point quiz you can use to practice. What's really useful is the applet in the middle that shows floating-point addition, including the guard, round, and sticky bits. Enter: A: .00098765432 B: 10 It shows you the single-precision floating-point representations underneath, as well as what the values are in scientific notation (binary and hex). Notice that the exponent of A is -10 and the exponent of B is 3. Thus, the alignment step will require A to be shifted 13 positions to the right. Notice the | The bit to the right of the | is the guard bit; the bit to the right of that is the round bit; and the bits that were shifted off beyond the guard and round bits are shown underlined, in step 1. These are the bits that are OR'ed together to determine the sticky bit. The sticky bit is shown on subsequent lines as a single bit. In our example, 1010000101110 are the bits of A that no longer fit, given that alignment required shifting 13 bits to make the exponents of A and B match. The guard bit: *1* 010000101110 The round bit: 1 *0* 10000101110 The sticky bit: the OR of the bits in *10000101110*, which is 1. Thus, you see in step 2 that 101 follows the | for A. Step 2 shows the addition. Step 3 shows the renormalization (which isn't needed in this case). Step 4 shows rounding (using "rounding up"). *********************Question: would the answer have been different if there were no guard, round, or sticky bits? Please explain. (And make sure you understand!) *********************Question: Why don't we have to worry about shifting to the left? Why is the shift always to the right? ======= It will be a good idea to enter other examples, and understand their floating point representations, and how they are added.