The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> Passing variables to laplace_nd
https://designers-guide.org/forum/YaBB.pl?num=1172448525

Message started by Saran on Feb 25th, 2007, 4:08pm

Title: Passing variables to laplace_nd
Post by Saran on Feb 25th, 2007, 4:08pm

Hey, I have a quick question and I appreciate if somebody can guide me in the right direction. :)

What is the clean way of having a variable in laplace_nd function. For instance, here I m modeling a baseband filter and I have to model this for different bandwidths. My filter has four stages that have been defined by their transfer functions. For simplicity I m including just the first stage which is a simple single pole.

vout = laplace_nd(gain_in_db * V(input), [2 * pi * nominal_freq * SCALE], [2 * pi * nominal_freq * SCALE, 1.0]);

This is the laplace filter definition for the first stage TIA. Normally, if there was only one bandwidth I was modeling, the SCALE variable wont be there (default = 1). The scale variable is defined as

case(MODE)

 freq1: SCALE = x;
 freq2: SCALE = y;
etc etc
endcase

The problem is that when I have this declaration, spectre gives an error saying that args #2 and #3 must be an array variable or a const array expression.

I was expecting spectre not to complain because the statement seemed logical. Obviously, there must have been some decisions made that wont allow me to declare variables in laplace_nd. My question is, if I want to have a variable in the laplace filter like I listed above, how can I cleanly do it?

Thanks,
Saran

Title: Re: Passing variables to laplace_nd
Post by zhong on Feb 25th, 2007, 11:43pm

Laplace fuction in spectre requires constant coeffcients .
You can use your original S-domain ploynomial function and directly convert it to integral form in Time domain
For example :
                             
 Vout                                  Ks/Wo
 -----        =             --------------------------
   Vin                     1+Ks/Wo + s^2/Wo^2
 

Converte to
  Vout = idt(Wo*(K*(Vin-Vout) -idt(WoVout)))

Time domain idt form allows you to have variable ..

Zhong

Title: Re: Passing variables to laplace_nd
Post by Geoffrey_Coram on Feb 26th, 2007, 5:21am


zhong wrote on Feb 25th, 2007, 11:43pm:
Laplace fuction in spectre requires constant coeffcients .


Laplace functions in Verilog-A, per the LRM, require constant coefficients.

You might get away with something like:
parameter integer mode = 1;
parameter real zero = (mode==1) ? x*`M_TWOPI : y * `M_TWO_PI;

because parameters are "constants" in Verilog.

Title: Re: Passing variables to laplace_nd
Post by Saran on Feb 26th, 2007, 7:13am

Thanks zhong and Geoffrey.

Geoffrey, I think if the mode was a constant and known well in advance, your solution might work. However, the mode is determined when the chip is powered up by some control bits and hence it will be incorrect to assume it to be constant.

Either way, I will try out your solutions and let you know. Thanks for the help! :)

Title: Re: Passing variables to laplace_nd
Post by Saran on Mar 2nd, 2007, 9:13am

Hey Guys, I have found out a brute or hack way to have variables in lalpace_nd, or for that matter in Verilog-AMS file. A parameter can be declared and the laplace_nd function will take the parameter as its argument..Everything is fine, spectre does not complain, but the problem is to now control the parameter value.

What we can do is, we can override the parameter by defining a formula for it using variables that will be defined in analog artist window. For instance, if I want to change scale, I would go to my top level schematic and press Q (properties of the block or instance) and define the scale value to a formula depending on some variables defined within analog artist. This will let us use parameters as variables in our simulation.

Saran

Title: Re: Passing variables to laplace_nd
Post by Geoffrey_Coram on Mar 2nd, 2007, 9:34am

Saran -
I think you missed a detail of my suggestion ... The "mode" could be a parameter set by a user property (Q) of an instance in the schematic.

In that way, I don't see how your "hack" is different from my suggestion, since both rely on setting something in schematic that is then fixed for the simulation.

If you have a limited number of possible scale factors, I have an idea for something that might work for a dynamic setting:

vout_s1 = laplace_nd(gain_in_db * V(input), [2 * pi * nominal_freq * x],  [2 * pi * nominal_freq * x, 1.0]);

vout_s2 = laplace_nd(gain_in_db * V(input), [2 * pi * nominal_freq * y],  [2 * pi * nominal_freq * y, 1.0]);

vout_s3 = laplace_nd(gain_in_db * V(input), [2 * pi * nominal_freq * z],  [2 * pi * nominal_freq * z, 1.0]);

case (MODE):
 freq1: vout = vout_s1;
 freq2: vout = vout_s2;
 freq3: vout = vout_s3;

etc.

Now, the laplace arguments are constant, but the actual output is selected amongst the different transfer functions.  For a few single-pole responses, this probably won't be a significant simulation overhead.

Title: Re: Passing variables to laplace_nd
Post by Saran on Mar 6th, 2007, 6:30am

Geoffrey, I read your post one more time...Yes, you are right! I missed the details. Point taken :). Thanks for the help.

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