|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本帖最后由 cjsb37 于 2013-4-29 09:13 编辑
fir.c
#include <fract.h>
//#include "mds_def.h"
#include <filter.h>
#include "received.h"
#include "tfir.h"
#define VEC_SIZE 1999 // length of the input vector
#define NUM_TAPS 6 // number of filter coefficients
//extern void _fir(fract16 *in,fract16 *out,int n,fir_state_fr16 *state);
fract16 in0[VEC_SIZE],in1[VEC_SIZE],in2[VEC_SIZE],in3[VEC_SIZE];
fract16 delay[NUM_TAPS];
fract16 out0[VEC_SIZE ];
fract16 out1[VEC_SIZE ];
fract16 out2[VEC_SIZE ];
fract16 out3[VEC_SIZE ];
complex_fract16 rs[VEC_SIZE];
void main()
{
int i ,c;
fir_state_fr16 state; // declare filter state
for (i=0;i<VEC_SIZE;i++)
{in3=r[4*i] ;
in2=r[4*i+1];
in1=r[4*i+2];
in0=r[4*i+3];}
//convolve_fr16(in0,VEC_SIZE,h0,4,out0);
//convolve_fr16(in1,VEC_SIZE,h1,4,out1);
//convolve_fr16(in2,VEC_SIZE,h2,4,out2);
//convolve_fr16(in3,VEC_SIZE,h3,4,out3);
fir_init(state, h0, delay, NUM_TAPS,1); // initialize filter state
fir_fr16(in0, out0, VEC_SIZE, &state); // apply the filter to the data
delay[0]=0;delay[1]=0;delay[2]=0;delay[3]=0;delay[4]=0;delay[5]=0;
fir_init(state, h1, delay, NUM_TAPS,1);
fir_fr16(in1, out1, VEC_SIZE, &state);
delay[0]=0;delay[1]=0;delay[2]=0;delay[3]=0;delay[4]=0;delay[5]=0;
fir_init(state, h2, delay, NUM_TAPS,1);
fir_fr16(in2, out2, VEC_SIZE, &state);
delay[0]=0;delay[1]=0;delay[2]=0;delay[3]=0;delay[4]=0;delay[5]=0;
fir_init(state, h3, delay, NUM_TAPS,1);
fir_fr16(in3, out3, VEC_SIZE, &state);
for (i=0;i<VEC_SIZE;i++)
{ rs.re=out0-out2;
rs.im=out1-out3;
//printf("in0[%d]=%d,",i,in0);
//printf("out0[%d]=%d,",i,out0);
//printf("h0[%d]=%d,",i,h0);
//printf("rs[%d]=%d+%dj\n",i,rs.re,rs.im);
}
//printf("rs=%d+%dj\n",rs[0].re,rs[0].im);
}
|
|