CSCI341 Lecture 18, IEEE Floating Point
Image courtesy of http://debsbookbag.blogspot.com/
The design team for a relationship-problem-solving-unit (RPSU) is choosing between a Candy and Flower implementation. Thousands of relationships may be at stake if the problems aren’t solved efficiently.
Parameter Candy Flowers Clock Rate 500 MHz 35 MHz CPI for ALU 1 1 CPI for Control 2 1 CPI for Memory 2.7 1 For a program with 20% ALU instructions, 10% control instructions and 70% memory instructions, which design will be faster?
REVIEW • We need to represent real numbers (very large, very small) in a machine • The agreed-upon standard is the IEEE Floating Point standard
IEEE FLOATING POINT STANDARD • Single Precision (4 bytes / 32-bit encoding) • Double Precision (8 bytes / 64-bit encoding)
SINGLE-PRECISION FLOATING POINT ENCODING e = 8-bit f=23-bit s= 1-bit sign exponent significand Biased exponent (because this The MSB, 1, is implied. isn’t your parents 2‘s Think 24-bits. complement system, this is IEEE rock and roll.) For single-precision FP , the bias is 127.
SINGLE-PRECISION FLOATING POINT ENCODING e = 8-bit f=23-bit s= 1-bit sign exponent significand (-1) s x 1.f x 10 e-127 Think of this as “one zero” not ten e-127 -> e - 01111111
BINARY TO DECIMAL 101.101 2 111.001 2 10.101 2
DECIMAL TO BINARY 25.25 10 12.2 10
ENCODE AS FLOATING POINT s= 1-bit e = 8-bit exponent f=23-bit significand sign • Place a value for the sign bit in the s field • Normalize the binary number • Add 127 (01111111) to the actual exponent • place this in the e field • Place the digits to the right of the binary point into the f field
ENCODE AS FLOATING POINT s= 1-bit e = 8-bit exponent f=23-bit significand sign 12.25 10 1.101010 1001001.1010 0.101011
DECODE FROM FLOATING POINT s= 1-bit e = 8-bit exponent f=23-bit significand sign • First bit is the sign bit, it remains the MSB • Subtract 127 from e to find the actual exponent • Extract the f bits into a normalized form: 1. f • Denormalize the number
DECODE FROM FLOATING POINT s= 1-bit e = 8-bit exponent f=23-bit significand sign 1 10000111 001100....0 0 10001000 101000....0 1 10001001 01100....0
PRECISION / RESOLUTION What’s the big deal?
CONSIDER A SMALLER FORMAT... sign exp sign 1 bit 3 bits 4 bits 1 101 1011 (Biased by 3) What is this in decimal?
CONSIDER A SMALLER FORMAT... How would you represent -6.76? sign exp sign 1 bit 3 bits 4 bits
OK... SO WHAT ABOUT MIPS? .data Pi: .double 3.1415926536897924 Rad: .double 12.345678901234567 .text main: l.d $f0, Pi # $f0 = Pi l.d $f4, Rad # $f4 = Rad mul.d $f12, $f4, $f4 # $f12 = Radius squared mul.d $f12, $f12, $f0 # Multiply by Pi li $v0, 3 syscall # Print the area li $v0, 10 syscall # Terminate the program
HOMEWORK • Reading 16 (online) • Chapter 11 of MIPS Assembly Language (pdf) give me more!
Recommend
More recommend