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.

Converting C5515 Assembly code to C6727B Processorver

Hi,

We have a sample code which is written in assembly.

The instructions for C5515 are 

_Test:

AC0 = 0;

repeat (#351)
AC0 = AC0 + ((*AR0-)* (*AR1+));

(*AR2+) = HI(AC0);
(*AR2) = AC0;

return

The Test routine takes three int16 pointers. The first two are inputs and the third one is output.

What will be the equivalent instructions to convert it to C6727B?

If I understood correctly for C6727B the first two arguments are passed in A4, B4 respectively and the third argument is passed in A6.

What about the equivalent instruction for repeat in C6727B?

Thank You for your time and reading the post

Regards,

GSR

  • GSR,

    I know the code that you are referring to in this case. One key detail that you are missing in your post is the first input pointer is initialized to the last sample in the buffer while the second input pointer is initialized to the first sample in its input buffer. That makes this code equivalent of computing one sample of filtered output using simple convolution of input samples with filter co-efficients. Refer to the diagram below

     I am pretty sure there is equivalent assembly or intrinsic C code for convolution function in C67x DSPLIB found here

    http://www.ti.com/tool/sprc265 (The code however would be for floating point function )

    If that doesn`t work, here is the Equivalent pseudo code

    int32 acc;

    for (i=0; i<FILTERORDER; i++)

     acc=acc+ x1[FILTERORDER-i-1]*x2[i]

    y[1] = (int16) (( acc & 0xFFFF0000)>>16) //Extract top 16 bits

    y[0] = (int16) (acc & 0x0000FFFF)  //Extract bottom 16 bits

    where x1 and x2 are input and y is the output.

    Try that out and let me know. Good luck!!

    Regards,

    Rahul

  • GSR,

    The C6000 Compiler User's Guide has the information you need to learn about interfacing C and Assembly. I doubt I can explain it any better. You seem to know a lot of it already.

    For C6000 applications, it is usually our recommendation to write your application in C, use the optimizer features, then see how good your performance is. It will save you a lot of time and trouble if you can stay with the output of the compiler, and our C6000 compiler is very good. Some complex instructions may have to be accessed using intrinsics, but still through the compiler.

    You can also look at the assembly output from the compiler and use that as a starting point for your assembly development, if you do not like the optimizer's results. This will give you all the basics, like stack space allocation and argument passing. Plus it will give you some good examples to learn C6000 assembly programming from.

    The C5000 and C6000 architectures are both very capable for their intended applications. Really good performance with low power dissipation and low cost make the C5000 perfect for many applications. High performance at high clock rates and high-speed peripherals make the C6000 perfect for many applications. But the architectures are very different, and the C6000 is much less friendly for assembly programming. Please avoid it if at all possible. We make the compiler really good because it is difficult to program the C6000 in assembly.

    Regards,
    RandyP

  • Hi Rahul and RandyP,

    Thank You for the reply.

    I have ported and I am waiting for a sample Input file to test the algorithms.

    Once I have the results I will share with them.

    But, one question regarding Notch Filter? Is it that ECG_FilterProcess is the only function responsible for Notch filter algorithm?

    But, when I tried on C672x CCS simulator the arguments were not passed as expected?

    I expect that the first argument to be passed in A4, and the second input to be in B4 and the last one to be in A6.

    But, I don't see them to be passed as so.

    Please let me know if I am doing anything wrong.

    Regards,

    GSR

  • GSR,

    How are the arguments being passed? Since you are writing in assembly, you are likely debugging in assembly, so you should be able to identify whether the three arguments are being placed into registers as expected, if the wrong values are being placed in the registers, or if the called function accesses values from the wrong registers.

    Rahul probably knows what ECG_FilterProcess is so I will leave this discussion for his expertise.

    Regards,
    RandyP

  • GSR,

    That is correct, convolution of the Order 351 Notch filter coefficients in that example with the input sequence using ECG_FilterProcess is the only function responsible for Notch filter algorithm.

    Let us know how it goes.

    Regards,

    Rahul


  • Hi Rahul,

    Do we have to set acc value to zero?

    However we are seeing a single bit errors after setting acc and workingbuff initialized to zero.

    Can we supply a unsigned 16-Bit data to ECG_ProcessCurrSample API?

    Regards,

    GSR