AnsweredAssumed Answered

ADSP-21469 floating point multiplication oddity

Question asked by Bill_T on Aug 14, 2014
Latest reply on Aug 25, 2014 by Bill_T

We are doing tests on some software and are noticing some odd behavior. Our testing philosopy has the testers implement the requirements without knowledge of how the prime software was implemented and then comparing the results as expected from the test execution with the results obtained from executing the prime software.

 

 

The particular problem that we are seeing is that when a simple multiplication of floating point values (same values passed into different functions) is performed.

 

 

Below I have excerpts from the code (note: the ellipses indicate code that is not shown) -

 

 

void Prime_Implementation(..., real32_T rtu_Bandwidth_Hz,

                          ..., real32_T *rty_TP_fltred_mon_error,

   ..., real32_T rtp_two_pi)

{

  real32_T Two_Pi1_lcl;

  ...

 

 

  if (rtu_Reset)

  {

    *rty_TP_fltred_mon_error = 0.0F;

  } else

  {

    Two_Pi1_lcl = rtp_two_pi * rtu_Bandwidth_Hz;

  ...

 

 

}

 

 

void Test_Implementation(..., real32_T rtu_Bandwidth_Hz,

  ..., real32_T *rty_TP_fltred_mon_error,

  ..., real32_T rtp_two_pi)

{

  real32_T N2;

  real32_T N1;

  real32_T N0;

  real32_T D1;

  real32_T D0;

 

 

  real32_T a1 = rtp_two_pi * rtu_Bandwidth_Hz;;

  ...

 

}

 

When each function is called the same arguments are passed in. rtu_Bandwidth_Hz = 0.1686724 (0x3E2CB875) and rtp_two_pi = 6.2813 (0x40C90FF0, which shows up in the register as 6.28131998). The products, however, produce different results.

 

In the prime implementation the assembly instruction for the product is:

 

f6 = f7*f12

 

The register values are

 

Input f7    Input f1    Output f6

0x40C90FF9  0x3E2CB875  0x3F87A79A = 1.0598023

 

The tester implementation assembly instruction for the prodcut is:

 

f7=f11*f12

 

The register values are

 

Input f11   Input f12   Output f7

0x40C90FF9  0x3E2CB875  0x3F87A79B = 1.0598024

 

The value we believe to be the correct value is 0x3F87A79A. The difference is not due to how the processor is set to round because the MODE1 register has the same value at the time each multiplication is performed.

 

 

Can anyone shed some light on why these 2 implementations would produce different results.

 

Thanks,

 

Bill

Outcomes