📄 cicfilter.cpp
字号:
// CICFilter.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <memory.h>
//试验一个16bit的CIC滤波器溢出的情况
void CIC_Filter(int nDataCnt,short *pBuf,short *pOut,int R);
int main(int argc, char* argv[])
{
printf("CIC Filter Test!\n");
short x[1024];
short y[1024];
for(int i=0;i<1024;i++)
{
x[i]=511; //10bit输入时,最大正数
x[i]=-512; //10bit输入时,最大负数
//x[i]=1023; //11bit输入时,最大正数
//x[i]=-1024; //11bit输入时,最大负数
}
memset(y,0,1024*sizeof(short));
CIC_Filter(1024,x,y,4);
return 0;
}
void CIC_Filter(int nDataCnt,short *pBuf,short *pOut,int R)
{
short intg1=0;
short intg2=0;
short intg3=0;
short dump1=0;
short dump2=0;
short dump3=0;
int i;
short *pIntg3=new short[nDataCnt];
short *pDump1=new short[nDataCnt];
short *pDump2=new short[nDataCnt];
memset(pIntg3,0,nDataCnt);
memset(pDump1,0,nDataCnt);
memset(pDump2,0,nDataCnt);
//积分环节
for(i=0;i<nDataCnt;i++)
{
pIntg3[i]=intg3;
intg3 +=intg2;
intg2 +=intg1;
intg1 +=pBuf[i];
}
//梳状滤波器环节
for(i=R;i<nDataCnt;i++)
{
pDump1[i]=dump1;
dump1=pIntg3[i] - pIntg3[i-R];
}
for(i=R;i<nDataCnt;i++)
{
pDump2[i]=dump2;
dump2 = pDump1[i] - pDump1[i-R];
}
for(i=R;i<nDataCnt;i++)
{
pOut[i]=dump3;
dump3 =pDump2[i] - pDump2[i-R];
}
delete [] pIntg3;
delete [] pDump1;
delete [] pDump2;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -