Docsity

Floating Point Adder - HDL Design - Lecture Slides, Slides of Verilog and VHDL

Partial preview of the text

Download Floating Point Adder - HDL Design - Lecture Slides and more Slides Verilog and VHDL in PDF only on Docsity!

IEEE Floating Point Adder

Using the IEEE Floating Point

Standard for an add/subtract

execution unit

Lecture overview

  • The Interface
  • Part by part
  • A floating point adder design

Specification of a FPA

  • Floating Point Add/Subtract Unit
  • Specification
    • Inputs in IEEE 754 Double Precision
    • Must perform both addition and subtraction
    • Must handle the full floating point standard
      • Normalized numbers
      • Not a Numbers – NaNs
      • +/- Infinity
      • Denormalized numbers

Specifications continued

  • Result will be a IEEE 754 Double Precision representation
  • Unit will correctly handle the invalid operation of adding + ∞ and - ∞ = Nan per the standard
  • Unit latches it inputs into registers from parallel 64-bit data busses.
  • There is a separate signal line that indicates the operation add or subtract

High level block diagram

  • Basic architecture interface
    • Data – 64 bit A,B,& C Busses
    • Control signals – Latch, Add/Sub, Asel, Drive
    • Condition Flags Output – 7 Flag signals
    • Clocks – Phi1 and Phi2 (a 2 phase clocked architecture

Floating Point AdderUnit

Abus Bbus

Cbus Flags

Add/SubLatch

DriveAsel

Phi2Phi

Start the VHDL

  • The entity interface

FloatingPoint Adder

A_Main B- Main Add_or_sbub LatchPhi DrivePhi Asel C_Main A_Out Flags

entity Floating_Point_Adder is port (A_Main : in BIT_VECTOR; B_Main : in BIT_VECTOR; C_Main : out BIT_VECTOR; A_Out: out BIT_VECTOR; Flags : out BIT_VECTOR; Add_or_sub : in BIT; Latch : in BIT; Drive : in BIT; Phi1 : in BIT; Phi2 : in BIT; Asel : in BIT ); end Floating_Point_Adder;

What goes in the other blocks

  • Adjusting the inputs to prepare to add
  • The add
  • Then renormalize
  • Finally round result

INPUT LATCHES

Add Mantissas Normalize Result

RESULT LATCHES OUTPUT DRIVERS

Input Adjust

A/S

Round according to selected scheme

VHDL coding for the latched

  • A first cut
  • The input latches
  • Note 2 phase

b1: block ((Phi2 and Latch) = '1') begin A_temp <= guarded A_Main; B_temp(63) <= guarded Add_or_sub xor B_Main(63); end block;^ B_temp(62 downto 0) <= guarded B_Main(62 downto 0); b2: block (Phi1 = '1') begin signa <= guarded A_temp(63); signb <= guarded B_temp(63); expa <= guarded A_temp(62 downto 52); expb <= guarded B_temp(62 downto 52); mana <= guarded A_temp(51 downto 0); end block;^ manb^ <= guarded B_temp(51 downto 0);

And what goes in between?

  • In the final design, lots goes in between, but
  • You first want to make sure that the latches are working properly
  • So just pass one input to the output and check
  • And once this works properly can move on with the design

signout <= signa; exp_round <= expa; man_round <= '0' & A_temp;

The first section

  • Prepare to add
  • Identify type of inputs and appropriately adjust operands

Processing^ MantissaLogic

Amantissa Bmantissa

M>M=M<MA0MB 0 EA0•MA0 (^) selR^ EA0 & Aman L 2-1 Mux^ Aman & 0 R^ EB0 & Bman Bman & 0 EB0•MB E>+(E=•M>) Swap 2x2 crossbars elements

selR L 2-1 Mux R

EA1+EB1 selR L 2-1 Mux R^ "Zero"^ selR L 2-1 Mux R"Nan" Cntrl Eq Shift Dist LinearShifter^ Right SignA xor SignB^ selR^ L^ 2-1 Mux^ R ADDER

ProcessingExponentLogic

Aexp Bexp

Larger Exp Shif t DistE>E=E<EA0EA1EB 0EB 1 (to Norm Unit)

Asign Bsign

2-1Mux (^) (E> + (E=•M>)) Sign Out (63)to output latch

Adder Output (to normalize unit)

Mantissa Processing Logic

  • Need to examine the two fractional parts and

generate several control signals that are

required to prepare the operands

  • Need relational signals M>, M=, M<
    • Needed to know which operand to shift
  • Need to know if stored fractional part if all 0’s

or not

  • Needed for NaN, 0, ∞ and determination

After generating control signals

  • Step 1 is to select between a normalized mantissa and a denormalized mantissa
  • For normalized – Prepend NOT(Ex0)
    • If Ex0 is a 1 then the exponent if all 0s and you have a denormalized number or 0
    • When Ex0 is a 0 you have a NaN, infinity, or a normalized number
  • Other selection is the factional part shifted left by 1 and postpended by a 0 - For denormalized numbers - Taking it from 2-126^ to 2-127^ and can now treat it like a normalized number

Shown in table form ??skip

  • Selection table to also point out this relationship
  • Note that for a 0 have NOT(Ex0) prepended to the fractional part or a 0.00000…

Ex0 Mx0 Mx0 Ex0*Mx Select R Select L 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 denorm

normNaN 0

infinity

Selections are input to a crossbar

  • The crossbar switch place the larger value on

the right path and the small onto the left path

  • The small is the operand to shift if any shifting

to align the binary point is needed

  • The equation for exchange on the crossbar is
    • E> + (E=*M>) or shift the A input to the right side if the exponent of A is the larger OR the exponents are equal and the fractional part of A is larger