Hi Guys i want to implement iir filter in assembly in c64x processor. preferably fixed point algorithm. Here is the c code of iir filter which i have written.

#include<stdio.h>
void main()
{

float ip1_seq[10]={1,1,1,1};
float b[10]={0.049,0.074,0.105,0.074,0.049},a[10]={-1.715,1.726,-0.85,0.195};
int len_ip=4,al=5,bl=5;
int n,k,i,len_seq=0;
float op_seq[10]={0},op1_seq[10]={0},op2_seq[10]={0};

len_seq=al;
if(al!=bl)
len_seq=(al<bl)?bl:al;
if(len_seq!=len_ip)
len_seq=(len_seq<len_ip)?len_ip:len_seq;


 for(i=len_ip;i<len_seq;i++)//padding zeros
  ip1_seq[i]=0;

 for(i=al;i<len_seq;i++)//padding zeros
  a[i]=0;

 for(i=bl;i<len_seq;i++)//padding zeros
  b[i]=0;

//CIRCULAR CONVOLUTION EQUA IMPLEMENTATION	  
  
  for(n=0;n<len_seq;n++)
{
    
    for(k=0;k<=n;k++)
	{
	op1_seq[n]+=b[k]*ip1_seq[n-k];
    }
 
    for(k=0;k<=n;k++)
	{
	op2_seq[n]+=(-a[k])*op_seq[n-k];
    }
    op_seq[n+1]=op1_seq[n]+op2_seq[n];
}
 

//END OF CIRCULAR CONVOLUTION EQUATION


//DISPLAY OUTPUT

for(k=1;k<len_ip+1;k++)
printf("%f\n",op_seq[k]);

//END OF DISPLAY OUTPUT





}

So what do you want us to do about it?

Do you have a C compiler which targets your processor?
The GCC compiler does - http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Submodel-Options.html#Submodel-Options

Having found that, does your existing algorithm have adequate performance without resorting to hand-crafting fixed point for everything?

As a first step, I would consider wrapping each of the floating point operations as function calls, to make for easier substitution later on. Of course, if you did this in C++, it would be a breeze as you could just write a fixed point class with a few inline functions and let it do all th e work for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.