The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Sep 3rd, 2024, 1:21am
Pages: 1
Send Topic Print
How can I give variables as parameter to a module (Read 1562 times)
aistudy
New Member
*
Offline



Posts: 8

How can I give variables as parameter to a module
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!
Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: How can I give variables as parameter to a module
Reply #1 - 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
Back to top
 
« Last Edit: Oct 19th, 2011, 5:31am by boe »  
View Profile   IP Logged
aistudy
New Member
*
Offline



Posts: 8

Re: How can I give variables as parameter to a module
Reply #2 - Oct 19th, 2011, 5:20am
 
Hi,

the declaration as localparam solved my problem.

Thanks a lot.
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.