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.

TMS320C5509a DSP, Problems 55xdsps-functions, mmul(), mul32()

Hello, 

im using the TMS320C5509a DSP Board and try to realize some filter functions while using the basic functions of the 55xdspx.lib.

The Problem is that the add()-function seems to work but the multiplikation only results in zeros.

I couldnt find a proper solution yet and hope that someone here could help me.
I think its basicly an implementation problem, so that i put one of my failed versions here. In hope someone here mite be able to tell me where i was wrong.

    DATA Werte_1[] ={16384, 16384/2, 16384/4, 16384/8};
    DATA Werte_2[4] ={0};

    LDATA L_Werte_2[4] ={0};

    LDATA L_Werte_1[4]={0}; LDATA L_Werte_12[4]={0}; LDATA L_Werte_2[4]={0};

    L_Werte_1[0]=1024;
    L_Werte_1[1]=1024*2;
    L_Werte_1[2]=1024*8;
    L_Werte_1[3]=1024*12;

    L_Werte_12[0]=1024;
    L_Werte_12[1]=1024*2;
    L_Werte_12[2]=1024*8;
    L_Werte_12[3]=1024*12;

    err= mul32(L_Werte_1, L_Werte_12,  L_Werte_2, 4);
    err= mmul(Werte_1,4,1,Werte_1,4,1,Werte_2);

I hope someone can help me.

  • In your C file, are you including the proper header file for that library?
  • I included following header files
    #include <stdlib.h>
    #include <math.h>
    #include <tms320.h>
    #include <stdio.h>
    #include <dsplib.h>

    which works for the add()-function of the dsp-lib. So that i guess it should be correct one.
  • One sidenote: ihave to use ccs v3.3 and develop a large memory model program.

  • The result you have obtained from mul32 is correct.  Remember that this is Q31*Q31 => Q31 multiplication, so very small numbers like you have used will of course round to zero.  Try using numbers close to INT32_MAX, or alternatively just use standard integer multiplication.

    Regards,

    Bill

  • At first, thank u very much for the help.

    Second, yes i forgot that when i first tried this function. But do u have any idea, what mistake ore configuration could lead to the zeros by using the mmul()-Function?

    Thats the actual function i planed to use in order to efficiently multiply my adc-value with the coefficients of my digital filter, which are safed in an array. Cause of the reason that this function uses both adu's i hoped to achieve a faster filter.


    So i hope u can help me with that matter too.

    Regards Peter


    P.S. im using a function with (DATA value1 * DATA value2)>>15 right now. That works but i still hope to get better (faster) results by using ur optimized functions

  • Hey Bill,


    its rearly important that i get that i get that mmul()-Function working.

    Could u just give a simple example, where it should working, so that i can eliminate the posibility of a wrong implementation?

    I hope u can help me with that

    Regards,

    Peter

  • As Bill suggested, try this:

        L_Werte_1[0]=INT32_MAX; /* represents 0.99999999953433871 as Q31 */
        L_Werte_1[1]=INT32_MAX/2; /* represents 0.49999999976716936 as Q31 */
        L_Werte_1[2]=INT32_MAX/8;
        L_Werte_1[3]=INT32_MAX/12;
    
        L_Werte_12[0]=INT32_MAX;
        L_Werte_12[1]=INT32_MAX/2;
        L_Werte_12[2]=INT32_MAX/8;
        L_Werte_12[3]=INT32_MAX/12;
  • Thank u for the fast answer,

    but i already know that the mul32()-Funktion mite work this way. But i have to work with 16Bit Values so that this function is probably only the last option.
    What i was hoping for was an example for the correct use and results of the mmul()-Function (its for DATA-Values, array has to have more then 4 values).
    That example and the resluts would help alot to figure out if the failure is only based on a false handling or mite lead to bigger problems like bugs, hardware problem and so one.

    So that i still hope you are able to help me.

    Regards ,

    Peter
  • Peter,

    Unfortunately, I've never used the mmul function before.  If you can wait until next week I can play around with it and see how it works.

    Regards,

    Bill

  • Bill,

    it would be great if u could do so.

    Regards,

    Peter

  • Peter,

    I found your problem, which was rather obvious in retrospect.  The mmul function implements matrix multiplication, so it expects

    A x B

    where A is m1-by-n1, and B is m2-by-n2, where n1 equals m2, and the result is m1-by-n2.  It returns an error if n1 does not equal m2.

    I think you want vector multiplication, which somewhat ironically the DSPLIB doesn't have for 16-bit numbers.

    If you're doing filtering, shouldn't you use FIR or convol or one of the IIR functions?

    Regards,

    Bill

  • Peter,

    In case you really need vector multiplication, I banged out the attached assembly function.

    As an example, using your data:

    extern void mul16(DATA *x, DATA *y, DATA *r, short n);

    DATA Werte_1[] ={16384, 16384/2, 16384/4, 16384/8};
    DATA Werte_2[4] ={0};

    mul16(Werte_1, Werte_1, Werte_2, 4);

    fills Werte_2 with:

    8192 2048 512 128

    Regards,

    Bill

    mul16.c55x.asm

  • We try to compare different implementations on fpga's and dsp's in VHDL and C. So that we have to realize nealry similar structures. Assemblerfunctions are only ok as long as they are only perform basic functions like multiplications. And im not the one in charge and have to do as wished.

  • Thanks for the code but can u also tell me how to implement the assembler-function?
  • Peter,

    I don't know what you mean.  I've given you documented code, and an example of how to use it.  What more could you want?

    Bill

  • Thanks Bill, your mul16 function saved me some time. Not sure why this isn't part of DSPLIB.