# Fixed point IIR filter implementation

Question asked by RomanR on May 30, 2016
Latest reply on Jun 16, 2016 by Mitesh

Hi,

have a problem with IIR filter implementation in assembler.

Here is C code:

 w=sample+cbuf[0]*coeff[4]+cbuf[1]*coeff[3];

y=w*coeff[2]+cbuf[0]*coeff[1]+cbuf[1]*coeff[0];

cbuf[1]=cbuf[0];

cbuf[0]=w;

And the assembler version:

/*    r4=sample

r8=coefficients

r12=state    */

i4=r12;        // i4->stat

i12=r8;        // i12->coef+4

modify(i12,4);

m12=-1; m4=1;

r0=dm(i4,m4), r8=pm(i12,m12);

mrf=r0*r8(SSF), r0=dm(i4,m4), r8=pm(i12,m12);

mrf=mrf+r0*r8(SSF), r8=pm(i12,m12);

r12=mr1f;

modify(i4,-2);

r12=r12+r4;      // w

mrf=r12*r8(SSF), r4=dm(i4,m4), r8=pm(i12,m12);         // w*coef(2)

mrf=mrf+r4*r8(SSF), r0=dm(i4,m4), r8=pm(i12,m12);

mrf=mrf+r0*r8(SSF);

r0=mr1f;

dm(-1,i4)=r4;

dm(-2,i4)=r12;    //*/

leaf_exit;

==================================

I do not know, why this code is not working, but should.

I don't see any logical error.

Maybe someone has an example of fixed point IIR filter implementation for SHARC ?

Regards

Roman