Hi,

In blackfin documentatation, i did not find any instrinsic for multiply and accumulate operation. There are saperate instrinsics for multiply and add but none of them provides 40 bits acumulation.

I am trying to accumulate with a higher precision.

/*original code*/

int64 acc = 0;

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

{

acc+ = ((in[i] * *coeff++) << 1);

}

/* Saturate */

if (acc> (int64)MAX_INT_32)

{

*out++ = (int16_t)0x7FFF;

}

else if (acc< (int64)MIN_INT_32)

{

*out++ = (int16_t)0x8000;

}

else

{

*out++ = (int16_t)(acc>> 16);

}

using

/*code with intrinsics*/

fract32 acc =0;

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

{

acc = add_fr1x32(acc,mult_fr1x32x32(x[i],a[i]));

}

declaring acc as a fract32 wont help.

are there instrinsics available for 64 bit operations?

is there any alternative?

If you are using VisualDSP++ 5.0 Update 9 or 10 (just released), you can do this using Embedded C accum type variables as shown below:

#include <stdfix.h>

#define N 512

void mac(fract * restrict x, fract * restrict a, fract * restrict out) {

/*code with Embedded C */

accum acc =0;

int i;

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

acc += (x[i] * a[i]);

*out++ = acc;

}

I built the example code optimized using 5.0 Update 10 and the compiled code looks optimal, shown below:

_mac:

P1 = R0;

I0 = R1;

P2 = 511;

P0 = R2;

A0 = 0;

R0 = W[P1++] (X);

R1.L = W[I0++];

LOOP .P33L10L LC0 = P2;

.P33L10:

LOOP_BEGIN .P33L10L;

R2 = (A0 += R1.L * R0.L) || R0 = W[P1++] (X) || R1.L = W[I0++];

LOOP_END .P33L10L;

.P33L11:

R0 = (A0 += R1.L * R0.L);

W[P0] = R0.H;

RTS;

._mac.end:

For more informmation on Embedded C support, see the section "Using Native Fixed-Point Types" in the "C/C++ Compiler and Library Manual for Blackfin Processors" which is available from the help system in VisualDSP++ 5.0 Update 9 or later.

You may also wish to look at the following blog: http://ez.analog.com/blogs/engineerzone-spotlight/2011/08/01/native-fixed-point-types-in-visualdsp-50

Regards,

Stuart.