1 / 11

Ch. 10 Floating Point Unit

Ch. 10 Floating Point Unit. MIPS Floating point arithmetic. Floating point Coprocessor "Coprocessor 1". System bus. l.s. Processor. Memory. Coprocessor 1. Coprocessor architecture. Floating point registers: $f0, …, $f31 Each 32 bits wide Single precision value: one register

halia
Download Presentation

Ch. 10 Floating Point Unit

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ch. 10 Floating Point Unit Comp Sci 251 -- Floating Point Arithmetic

  2. MIPS Floating point arithmetic • Floating point Coprocessor • "Coprocessor 1" System bus l.s Processor Memory Coprocessor 1 Comp Sci 251 -- Floating Point Arithmetic

  3. Coprocessor architecture • Floating point registers: $f0, …, $f31 • Each 32 bits wide • Single precision value: one register • Double precision value: • Even/odd pair of registers • Examples: $f0:$f1 $f4:$f5 $f28:$f29 $f3:$f4 Comp Sci 251 -- Floating Point Arithmetic

  4. Floating point MIPS assembly code • Data definitions x: .float 32.568 # single precision y: .double 32.568 # double precision • Load/store instructions l.s $f5, x # load single s.s $f5, x # store single Comp Sci 251 -- Floating Point Arithmetic

  5. Control Unit Floating Point Arithmetic Logical Unit (FALU) Register Register mfc1 or mtc1 FP Register FP Register mov.s or mov.d store: s.s or s.d load: l.s or l.d Main Memory Comp Sci 251 -- Floating Point Arithmetic

  6. Data Bus Instructions Condition Code Control unit and clocks Operands Register unit (16 x 64) Exponent part fraction A B result Exponent Unit A B result Add Unit A B result Divide unit A B result Multiply unit Comp Sci 251 -- Floating Point Arithmetic

  7. Floating point instructions • Register  register copy mov.s $f5, $f23 # move single, $f5$f23 • CPU  FPU copy mfc1 $t0, $f5 # move from coprocessor1, $t0$f5 mtc1 $t0, $f5 # move to coprocessor1, $t0$f5 Comp Sci 251 -- Floating Point Arithmetic

  8. Floating point instructions • Arithmetic (replace s with d for double precision) add.s $f2, $f4, $f6 # $f2  $f4 + $f6 sub.s $f2, $f4, $f6 # $f2  $f4 - $f6 mul.s $f2, $f4, $f6 # $f2  $f4 * $f6 div.s $f2, $f4, $f6 # $f2  $f4 / $f6 abs.s $f2, $f4 # $f2  |$f4| Comp Sci 251 -- Floating Point Arithmetic

  9. Floating point instructions • Comparison: affects coprocessor status flag (replace s with d for double precision) c.eq.s $f0, $f6 # flag  $f0 == $f6 c.le.s $f0, $f6 # flag  $f0 <= $f6 c.lt.s $f0, $f6 # flag  $f0 < $f6 • Conditional branches bc1t label # branch if flag == true bc1f label # branch if flag == false Comp Sci 251 -- Floating Point Arithmetic

  10. Floating point instructions • Type conversion • between integer (w), single (s), double (d) data types • Examples: # convert to word (int) in $f0 from single in $f2 cvt.w.s $f0, $f2 # convert to single in $f0 from word (int) in $f2 cvt.s.w $f0, $f2 Comp Sci 251 -- Floating Point Arithmetic

  11. Exercise • Write MIPS for the following statements float f = 4.99; cout << (int) f << endl; Comp Sci 251 -- Floating Point Arithmetic

More Related