Docsity

Execution Units - HDL Design - Lecture Slides, Slides of Verilog and VHDL

Partial preview of the text

Download Execution Units - HDL Design - Lecture Slides and more Slides Verilog and VHDL in PDF only on Docsity!

IEEE Floating Point

The IEEE Floating Point Standard and

execution units for it

Lecture overview

  • The standard
  • Floating Point Basics
  • A floating point adder design

The floating point standard

  • Double Precision
  • Value of bits in word representation is:
    • If e=2047 and f /= 0, then v is NaN regardless of s
    • If e=2047 and f = 0, then v = (-1) s^ ∞
    • If 0 < e < 2047, then v = (-1) s^2 e-1023^ (1.f)
      • – normalized number
    • If e = 0 and f /= 0, the v = (-1) s^2 -1022^ (0.f)
      • Denormalized numbers – allow for graceful underflow
    • If e = 0 and f = 0 the v = (-1) s^ 0 (zero)

s e (11-bits) f (52-bits)

The floating point standard

  • Notes on single and double precision
    • The leading 1 of the fractional part is not stored for normalized numbers
    • Representation allows for +0 and -0 indicating direction of 0 (allow determination that might matter if rounding was used)
    • Denormalized numbers allow graceful underflow towards 0

Conversion Example Continued

  • 1.1001 x 2 6 is binary for 100
  • Thus the exponent is a 6
    • Biased exponent will be 6+127=133 = 1000 0101
    • Sign will be a 0 for positive
    • Stored fractional part f will be 1001
  • Thus we have
    • s e f
    • 0 100 0 010 1 1 00 1000….
    • 4 2 C 8 0 0 0 0 in hexadecimal
    • $42C8 0000 is representation for 100

Another example

Another example

  • Convert $41C8 0000 to decimal
    • 0100 0001 1100 1000 0000 ….
    • S is 0 so positive number
    • Exponent 1000 0011 = 128+3=131-127=
    • f = 1001 so mantissa is 1.
    • With 4 binary positions have 11001 as final number or a decimal
    • 25

Arithmetic with floating point numbers

  • Add op1 $42C8 0000 and op2 $41C8 0000
  • First divide into component parts
    • Op1 $42C8 0000 =0100 0010 1100 1000 0000 ….
      • S = 0
      • E = 1000 0101 = 133 – 127 = 6
      • M (^) op1 = 1.10010000…
    • Op2 $41C8 0000 =0100 0001 1100 1000 0000 ….
      • S = 0
      • E = 1000 0011 = 131 – 127 = 4
      • M (^) op2 = 1.10010000…

Add

  • Add op1 mantissa with the aligned op

mantissa

  • Result exponent is 6
  • Value is 1111101 or 64+32+16+8+4+1=
  • Values added were 100 and 25

Constructing Result Value

  • Sign 0
  • Exponent 6 E = 1000 0101 = 133 – 127 = 6
  • Mantissa of Result 1.
  • Fractional Part 1111010000….
  • Constructed Value
    • 0 100 0010 1 111 1010 0000 0000 0000 0000
    • $4 2 F A 0 0 0 0 (125)

Multiplication example

  • Multiply op1 $42C8 0000 & op2 $41C8 0000
  • First divide into component parts
    • Op1 $42C8 0000 =0100 0010 1100 1000 0000 ….
      • S = 0
      • E = 1000 0101 = 133 – 127 = 6
      • M (^) op1 = 1.10010000…
    • Op2 $41C8 0000 =0100 0001 1100 1000 0000 ….
      • S = 0
      • E = 1000 0011 = 131 – 127 = 4
      • M (^) op2 = 1.10010000…

Multiplication basics

  • Base 10 example
    • 3x10 2 * 1.1x10 2 = 3.3 x 10 4
  • Have 2 numbers A x 2ea^ and B x 2 eb
  • Multiply and get
  • result = A*B x 2 ea+eb

The mantissas

  • Do a binary multiplication
    • 1 1001
    • 1100 1
    • 11001 and add
    • 100111 0001
  • Adjusting for binary point have 10.

Final result

  • • Representation for -
    • – 175 = 128 + 32 + 8 + 4 + 2 +1 =
    • – Or 1.0101111 x
    • – S =
    • – Exponent is 7 +127 = 134 =
    • – Fractional part f =
    • – Or in Hex $C32F – Representation 1100 0011 0010 1111 0000 ….
  • • Exponent is 137 or
  • • Mantissa is 10.
  • • Adjusted for exponent
  • • Value is 2048+256+128+64+
  • • Or 2304+128+68 = 2432 + 68 =
  • • And we were multiplying 100 *