導航:首頁 > 編程語言 > cic濾波器程序

cic濾波器程序

發布時間:2023-01-30 13:43:36

㈠ 梳狀濾波器MATLAB

CIC 在Matlab中有固定的函數,直接用就可以了,它是一個object,你查一下help。

㈡ 誰會用matlab設計一個CIC濾波器,要有完整的程序,謝謝了

CIC抽取補償濾波器設計,CIC濾波器採用5階8倍抽取
如下:
%
%THIS IS A WIZARD GENERATED FILE. DO NOT EDIT THIS FILE!
%
%---------------------------------------------------------------------------------------------------------
%This is a filter withfixed coefficients
%This Model Only Support Single Channel Input Data.
%Please input:
%data vector: stimulation(1:n)
%
% This Model Only Support FIR_WIDTH to 51 Bits
%
%FILTER PARAMETER
%Input Data Type: Signed
%Input Data Width: 13
%FIR Width (Full Calculation Width Before Output Width Adjust) : 23
%-----------------------------------------------------------------------------------------------------------

%MegaWizard Scaled Coefficient Values
function output = CIC8_fir_comp_mlab_mat (stimulation, output)
coef_matrix=[0 0 1 0 -2 -3 0 7 10 1 -17 -26 -5 46 102 127 102 46 -5 -26 -17 1 10 7 0 -3 -2 0 1 0 0 ];
INTER_FACTOR = 1;
DECI_FACTOR = 1;
MSB_RM = 0;
MSB_TYPE = 0;
LSB_RM = 0;
LSB_TYPE = 0;
FIR_WIDTH = 23;
OUT_WIDTH = FIR_WIDTH - MSB_RM - LSB_RM ;
DATA_WIDTH = 13;

data_type= 1;

% check size of inputs.
[DX,DY] = size(stimulation);
[CX,CY] = size(coef_matrix);
if (CX ~= DY * INTER_FACTOR)
fprintf('WARNING : coef_matrix size and input data size is not match\n');
end

%fill coef_matrix to length of data with the latest coef set
if (CX < DY * INTER_FACTOR)
for i= CX +1:DY * INTER_FACTOR
coef_matrix(i,:) = coef_matrix(CX,:);
end
end

%check if input is integer
int_sti=round(stimulation);
T = (int_sti ~= stimulation);
if (max(T)~=0)
fprintf('WARNING : Integer Input Expected: Rounding Fractional Input to Nearest Integer...\n');
end

%Input overflow check
switch data_type
case 1
%set max/min for signed
maxdat = 2^(DATA_WIDTH-1)-1;
mindat = -maxdat-1;
case 2
%set max/min for unsigned
maxdat = 2^DATA_WIDTH-1;
mindat = 0;
end

if(data_type == 2)
if(abs(coef_matrix) == coef_matrix)
FIR_WIDTH = FIR_WIDTH +1;
end
end

%Saturating Input Value
a=find(int_sti>maxdat);
b=find(int_sti<mindat);
if (~isempty(a)|~isempty(b))
fprintf('WARNING : Input Amplitude Exceeds MAXIMUM/MINIMUM allowable values - saturating input values...\n');
lena = length (a);
lenb = length (b);
for i =1:lena
fprintf('%d > %d \n', int_sti(a(i)), maxdat);
int_sti(a(i)) = maxdat;
end
for i =1:lenb
fprintf('%d < %d \n', int_sti(b(i)), mindat);
int_sti(b(i)) = mindat;
end
end

% Add interpolation
inter_sti = zeros(1, INTER_FACTOR * length(int_sti));
inter_sti(1:INTER_FACTOR:INTER_FACTOR * length(int_sti)) = int_sti;

for i = 1 : DY *INTER_FACTOR
coef_current = coef_matrix(i,:);
output_temp(i) = simp_adaptive (inter_sti, coef_current, i);
end
% Truncate output
len1 = length(output_temp);

switch LSB_TYPE
case 0
%truncate
out_dec = bi_trunc_lsb(output_temp,LSB_RM,FIR_WIDTH);
case 1
%round
out_dec = bi_round(output_temp,LSB_RM, FIR_WIDTH);
end

switch MSB_TYPE
case 0
%truncate
out_dec = bi_trunc_msb(out_dec,MSB_RM,FIR_WIDTH-LSB_RM);
case 1
%round
out_dec = bi_satu(out_dec,MSB_RM, FIR_WIDTH-LSB_RM);
end

% choose decimation output in phase=DECI_FACTOR-1
if(DECI_FACTOR == 1)
output = out_dec;
else
output = out_dec(DECI_FACTOR:DECI_FACTOR:len1);
end

function[output, outindex] = simp_adaptive (int_sti, coef_current, data_index, output)
%Simulation is the whole input sequence
%coef_current is the current coefficient set
%data_index gives the last data to use
%outputs are the sum of input and coef multiplication
%outindex is the next data_index

sti_current = zeros(length(coef_current),1);

data_length = length(int_sti);

%Check data index
if (data_index > data_length)
fprintf('ERROR: DATA INDEX IS LARGER THAN DATA LENGTH!!!\n');
return;
end
for i = 1: length(coef_current)
if ((data_index -i+1)>0 & (data_index - i+1)<=data_length)
sti_current(i,1) = int_sti(data_index - i+1);
end
end

outindex= data_index+1;
output = coef_current * sti_current;
% end of function simp_adaptive

function output = bi_round(data_in,LSB_RM,ORI_WIDTH, output)
% LSB_RM is the bit to lose in LSB
% ORI_WIDTH is the original data width
data = round (data_in / 2^LSB_RM);
output = bi_satu(data,0,ORI_WIDTH - LSB_RM);
%end of function bi_trunc_lsb

function output = bi_trunc_lsb(data_in,LSB_RM,ORI_WIDTH, output)
% LSB_RM is the bit to lose in LSB
% ORI_WIDTH is the original data width
%2's complement system
output = bitshift(2^ORI_WIDTH*(data_in<0) + data_in, -LSB_RM) - 2^(ORI_WIDTH-LSB_RM) *(data_in<0);
% end of function bi_round

function output = bi_trunc_msb(data_in,MSB_RM,ORI_WIDTH, output)
% MSB_RM is the bit to lose in LSB
% ORI_WIDTH is the original data width
%2's complement system
data = 2^ORI_WIDTH * (data_in < 0)+ data_in;
erase_num = 2^(ORI_WIDTH - MSB_RM) - 1;
data = bitand(data, erase_num);
output = data - 2^(ORI_WIDTH - MSB_RM)*(bitget(data,ORI_WIDTH - MSB_RM));
%end of bi_trunc_msb

function output = bi_satu(data_in,MSB_RM,ORI_WIDTH, output)
% MSB_RM is the bit to lose in LSB
% ORI_WIDTH is the original data width
%2's complement system
maxdat = 2^(ORI_WIDTH - MSB_RM -1)-1;
mindat = 2^(ORI_WIDTH - MSB_RM -1)*(-1);
data_in(find(data_in > maxdat)) = maxdat;
data_in(find(data_in < mindat)) = mindat;
output = data_in;
%end of bi_satu

㈢ 下面是CIC濾波器頻率響應圖的M代碼。求大神幫解釋下,特別是那幾個函數的運用搞清楚

這段代碼是級聯積分梳狀濾波器中梳狀濾波器的部分。
[h1,f1]=freqz(ones(1,D),1,1000,fs)在matlab help中查freqz有詳細解釋及舉例。該句用於分析長度為5的FIR濾波器的頻率響應,返回值h1為頻率響應,f1為頻率軸,已經是以Hz為單位了(0~fs/2)
因此下句也就用錯了
plot(f1/(fs/2),20*log10(abs(h1))-max(20*log10(abs(h1)))應改為
plot(f1,20*log10(abs(h1))-max(20*log10(abs(h1)))
此時畫出的是幅頻圖,幅度進行了歸一化,幅度單位是dB。

㈣ CIC濾波器

CIC濾波器是無線通信的常用模塊,一般用於數字下變頻(DDC)核數字上變頻(DUC)系統。CIC濾波器結構簡單,沒有乘法器,只有加法器、積分器和寄存器,可以實現高速濾波,常用在輸入采樣率最高的第一級。

1.單級CICI濾波器

CIC濾波器包括兩個基本組成部分:積分部分和梳妝部分,如圖所示:

積分部分的積分器是單極點的IIR濾波器,並且反饋系數為1,狀態方程為:

上述的積分器也可以看做是累加器。根據Z變換,積分器的傳輸函數為:

梳妝器是一份FIR濾波器,其狀態方程為:

式中,D是設計參數,稱為微分延遲,其傳輸函數為:

那麼:單級CIC濾波器的傳遞函數為:



帶入上式,可以得到傳遞函數的幅頻響應為:

CIC濾波器的幅頻響應特性如圖所示,其中[0,2π/DM]為主瓣,其他的區間稱為旁瓣。

從幅頻響應特性可以看到,主瓣的最大值為DM(在 w=0時w=0時),旁瓣的最大值在 w=3π/DMw=3π/DM處 取得

它與主瓣電平的差值為:

根據在 θ在0~ 45°時, θ≈sinθ,可得:

可見單級CIC濾波器的旁瓣電平較大,阻帶衰減較差。為降低旁瓣電平,可以採用多級CIC濾波器級聯辦法來實現。

2.多級CICI濾波器

一個N級CIC抽取濾波器系統傳遞函數為:

在N級級聯時,阻帶衰減為單級衰減的N倍,即13.46×N(dB)。

㈤ matlab里設計CIC濾波器該用哪個函數

matlab里設計cic濾波器的函數有以下兩種:
1. fdesign.decimator
例如:設定好采樣頻率Fs, 信號帶寬Fp, 阻帶衰減As, 差分時延m及降采樣比D就可以得到cic濾波器的傳輸函數
d1 = fdesign.decimator(D,'CIC',m,Fpass,As,Fs);
Hcic = design(d1);

2. mfilt.cicdecim (fixed-point CIC decimator, mfilt是matlab里專門用來設計多速率信號處理濾波器的一套函數)

hm = mfilt.cicdecim(decimation_factor,differential_delay,NumberofSections);
decimation_factor為降采樣比,differential_delay同上為差分時延,NumberofSections為cic濾波器的節數,與第一個函數相比,這個函數沒有規定采樣濾波,通帶寬度、阻帶衰減等

㈥ CIC濾波器設計

CIC濾波器實現簡單,資源消耗少(只需要加法器),成為變采樣率系統中比較常用的濾波器,但也需要在合適的場景中使用,不然對信號質量會造成較大影響。

我們可以通過matlab的filter designer了解CIC濾波器的各種特性。通過圖1和圖2找到CIC濾波器設計窗口。

從幅頻曲線中容易得出CIC濾器器通帶平台性差,過渡帶寬,帶外抑制性能起伏較大。

帶外抑制性能可以通過增加CIC級數(Number Of Sections)來提升,但這會對通帶平坦性帶來負面影響,具體設計CIC時需要折中該參數。

通常在C語言實現CIC時,可以將該參數設計為偶數,這樣會使拖尾是一個整數,方便去掉數據首尾的無效值。更進一步,設計為2,4,8時,歸一化可以直接通過移位實現。

當我們使用CIC時,需要保證 有用信號的fmax應足夠小於fs/2/Mcic ,其中Mcic為內插倍數。這樣才能保證在有效帶寬內足夠的平坦度,一般fmax相對於直流衰減不能超過0.5dB.

所以在變速率系統中,CIC一般作為最後數字濾波器的前端(靠近模擬域),如上采樣系統中信號先經過限帶成型濾波器(低通FIR),HB濾器組,最後經過CIC到DAC速率。

下圖為8倍上采樣的圖示。

需要注意的是為了保證CIC前後信號時域采樣點平均功率的一致性,在第一級CIC濾波器中沒有做歸一化,這部分增益正好可以補償上采樣插0帶來采樣點功率的損失。後續每一級都要做歸一化,防止溢出。

clear;clc;close all;

%% load data symbols from RRC out,make sure fmax << fs/2/Mcic

load('zeroDataFilterOut.mat')  % 8x oversampling signal

symbPower = funCountPower(zeroDataFilterOut); % Power before filter

%% CIC filter for interpolate 8 times

Mcic = 8;

coefCic = ones(Mcic,1);

N = 4;      % number of CIC section

modDataZero8x = upsample(zeroDataFilterOut,Mcic);

txPower = funCountPower(modDataZero8x); % Power after zero insertion

%% filter

dataFilterTemp = conv(modDataZero8x,coefCic);  % First CIC section

for i = 1:N-1

    dataFilterTemp = conv(dataFilterTemp,coefCic)/Mcic;

end

tailLen = N*(Mcic-1)/2;

dataOut = dataFilterTemp(tailLen+1:end-tailLen);

outPower = funCountPower(dataOut);  % Power after filter

㈦ CIC抽取濾波器 FPGA實現【DSP】

CIC (Cascaded Integrated Comb filters )指級聯積分梳狀濾波器。分為兩種分別是內插和抽取;本文介紹抽取的實現。抽取就是間隔一定數量丟棄采樣點的過程,但是對於帶寬較寬的信號,直接丟棄采樣點會造成混疊。為了抑制混疊,在抽取前面需要加入低通濾波器,濾波輸出信號截止頻率應該小於 , 是原始采樣率, 是抽取倍率。CIC濾波器可以同時實現濾波和抽取,而且結構簡單。原始CIC的抽取放在最後一步,其實可以簡化。

經過簡化後結構如下:

是differential delay,可以是任何正整數,但一般取1或2。 是抽取倍率。定義級聯數為 ,代表comb級聯數或積分級聯數,它們是對稱的,圖1中 。系統函數下圖:其中

其中 時:

是歸一數字頻率, , 是真實頻率, 是采樣率。取模後畫圖:

橫軸0.5就是一半采樣率點。上圖中我們希望 ,但是不夠平坦,下降嚴重,所以一般會在CIC之後串入一個FIR補償濾波器,讓通帶更加平坦,在上圖中,最後FIR輸出的截止頻率一般設為0.04到0.08之間。

FPGA實現:

CIC濾波器由 延時器、加法器、減法器、抽取器構成,內部運算位寬: ,其中 是輸入位寬。已知 就可以確定一個CIC抽樣濾波器。

時結構圖:

圖中使用統一采樣時鍾,comb項用一個經過分頻後的使能信號控制 觸發器達到分頻效果。

verilog無法高亮,CIC的verilog描述詳見 github

以上

僅參考備忘用途

㈧ matlab里設計CIC濾波器該用哪個函數

tlab里設計cic濾波器的函數有以下兩種:
1. fdesign.decitor
例如:設定好采樣頻率Fs, 帶寬Fp, 阻帶衰減As, 差分時延m及降采樣比D就可以得到cic濾波器的傳輸函數
d1 = fdesign.decitor(D,'CIC',m,Fpass,As,Fs);
Hcic = design(d1);

2. mfilt.cicdecim (fixed-point CIC decitor, mfilt是tlab里專門用來設計多速率處理濾波器的一套函數)

hm = mfilt.cicdecim(decition_factor,differential_delay,NumberofSections);
decition_factor為降采樣比,differential_delay同上為差分時延,NumberofSections為cic濾波器的節數,與第一個函數相比,這個函數沒有規定采樣濾波,通帶寬度、阻帶衰減等
關於這個建議去硬之城官網看看哦,能快速解決問題 服務態度又好這個很多地方都做不到的。

閱讀全文

與cic濾波器程序相關的資料

熱點內容
oracleexp指定版本 瀏覽:150
李銀美韓國 瀏覽:319
u12linux 瀏覽:783
限制級視頻網 瀏覽:636
.ybci.waq ?x 瀏覽:765
騰訊文件蘋果板 瀏覽:173
外國女同電影 瀏覽:336
為什麼同一文件壓縮比原文大 瀏覽:206
北京哪裡有數控機床編程 瀏覽:135
男兒當自強版本 瀏覽:164
恐怖網站電影在線 瀏覽:207
webbrowser密碼框 瀏覽:720
大奶按摩電影 瀏覽:126
nios2uclinux文件系統 瀏覽:228
拍攝指南by製造機txt下載 瀏覽:187
中東一個小男孩的電影 瀏覽:41
最好看的機甲小說 瀏覽:495
小孩第一次進電影院英文翻譯 瀏覽:729
ios獲取項目文件路徑 瀏覽:100
色武俠小說 瀏覽:879

友情鏈接