The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design >> Analog Design >> How can I give variables as parameter to a module
https://designers-guide.org/forum/YaBB.pl?num=1319014527

Message started by aistudy on Oct 19th, 2011, 1:55am

Title: How can I give variables as parameter to a module
Post by aistudy on Oct 19th, 2011, 1:55am

Hi,

how can I give variables as parameter to a Verilog-A module?

I wrote the module Resistor in Verilog-A with parameter Noise and value of resistance.


Code:
module Resistor(p,n);
electrical p,n;
parameter real R=1.0 from [0:inf];
parameter integer Noise = 1 from [0:1];
...
endmodule


I can pass numbers direktly as parameter:


Code:
Resistor #(.R(4)) r_gate(G, g);


But I can't pass any calculated value or a value which is a parameter or variable.

I would like to pass the Variable "R_g", which will be calculated in following sample:


Code:
WF=UGW/1000;
WZ=WF/2;
Wtot=WF;
R_g=rg*WZ;


I'm becoming the following error message from Agilent ADS:
"Invalid (non-static) initialization for parameter R"

Sometimes ADS gives non error message but the result of the DC-simulation are not practicable.

How I solve this problem?

Thanks a lot!

Title: Re: How can I give variables as parameter to a module
Post by boe on Oct 19th, 2011, 3:45am

Hi Aistudy,

aistudy wrote on Oct 19th, 2011, 1:55am:
But I can't pass any calculated value or a value which is a parameter or variable.
...

Code:
WF=UGW/1000;
WZ=WF/2;
Wtot=WF;
R_g=rg*WZ;
...
Instance parameters must be constants. E.g.
Code:
localparam real rg = <val>,
   UGW = <val>,
   WF=UGW/1000,
   WZ=WF/2,
   Wtot=WF,
   R_g=rg*WZ;
Resistor #(.R(R_g)) r_gate(G, g);
should work.
If you want to change the value dynamically, you need to declare R as dynamicparam (if ADS supports this).
- B O E

Title: Re: How can I give variables as parameter to a module
Post by aistudy on Oct 19th, 2011, 5:20am

Hi,

the declaration as localparam solved my problem.

Thanks a lot.

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