FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-27-2008, 03:39 AM
[email protected]
Guest
 
Posts: n/a
Default 5 Stages CIC Filter Matlab Simulation Problem

I implemented the matlab simulation model according to hardware
architecture.The impulse response is ok when the impulse length is
short.But when I increase the length of impulse stimulus, I found
increasing spurs. I don't know whether this is caused by the
instability of the filter or some other reasons. Attached is the
matlab code,and at the end of code I added the matlab internal
function mfilt.cicdecim for comparison.


%Filter Stimulus
%data_in =sin((1:2^15)*pi/2^10);
data_in =[1 zeros(1,4*6000-1)];

%Filter Parameters
R= 4;%decimation factor
M=1;%differential delay
N=5;%cascaded numbers of section

%Integrator Section Registers Initialization
intg_reg1(1) = data_in(1);
intg_reg1_d(1) =0;
intg_reg2(1) = 0;
intg_reg2_d(1) =0;
intg_reg3(1) = 0;
intg_reg3_d(1) =0;
intg_reg4(1) = 0;
intg_reg4_d(1) =0;
intg_reg5(1) = 0;
intg_reg5_d(1) =0;



for i=2:length(data_in)

intg_reg1_d(i) = intg_reg1(i-1);
intg_reg1(i) = intg_reg1_d(i) + data_in(i);

intg_reg2_d(i) = intg_reg2(i-1);
intg_reg2(i) = intg_reg2_d(i) + intg_reg1_d(i);

intg_reg3_d(i) = intg_reg3(i-1);
intg_reg3(i) = intg_reg3_d(i) + intg_reg2_d(i);

intg_reg4_d(i) = intg_reg4(i-1);
intg_reg4(i) = intg_reg4_d(i) + intg_reg3_d(i);

intg_reg5_d(i) = intg_reg5(i-1);
intg_reg5(i) = intg_reg5_d(i) + intg_reg4_d(i);

end

% Decimation by R

deci_data=intg_reg5_d(R:R:end);

%Comb Section Registers Initialization
diff_reg1(1) = deci_data(1);
diff_reg1_d(1) = 0;
diff_reg2(1) = 0;
diff_reg2_d(1) =0;
diff_reg3(1) = 0;
diff_reg3_d(1) = 0;
diff_reg4(1) = 0;
diff_reg4_d(1) = 0;
diff_reg5(1) = 0;
diff_reg5_d(1) = 0;
diff_reg6(1) = 0;

for ii=2:length(deci_data)

diff_reg1(ii) = deci_data(ii);
diff_reg1_d(ii) = diff_reg1(ii-1);

diff_reg2(ii) = diff_reg1(ii)-diff_reg1_d(ii);
diff_reg2_d(ii) = diff_reg2(ii-1);

diff_reg3(ii) = diff_reg2(ii)-diff_reg2_d(ii);
diff_reg3_d(ii) = diff_reg3(ii-1);

diff_reg4(ii) = diff_reg3(ii)-diff_reg3_d(ii);
diff_reg4_d(ii) = diff_reg4(ii-1);

diff_reg5(ii) = diff_reg4(ii)-diff_reg4_d(ii);
diff_reg5_d(ii) = diff_reg5(ii-1);

diff_reg6(ii) = diff_reg5(ii)-diff_reg5_d(ii);
end
data_out = diff_reg6;

data_in =[1 zeros(1,4*10000-1)];

hm=mfilt.cicdecim(4,1,5);
cic_ir=double(filter(hm,data_in));
Reply With Quote
  #2 (permalink)  
Old 06-27-2008, 10:57 AM
Tony
Guest
 
Posts: n/a
Default Re: 5 Stages CIC Filter Matlab Simulation Problem

On Jun 27, 9:39*am, tonyjian...@hotmail.com wrote:
> I implemented the matlab simulation model according to hardware
> architecture.The impulse response is ok when the impulse length is
> short.But when I increase the length of impulse stimulus, I found
> increasing spurs. I don't know whether this is caused by the
> instability of the filter or some other reasons. Attached is the
> matlab code,and at the end of code I added the matlab internal
> function mfilt.cicdecim for comparison.
>
> %Filter Stimulus
> %data_in =sin((1:2^15)*pi/2^10);
> data_in =[1 zeros(1,4*6000-1)];
>
> %Filter Parameters
> R= 4;%decimation factor
> M=1;%differential delay
> N=5;%cascaded numbers of section
>
> %Integrator Section Registers Initialization
> intg_reg1(1) = data_in(1);
> intg_reg1_d(1) =0;
> intg_reg2(1) = 0;
> intg_reg2_d(1) =0;
> intg_reg3(1) = 0;
> intg_reg3_d(1) =0;
> intg_reg4(1) = 0;
> intg_reg4_d(1) =0;
> intg_reg5(1) = 0;
> intg_reg5_d(1) =0;
>
> for i=2:length(data_in)
>
> * * intg_reg1_d(i) = intg_reg1(i-1);
> * * intg_reg1(i) = intg_reg1_d(i) + data_in(i);
>
> * * intg_reg2_d(i) = intg_reg2(i-1);
> * * intg_reg2(i) = intg_reg2_d(i) + intg_reg1_d(i);
>
> * * intg_reg3_d(i) = intg_reg3(i-1);
> * * intg_reg3(i) = intg_reg3_d(i) + intg_reg2_d(i);
>
> * * intg_reg4_d(i) = intg_reg4(i-1);
> * * intg_reg4(i) = intg_reg4_d(i) + intg_reg3_d(i);
>
> * * intg_reg5_d(i) = intg_reg5(i-1);
> * * intg_reg5(i) = intg_reg5_d(i) + intg_reg4_d(i);
>
> end
>
> % Decimation by R
>
> deci_data=intg_reg5_d(R:R:end);
>
> %Comb Section Registers Initialization
> diff_reg1(1) = deci_data(1);
> diff_reg1_d(1) = 0;
> diff_reg2(1) = 0;
> diff_reg2_d(1) =0;
> diff_reg3(1) = 0;
> diff_reg3_d(1) = 0;
> diff_reg4(1) = 0;
> diff_reg4_d(1) = 0;
> diff_reg5(1) = 0;
> diff_reg5_d(1) = 0;
> diff_reg6(1) = 0;
>
> for ii=2:length(deci_data)
>
> * * diff_reg1(ii) = deci_data(ii);
> * * diff_reg1_d(ii) = diff_reg1(ii-1);
>
> * * diff_reg2(ii) = diff_reg1(ii)-diff_reg1_d(ii);
> * * diff_reg2_d(ii) = diff_reg2(ii-1);
>
> * * diff_reg3(ii) = diff_reg2(ii)-diff_reg2_d(ii);
> * * diff_reg3_d(ii) = diff_reg3(ii-1);
>
> * * diff_reg4(ii) = diff_reg3(ii)-diff_reg3_d(ii);
> * * diff_reg4_d(ii) = diff_reg4(ii-1);
>
> * * diff_reg5(ii) = diff_reg4(ii)-diff_reg4_d(ii);
> * * diff_reg5_d(ii) = diff_reg5(ii-1);
>
> * * diff_reg6(ii) = diff_reg5(ii)-diff_reg5_d(ii);
> end
> data_out = diff_reg6;
>
> data_in =[1 zeros(1,4*10000-1)];
>
> hm=mfilt.cicdecim(4,1,5);
> cic_ir=double(filter(hm,data_in));


I got it! In fact double type in matlab is represented with
54(including 1 sign bit) ,so the so-call floating point simulation is
fixed-point theoritically. Thus overflow is inevitable with the
increase of integration length."Wrap-around" is needed according to
Hogenauer's paper in order to avoid overflow error.
Reply With Quote
  #3 (permalink)  
Old 06-04-2009, 12:21 PM
Junior Member
 
Join Date: Jun 2009
Posts: 1
Default

Hi,

I found this thread while doing some matlab simulation
on CIC filters and have a question to your matlab comb section:
Is the comb register initialisation part correct?
If I'm looking at the loop after the initialisation I would
expect that the register initialisation should be for
all X=1..6 diff_regX(1)= deci_data(1);

My implementation is different and takes only two length 5 vectors
for the delay taps. I took your implementation and compared the
results and they differ unless I do modify your initialisation part
as above.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with post-route simulation / timing simulation Andreas Ehliar FPGA 4 12-01-2008 06:51 AM
DS-CDMA simulation using Matlab BULDO DSP 1 04-18-2008 01:20 AM
FIR filter problem in the MIMO simulation cellarway DSP 1 05-24-2007 09:18 PM
Problem of SOS matrix to Transfer Function in IIR Filter Design using Matlab X.Y. DSP 3 01-05-2007 03:12 PM
Simulation of DTFT in MATLAB krishna_sun82 DSP 7 04-07-2006 09:00 AM


All times are GMT +1. The time now is 03:25 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved