This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Information about: instruction EISQRTF32

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

I am currently validating a algorithm on a C2000 FPU platform.

For this I compare results from Matlab and C2000 FPU target.

All processing are done in Floating single precision (singe in Matlab).

As of today, results are matching perfectly (binary comparison of the Floating single precision results).

However for "sqrt" function results does not match.

The difference comes from the "estimate of the inverse square root of x".

On the C200 target it is done with the instruction: EISQRTF32

On Matlab, I am calling a custom function to calculate the Estimate.

I am using one based on the famous : 5f3759df

Find below an example:

Find the estimate of x equal to  x = 0.0003424387

1) With TI:
x= 0.0003424387
R0=x
EISQRTF32 R1H, R0H
R0= 0x39b38958   Note: R0 = 0.0003424387
R1= 0x42580000            

2) With 5f3759df solution:

x= 0.0003424387
int i = *(int*)&x; // convert to binary integer    -----> i = 968067416 = 0x39b38958
i = (i >> 1)                                                      -----> i =                    = 0x1cd9c4ac
i = 0x5f3759df - i; // the smart trick                -----> i = 968067416 = 0x425d9533
x = *(float*)&i; // convert binary back to decimal

So :

TI result: 0x42580000 

Other:     0x425d9533

Could you please indicate to me what is behind the EISQRTF32 instruction ?

Thanks and best regards,

Mathieu

  • Mathieu,

    The hardware inverse square root method used in the FPU is the same as that in the fastRTS library.  You can find that in controlSUITE and I have attached the code to this post.

    The FPU implementation takes 2 pipeline cycles and delivers a more accurate result than the integer method you mention.

    FPU:                            54.0

    integer method:        55.3957024

    exact answer:            54.0391588252752

    On this basis I don't think the integer method offers any advantage.

    Regards,

    Richard

    isqrt_f32.asm

  • Hi Richard,

    Thanks for the quick answer.

    However my request was not to complain about FPU result.
    I just need to know what is doing the "FPU implementation that takes 2 pipeline cycles and delivers a more accurate result than the integer method you mention."
    Indeed I have an debug environment based on Matlab that first provides Matlab results, then via the Texas Instruments DS SCRIPTS (DSS) tool launch Target processing and then compares the results. It works fine except for "sqrt". I want to keep what is doing the FPU but I want to change my Matlab sqrt function to match the FPU F28335 behavior.
    Could you please provide how the FPU is doing to provide 54.0 as result (EISQRTF32 R1H, R0H)?

    Thanks a lot for your help.
    Regards,
    Mathieu
  • Hi Mathieu,

    This particular instruction is part of the FPU core.  It uses a look-up table to make a first approximation of inverse square root.  The expectation is that a user will apply the result in a Newton-Raphson algorithm to get a more accurate answer.

    The attachment shows equivalent C code and the two look-up tables involved in the approximation.

    Regards,

    Richard

    EISQRTF32.pdf

  • Thanks a lot Richard to share this information with TI C2000 FPU users !
    I integrated in my Matlab code and now results are matching.
    It helps a lot to have such a good support.
    Thanks again and best regards
    Mathieu