?? 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輸入時,最大正數(shù)
x[i]=-512; //10bit輸入時,最大負數(shù)
//x[i]=1023; //11bit輸入時,最大正數(shù)
//x[i]=-1024; //11bit輸入時,最大負數(shù)
}
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);
//積分環(huán)節(jié)
for(i=0;i<nDataCnt;i++)
{
pIntg3[i]=intg3;
intg3 +=intg2;
intg2 +=intg1;
intg1 +=pBuf[i];
}
//梳狀濾波器環(huán)節(jié)
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 + -