The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Aug 15th, 2024, 11:21am
Pages: 1
Send Topic Print
decimation filter CIC, two's complement (Read 4289 times)
trond
Senior Member
****
Offline



Posts: 168
Glasgow, Scotland
decimation filter CIC, two's complement
Mar 22nd, 2007, 5:40am
 
Hello,

I wanted to implement a quick 2 second order CIC decimation filter based on the cascade of two accumulators, followed by a rate reduction by M, followed by two differentiators. The input to the decimator is the one bit output of a Sigma Delta modulator, i.e. 0,1,1,0,0,0,1......

This is was i am using:

\\INTEGRATORS
@(cross(V(clk) -0.5 , 1)) begin          //Fast clk
accum1=accum1+sd_output;
accum2=accum2+accum1;
end

\\RE-SAMPLE
@(cross(V(clkM) -0.5 , 1)) begin       //Decimated clk
x1=accum2;

\\DIFFERENTIATORS
d1=x1 - absdelay(x1, 4/Fs);
d2=d1 - absdelay(d1, 4/Fs);

Then I read out d2 and save to a file for processing in Matlab.

Now, this works fine BUT, the integrator registers will get quite large. So i wanted to use modulo arithmetic by using:

\\INTEGRATORS
@(cross(V(clk) -0.5 , 1)) begin          //Fast clk
accum1=(accum1+sd_output) % 1024;
accum2=(accum2+accum1) % 1024;
end

But there must be something wrong as the final output does not contain my signal anymore. How does one do two's complement or modulo N arithmetic in VerligA\MS???/

thanks for any tips.

Back to top
 
 
View Profile   IP Logged
trond
Senior Member
****
Offline



Posts: 168
Glasgow, Scotland
Re: decimation filter CIC, two's complement
Reply #1 - Mar 22nd, 2007, 7:01am
 
I just realized that the % operator is more like the remainder, rather than the modulo operator I am used to from Matlab. So,
mod(-3,8) = 5 BUT -3%8 = -3.
I was browsing the VerilogA LRM but could only find the % operator. Is there another command i can use to obtain the desired results/

Cheers
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: decimation filter CIC, two's complement
Reply #2 - Apr 12th, 2007, 1:27am
 
You can use the following function:

Code:
analog function real mod;
   input num,den;
   real num,den;

   mod = num<0 ? num%den+den : num%den;
endfunction 



Regards,

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
trond
Senior Member
****
Offline



Posts: 168
Glasgow, Scotland
Re: decimation filter CIC, two's complement
Reply #3 - May 3rd, 2007, 12:26am
 
Cheers Andrew. All fine now Smiley
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.