TMS320F28374S: CLA math accuracy

Part Number: TMS320F28374S
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hi,

One doubt about CLA math accuracy:

1) DataROM is used;

2) fresult=CLAacos(fval) was called;

The result is: 

fval=0.98, fresult=0.20128

fval=0.985, fresult=0.17343

fval=0.99, fresult=0.14221

fval=0.999, fresult=0.074669, accuracy is not good

fval=0.9999, fresult=0.067115, accuracy is not good to

 The value from windows calculator.

Any way to improve it? 

Thanks a lot.

Br, Jordan

  • Hi Jordan,

    The algorithm for the CLAacos() function is as follows:

    The algorithm uses the coefficients hardcoded into the ROM for the calculations. The only options I can think of would be to either edit the algorithm to improve accuracy (the function definition is located in: [C2000Ware install]/libraries/math/CLAmath/c28/source/CLAacos.asm or you could implement the algorithm yourself using the ROM lookup table). You could also make your own lookup table with more precise values and copy them over to the CLA LSRAM for use; however, this would likely take up a lot of LSRAM space.

    Since these are both time consuming and difficult to implement solutions, I unfortunately don't believe there is great way to improve the accuracy.

    Best Regards,

    Delaney

  • Delaney,

    For CLAacos(), CLAsin() and others, from the algorithm, some key words like "index" and "table" are mentioned. Does it mean that, the lookup table is used for these functions?

    I tried to disable lookup table, and switch to the lib "cla1_math_library_fpu32". The result of these functions are always "0". 

    Thanks a lot.

    Br, Jordan

  • Hi Jordan,

    For CLAacos(), CLAsin() and others, from the algorithm, some key words like "index" and "table" are mentioned. Does it mean that, the lookup table is used for these functions?

    Yes, that is correct. The "index" refers to the index in the acos table in ROM and "table" refers to the acos table itself. It would probably be helpful to view the contents of the ROM tables; they are shown in the CLAacosineTable.asm file in the same folder.

    I tried to disable lookup table, and switch to the lib "cla1_math_library_fpu32". The result of these functions are always "0". 

    Please ensure you are following all the steps in the 4.3 Integrating the Library into your Project section of the CLA math users guide (linked here) to use the CLA math library without the ROM tables. 

    Best Regards,

    Delaney

  • Delaney,

    Yes, "Integrating the Library into your Project", these are followed.

    But as you can see from the source file, like CLAacos(), there's "index" and "table". They are using the ROM tables, instead of calculating. 

    Br, Jordan

  • Hi Jordan,

    Yes, the CLA math functions always must use lookup tables for their calculations. As you can see, the ROM table contains hardcoded values, which is why the precision of the calculations really can't be changed unless the values themselves are made to be more precise or if more precise calculations are performed. If you disable the ROM lookup tables and use the non-datarom version of the library, it should instead copy the same tables over to LSRAM and the "index" and "table" attributes would refer to the tables there. 

    Lookup tables are necessary for performing trigonometric functions on the CLA because the CLA cannot call the trig functions included in the math.h library like the c28x can, since the standard header files (including math.h) are not compiled for the CLA. 

    Best Regards,

    Delaney

  • Thanks Delaney.

    Br, Jordan