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.

fixed point trigonometric functions for c6416.

Other Parts Discussed in Thread: CCSTUDIO

I need  to use fixed point trigonometric functions (i.e. atan2) in DSK6416 (C6416 on it).

I tried to use IQmath (for C64+), but it didn't work properly on C6416.

Where can I have trigonometric fuctions for C6416?

Thanks in advance.

  • For for Q math, there is an IQmath compatible with the C6416 at the following forum post:

    http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/112/p/11535/44931.aspx#44931

     

     

  • Mariana,

    Thanks for your reply. However, I still have the errors regarding some unresolved functions as follows:

    I have included the following libs: csl6416.lib, dsp64x.lib, IQmath_c64x_v212.lib, rts6400.lib

    BTW, I'm trying to use IQatan2 function.

     

    undefined                        first referenced
     symbol                              in file
    ---------                        ----------------
    _IQatan2Table                    C:\\CCStudio_v3.3\\c64plus\\IQmath_v213\\lib\\IQmath_c64x_v212.lib
    _IQatan2HalfPITable              C:\\CCStudio_v3.3\\c64plus\\IQmath_v213\\lib\\IQmath_c64x_v212.lib
    __mpy32ll                        C:\\CCStudio_v3.3\\c64plus\\IQmath_v213\\lib\\IQmath_c64x_v212.lib
    _IQdivTable                      C:\\CCStudio_v3.3\\c64plus\\IQmath_v213\\lib\\IQmath_c64x_v212.lib
    >>   error: symbol referencing errors - './Debug/sun_wg_dsp_dsk6416.out' not
                built

    >> Compilation failure

    Build Complete,
      2 Errors, 5 Warnings, 0 Remarks.

     

     

  • sm said:
    __mpy32ll                        C:\\CCStudio_v3.3\\c64plus\\IQmath_v213\\lib\\IQmath_c64x_v212.lib

    Searched a little and it seems that you need to implement some of the instrinsics that only work for C64x+ in C code (use optimization as in the forst post below):

    https://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/112/p/11853/46405.aspx#46405

    http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/99/p/7048/27375.aspx#27375

     

    Do you have IQmah_RAM_c64x+.lib included?

    http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/112/p/54332/192818.aspx#192818

  • Mariana,

    Thanks for your help.

    I have linked IQmath_RAM_C64x+.lib and also have created my own _mpy32ll() intrinsic replacement.

    So, now I don't have any error regarding unresolved symbols or functions during the compilation and linking my codes.

    However, the result of the function _IQatan2() is not correct. It does't work properly.

    Is there any other trigonometric function libraries for c6416?

    Or what else do I need to try to make this IQmath lib run correctly on C6416?

     

     

  • Hi sm,

    sm said:
    However, the result of the function _IQatan2() is not correct. It does't work properly.

    What do you mean by wrong result? Can you be more specific?

    If you want, attach your project and I can take a look at the results for you.

     

    You can always use the regular RTS function, but as it will emulate floating point, it will take many more cycles than the IQmath:

    #include <math.h>

    void main()
    {

    float a, b;

    b = 3.1416/4; //pi/4 = 45 degrees

    a = tan(b);

    b= atan(a);

    }

  • Mariana, Thanks again for your reply. My test code is very simple. The result in out1 should be pi/4.

    But the result from C6416 is always "0".

    void main()
    {
      float a;
      float b;
      float c;

      _iq xin1;
      _iq yin1;
      _iq out1;

      xin1 =_FtoIQ(0.5);
      yin1 =_FtoIQ(0.5);        
      out1=_IQatan2( yin1, xin1 );   // "out1" should be 13176794(dec), 0x00C90FDA, => 0.7854 (pi/4) in Q24. But it is always '0' in c6416.

      a = 0.5;
      b = 0.5;
      c = 0;
      c = atan(a/b);

    }

    The following is the part of my project file.

    ; Code Composer Project File, Version 2.0 (do not modify or remove this line)

    [Project Settings]
    ProjectDir="C:\svn\sun_wg_dspsw\"
    ProjectType=Executable
    CPUFamily=TMS320C64XX
    Tool="Compiler"
    Tool="CustomBuilder"
    Tool="DspBiosBuilder"
    Tool="Linker"
    Tool="XDC"
    Config="Debug"
    Config="Release"

    [Source Files]
    Source="..\..\..\CCStudio_v3.3\c6400\dsplib\lib\dsp64x.lib"
    Source="..\..\..\CCStudio_v3.3\c64plus\IQmath_v213\lib\IQmath_c64x_v212.lib"
    Source="..\..\..\CCStudio_v3.3\c64plus\IQmath_v213\lib\IQmath_RAM_c64x+.lib"
    Source="C:\CCStudio_v3.3\C6000\cgtools\lib\rts6400.lib"
    Source="C:\CCStudio_v3.3\C6000\csl\lib\csl6416.lib"
    Source="intvecs.asm"
    Source="main.c"
    Source="math_functions.c"
    Source="rcv_functions.c"
    Source="lnk_dsk6416.cmd"

  • Can you attach your full test project this way I can try to debug it?

  • Mariana,

    How can I attach the files in the posting?

    I cann't find any file attachment menu.

     

  • When you are replying, click on options on the top:

  • Mariana,

    My project file. main.c, and link command file are zipped and attached.

    sun_wg_dspsw.zip
  • Mariana,

    I have attached new zip file (sun_wg_dspsw_new.zip).

    The project file in the previous attachment has unnecessary customized header files, so I had removed them.

    With the new project file, I could reproduced the problem, too.

     

    sun_wg_dspsw_new.zip
  • Hi Sm,

    It took me a while to figure this out. I had to generate a new library that contains the declaration to the "instrisics" inside of it:

    extern long long _mpy32ll(int a, int b);
    extern long long _mpy32su(int src1 , int src2);
    extern long long _mpy32us(unsigned src1 , int src2);
    extern long long _mpy32u(unsigned src1 , unsigned src2);

    So use replace IQmath_c64x_v212.lib and IQmath_RAM_c64x+.lib with the IQmathC64x.lib attached to the post. So you still need the intrinsic-like function in your code, but the library inside has the declaration so it knows how to deal with the function.

     

    IQmathC64x.lib
  • Mariana, thanks for your help.

    I replaced the IQmath_c64x_v212.lib and IQmath_RAM_c64x+.lib with the library (IQmath_c64x.lib) that  you have provided.
    Also, I had added the following instrinsic functions in my codes.

    long long _mpy32ll(int a, int b)
    {
        return (long long)(a * b);
    }
    long long _mpy32su(int a, unsigned int b)
    {
        return (long long)(a * b);
    }
    long long _mpy32us(unsigned int a, int b)
    {
        return (long long)(a * b);
    }
    long long _mpy32u(unsigned int a, unsigned int b)
    {
        return (long long)(a * b);
    }


    But I still have errors:

    [Linking...] "C:\CCStudio_v3.3\C6000\cgtools\bin\cl6x" -@"Debug.lkf"
    <Linking>
    >> warning: creating output section $build.attributes without SECTIONS
                specification

    undefined                        first referenced
     symbol                              in file
    ---------                        ----------------
    __mpy32                          C:\\CCStudio_v3.3\\c64plus\\IQmath_v213\\lib\\IQmathC64x.lib
    __dmv                            C:\\CCStudio_v3.3\\c64plus\\IQmath_v213\\lib\\IQmathC64x.lib
    >>   error: symbol referencing errors - './Debug/sun_wg_dsp_dsk6416.out' not
                built

    >> Compilation failure

    Build Complete,
      2 Errors, 2 Warnings, 0 Remarks.
     
     
    I have attached my project file with my source code.
    Only change which I had made is adding intrinsic functions.
    Would you take a look?

     

     

     

     

    sun_wg_dspsw_20100728.zip
  • Hi sm,

    See corrected project attached.

    I had to:

    - remove the template form the cmd file as it is a reserved name

    - correct your mv option in the compiler options

    - the intrinsics have to come before the iqmath.h inclusion.

    - replace return (long long)(a * b); with return (long long)a * b; in the "intrinsics" functions

     

    sun_wg_dspsw_20100728.zip
  • Hi sm,

    Attached is a new version with all the intrinsics included (_mpy32 and _dmv as well). So you do not need to have the intrinsics in your project any more, I put them inside the library with -o3 and recompiled it.  So please try again with this new one if you have any problems.

    Should work wih:

    #define GLOBAL_Q (29)

    #include "IQmath.h"


    void main()
    {

      _iq xin1;
      _iq yin1;
      _iq out1;

      xin1 =_FtoIQ(0.5);
      yin1 =_FtoIQ(0.5);        
      out1=_IQatan2( yin1, xin1 );  

    }

    IQmathC64xrelease.lib
  • Mariana,

    Thank you very much. The atan2 function in IQmath lib finally work in DSK6416!!!

    I much appreciate your help. I believe your work & publication in the wiki will help many C6416 users.

    BTW, I cannot find the "Verify Answer" button in the page so I could not finalize this posting.

     

  • Hello Mariana,

     

    I would like to simulate the operation of a C6416 on a PC and also use the IQmath library.  I have downloaded the C6000 Host Instrinsics package, and I also have downloaded the IQmath source code for the C64x+.  But to get this to work for the C64x (not C64x+), I need the optimized C-code that implements the C64x+ instrinsics (_mpy32ll, _mpy32su, _mpy32us, _mpy32u, _mpy32, _dmv).  Is it possible to get this code?

     

    Thank you,

    -Rich