The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 8:40am
Pages: 1
Send Topic Print
LPF w/t variable cut off freqency (Read 1373 times)
sand_dolphin2
Community Member
***
Offline



Posts: 40
Japan
LPF w/t variable cut off freqency
Oct 19th, 2009, 7:31pm
 
Plz help me by some kind advice!!

I want to make LPF w/t variable cut off freq.
The select signal is comming from logical.

i want to make smart code like bellow case like verilog-HDL.

//---- from code
logic [1:0] FREQSEL;
electrical in,out;

analog
begin
   if(FREQSEL == 2'b00)
    begin
     V(out)      <+ laplace_nd( V(in), { num0 }, {den0, den1_750k} );
    end
   else if(FREQSEL == 2'b01)
    begin
     V(out)      <+ laplace_nd( V(in), { num0 }, {den0, den1_1_5M} );
    end
   else //if(FREQSEL == 2'b10 or 11 or x)
    begin
     V(out)      <+ laplace_nd( V(in), { num0 }, {den0, den1_3_0M} );
    end
end

//---- end code


I'd already know the laplace fanction can't set variable freq.
so,the compiler output Error log.
But, i want to make code simply like this for Digital designer like me Embarrassed

Plz give some advice!! Wink
See you soon
ciao Wink
Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: LPF w/t variable cut off freqency
Reply #1 - Oct 22nd, 2009, 3:23am
 
sand_dolphin2,
According to sec. 4.5.15 in  the Verilog-AMS LRM (version 2.3.1, http://www.designers-guide.org/VerilogAMS/vams231.pdf) analog operators (such as laplace_xx) are not allowed inside if/case etc. statements (unless using constant expressions). Poles and zeros may not change either (cf. sec. 4.5.14).
One possiblity is to use 3 filtered internal signals: Code:
analog
begin
   V(out750k)	<+ laplace_nd( V(in), { num0 }, {den0, den1_750k} );
   V(out1M5)	<+ laplace_nd( V(in), { num0 }, {den0, den1_1_5M} );
   V(out3M)	<+ laplace_nd( V(in), { num0 }, {den0, den1_3_0M} );
   if(FREQSEL == 2'b00)
	V(out) <+ V(out750k);
   else if(FREQSEL == 2'b01)
	V(out) <+ V(out1M5);
   else //if(FREQSEL == 2'b10 or 11 or x)
	V(out) <+ V(out3M);
end 

This requires 3 internal signal nodes, so it may not be a very efficient solution.  And when switching, the signal will usually jump.
Of course, there are other options to solve this as well. Which solution is best depends on your requirements.
BOE
Back to top
 
« Last Edit: Oct 22nd, 2009, 6:18am by boe »  
View Profile   IP Logged
sand_dolphin2
Community Member
***
Offline



Posts: 40
Japan
Re: LPF w/t variable cut off freqency
Reply #2 - Oct 22nd, 2009, 10:17pm
 
Dear BOE,

boe wrote on Oct 22nd, 2009, 3:23am:
sand_dolphin2,
According to sec. 4.5.15 in  the Verilog-AMS LRM (version 2.3.1, http://www.designers-guide.org/VerilogAMS/vams231.pdf) analog operators (such as laplace_xx) are not allowed inside if/case etc. statements (unless using constant expressions). Poles and zeros may not change either (cf. sec. 4.5.14).
One possiblity is to use 3 filtered internal signals:

This requires 3 internal signal nodes, so it may not be a very efficient solution.  And when switching, the signal will usually jump.
Of course, there are other options to solve this as well. Which solution is best depends on your requirements.
BOE


Ohps! soo cool code!! Shocked

Thank you for your kindly explain and suggestion in always.
I can solve this by your code!!!  ;)
and our design not need to take care about switching influence.

See you soon if you like me!
bye for now. ciao  :)
Back to top
 
 
View Profile   IP Logged
Paul Floyd
New Member
*
Offline



Posts: 8
France
Re: LPF w/t variable cut off freqency
Reply #3 - Oct 26th, 2009, 5:05am
 
Hi

laplace (like all analog operators), if used in conditional/loop blocks,  can only be used inside ones governed by genvars.

The arguments are "Constant expressions". This does not mean that variables are not allowed (4.5.14, see the note after table 4-20) or that there is a restriction where variables are used. It just means that the simulator must take the fist values.

So you should be able to write something like

  real den [0:1];

analog begin
    den[0] = den0;
   
    if(FREQSEL == 2'b00)
      begin
       den[1] = den1_750k;
      end
    else if(FREQSEL == 2'b01)
      begin
       den[1] = den1_1_5M;
      end
    else //if(FREQSEL == 2'b10 or 11 or x)
      begin
       den[1] = den1_3_0M;
      end

    V(out) <+ laplace_nd(V(in), {num0}, den);

Paul
Back to top
 
« Last Edit: Oct 26th, 2009, 6:47am by Paul Floyd »  
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: LPF w/t variable cut off freqency
Reply #4 - Oct 26th, 2009, 9:36am
 
Paul Floyd wrote on Oct 26th, 2009, 5:05am:
Hi

laplace (like all analog operators), if used in conditional/loop blocks,  can only be used inside ones governed by genvars.

The arguments are "Constant expressions". This does not mean that variables are not allowed (4.5.14, see the note after table 4-20) or that there is a restriction where variables are used. It just means that the simulator must take the fist values.
...
I assumed FREQSEL to be dynamic...
For your code to work FREQSEL has to be set to the desired value at the beginning of the simulation; and if this is OK, I would put that selection sequence into an initial_step statement.
BOE
Back to top
 
 
View Profile   IP Logged
Peruzzi
Community Member
***
Offline



Posts: 71

Re: LPF w/t variable cut off freqency
Reply #5 - Oct 26th, 2009, 2:41pm
 
All,

I responded to Sand Dolphin privately last week, seeking a short contract from his company, but with no luck ;-(

I did share the following hint with him and now I'm sharing it with others following this thread:

Sand Dolphin,
The problem you describe is straightforward to solve.  One solution is based upon differential equations in the form of state equations.  You must also use certain analog modeling principles which may be found in Ken Kundert's book "Designer's Guide to Verilog-AMS".

Cheers,
Robert Peruzzi
www.RPeruzzi.com


Back to top
 
 
View Profile   IP Logged
sand_dolphin2
Community Member
***
Offline



Posts: 40
Japan
Re: LPF w/t variable cut off freqency
Reply #6 - Oct 26th, 2009, 5:28pm
 
Dear BOE!!
Thank you for your cooperation in always Smiley

boe wrote on Oct 26th, 2009, 9:36am:
Paul Floyd wrote on Oct 26th, 2009, 5:05am:
Hi

laplace (like all analog operators), if used in conditional/loop blocks,  can only be used inside ones governed by genvars.

The arguments are "Constant expressions". This does not mean that variables are not allowed (4.5.14, see the note after table 4-20) or that there is a restriction where variables are used. It just means that the simulator must take the fist values.
...
I assumed FREQSEL to be dynamic...
For your code to work FREQSEL has to be set to the desired value at the beginning of the simulation; and if this is OK, I would put that selection sequence into an initial_step statement.
BOE


so, my designe should be changed FREQSEL dynamic. but there is no need to consider deeply the behavior of during changing this signals at this phase.
 
What kind of problem should i take care of the behavior of changing FREQSEL in this code ?
If you have some advice, plz let me know...

See you soon again
so,you are very high technical engineers i(we) think Shocked
chiao   Wink
Back to top
 
« Last Edit: Oct 26th, 2009, 7:18pm by sand_dolphin2 »  
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: LPF w/t variable cut off freqency
Reply #7 - Oct 29th, 2009, 10:51am
 
sand_dolphin2,
Paul Floyd's code limits you to one bandwidth per simulation run. If you need to change FREQSEL/the bandwidth during a simulation run, you can
1. use my "lazy" code from reply #1, which I created it within one or two minutes from yours (however it requires additional internal nodes as already mentioned), or
2. write your own filter model as Peruzzi suggested (requires less internal nodes so it should simulate better/faster, and also allows modeling the switching transition).

BOE
Back to top
 
 
View Profile   IP Logged
sand_dolphin2
Community Member
***
Offline



Posts: 40
Japan
Re: LPF w/t variable cut off freqency
Reply #8 - Oct 29th, 2009, 3:39pm
 
Dear BOE!!
Thank you so much for your kind.

boe wrote on Oct 29th, 2009, 10:51am:
sand_dolphin2,
Paul Floyd's code limits you to one bandwidth per simulation run. If you need to change FREQSEL/the bandwidth during a simulation run, you can
1. use my "lazy" code from reply #1, which I created it within one or two minutes from yours (however it requires additional internal nodes as already mentioned), or
2. write your own filter model as Peruzzi suggested (requires less internal nodes so it should simulate better/faster, and also allows modeling the switching transition).

BOE


i used "1" , so your #1 code. gooooooood. Wink

thanks ciao Smiley

btw how about your opinion about thread of

 AC analysis in verilog-ams
http://www.designers-guide.org/Forum/YaBB.pl?num=1237145096

i re opened this thread , and wait some comments from anybody.
if you have some advice, plz let me know.

best regards,
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.