导航:首页 > 编程语言 > 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滤波器程序相关的资料

热点内容
你那天晚上看了什么电影英文翻译 浏览:236
东方福利的电影票怎么用 浏览:739
泰国爱情片 浏览:339
日本顶级爱情理论片 浏览:925
十部顶级韩剧电影 浏览:240
1979年越南战争电影 浏览:510
含糖1v1sc荔枝 浏览:415
免费看韩国电影的网站 浏览:953
word怎么设置水印 浏览:414
qq提醒cf 浏览:883
成了电影 浏览:648
盘点大尺度床戏的电影 浏览:441
putty传文件给linux 浏览:121
有个蒲字的电影,女主和男主在酒吧相遇 浏览:233
日韩电影欲大尺推荐 浏览:48
网吧电影平台 浏览:839
重生抗日我是少帅张学铭 浏览:384
韩国电影免费在线观看大全 浏览:232
男男电影哪里可以看 浏览:919
可疑的美发店韩剧中文版介绍 浏览:157

友情链接