The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> LPF w/t variable cut off freqency
https://designers-guide.org/forum/YaBB.pl?num=1256005903

Message started by sand_dolphin2 on Oct 19th, 2009, 7:31pm

Title: LPF w/t variable cut off freqency
Post by sand_dolphin2 on 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 :-[

Plz give some advice!! ;)
See you soon
ciao ;)

Title: Re: LPF w/t variable cut off freqency
Post by boe 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:
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

Title: Re: LPF w/t variable cut off freqency
Post by sand_dolphin2 on 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!! :o

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  :)

Title: Re: LPF w/t variable cut off freqency
Post by Paul Floyd 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.

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

Title: Re: LPF w/t variable cut off freqency
Post by boe 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

Title: Re: LPF w/t variable cut off freqency
Post by Peruzzi on 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



Title: Re: LPF w/t variable cut off freqency
Post by sand_dolphin2 on Oct 26th, 2009, 5:28pm

Dear BOE!!
Thank you for your cooperation in always :)


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 :o
chiao   ;)

Title: Re: LPF w/t variable cut off freqency
Post by boe 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

Title: Re: LPF w/t variable cut off freqency
Post by sand_dolphin2 on 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. ;)

thanks ciao :)

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,

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.