ch 10 floating point unit
Download
Skip this Video
Download Presentation
Ch. 10 Floating Point Unit

Loading in 2 Seconds...

play fullscreen
1 / 11

Ch. 10 Floating Point Unit - PowerPoint PPT Presentation


  • 166 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Ch. 10 Floating Point Unit' - halia


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
ch 10 floating point unit

Ch. 10 Floating Point Unit

Comp Sci 251 -- Floating Point Arithmetic

mips floating point arithmetic
MIPS Floating point arithmetic
  • Floating point Coprocessor
  • "Coprocessor 1"

System bus

l.s

Processor

Memory

Coprocessor 1

Comp Sci 251 -- Floating Point Arithmetic

coprocessor architecture
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

floating point mips assembly code
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

slide5

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

slide6

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

floating point instructions
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

floating point instructions1
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

floating point instructions2
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

floating point instructions3
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

exercise
Exercise
  • Write MIPS for the following statements

float f = 4.99;

cout << (int) f << endl;

Comp Sci 251 -- Floating Point Arithmetic

ad