CSCI341 Lecture 18, IEEE Floating Point Image courtesy of - - PowerPoint PPT Presentation

csci341
SMART_READER_LITE
LIVE PREVIEW

CSCI341 Lecture 18, IEEE Floating Point Image courtesy of - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

Lecture 18, IEEE Floating Point

CSCI341

slide-2
SLIDE 2

Image courtesy of http://debsbookbag.blogspot.com/

slide-3
SLIDE 3

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.

slide-4
SLIDE 4

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?

slide-5
SLIDE 5

REVIEW

  • We need to represent real numbers (very large, very small)

in a machine

  • The agreed-upon standard is the IEEE Floating Point standard
slide-6
SLIDE 6

IEEE FLOATING POINT STANDARD

  • Single Precision (4 bytes / 32-bit encoding)
  • Double Precision (8 bytes / 64-bit encoding)
slide-7
SLIDE 7

SINGLE-PRECISION FLOATING POINT ENCODING

s= 1-bit sign e = 8-bit exponent f=23-bit significand

The MSB, 1, is implied. Think 24-bits. Biased exponent (because this isn’t your parents 2‘s complement system, this is IEEE rock and roll.) For single-precision FP , the bias is 127.

slide-8
SLIDE 8

SINGLE-PRECISION FLOATING POINT ENCODING

s= 1-bit sign e = 8-bit exponent f=23-bit significand

(-1)s x 1.f x 10e-127 Think of this as “one zero” not ten

e-127 -> e - 01111111

slide-9
SLIDE 9

BINARY TO DECIMAL

101.1012 111.0012 10.1012

slide-10
SLIDE 10

DECIMAL TO BINARY

25.2510 12.210

slide-11
SLIDE 11

ENCODE AS FLOATING POINT

  • 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

s= 1-bit sign e = 8-bit exponent f=23-bit significand

slide-12
SLIDE 12

ENCODE AS FLOATING POINT

s= 1-bit sign e = 8-bit exponent f=23-bit significand

12.2510 1001001.1010 0.101011 1.101010

slide-13
SLIDE 13

DECODE FROM FLOATING POINT

s= 1-bit sign e = 8-bit exponent f=23-bit significand

  • 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
slide-14
SLIDE 14

DECODE FROM FLOATING POINT

s= 1-bit sign e = 8-bit exponent f=23-bit significand 1 10000111 001100....0 10001000 101000....0 1 10001001 01100....0

slide-15
SLIDE 15

PRECISION / RESOLUTION

What’s the big deal?

slide-16
SLIDE 16

CONSIDER A SMALLER FORMAT...

sign exp sign 1 bit 3 bits 4 bits 1 101 1011

What is this in decimal?

(Biased by 3)

slide-17
SLIDE 17

CONSIDER A SMALLER FORMAT...

sign exp sign 1 bit 3 bits 4 bits

How would you represent -6.76?

slide-18
SLIDE 18

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

slide-19
SLIDE 19
  • Reading 16 (online)
  • Chapter 11 of MIPS Assembly Language (pdf)

HOMEWORK

give me more!