From: Marq Kole <marq.kole_at_.....>
Date: Mon Dec 04 2006 - 01:50:31 PST
All,
Maybe I can answer this myself :-)
That's what we should use localparams
for, I guess. I would suggest to add that notion to the noted paragraph.
Then the example becomes:
paramset layoutres resistor;
parameter real w = 1k from (0:inf);
parameter real l = 1k from (0:inf);
parameter real dw = 0 from [0:w);
parameter real dl = 0 from [0:l);
parameter real r = 0 from [0:inf);
parameter real lr = 0;
parameter real wr = 0;
parameter real ar = 0;
localparam real leff = l - 2.0 * dl;
localparam real weff = w - 2.0
* dw;
localparam real aeff = leff*weff;
.r=r + lr/leff + wr/weff + ar/aeff;
endparamset
Cheers,
Marq
Marq Kole
Competence Leader Robust Design
Research
NXP Semiconductors
Marq Kole <marq.kole@nxp.com>
Sent by:
owner-verilog-ams@server.eda.org
04-12-2006 10:38
To
"verilog-ams" <verilog-ams@server.eda-stds.org>
cc
Subject
variables in paramsets
Classification
All,
I've been trying my hand at paramsets, but I've run across a weird passage
in the standard text (LRM 2.2, section 7.3.1, p. 138, 2nd paragraph)
that says:
"Paramset statements may assign values to variables declared in the
paramset; the values
need not be constant expressions. However, these variables shall not be
used to assign
values to the module’s parameters. Paramset variables may be used to provide
output
variables for instances that use the paramset; see Section 7.3.3."
My interpretation is: you can declare variables in the paramset statement,
but you are not allowed to use them in a dot module parameter assignment,
as that would "assign values to the module’s parameters".
This seems to exclude the use of paramset variables as for instance in
the following piece of code:
paramset layoutres resistor;
parameter real w = 1k from (0:inf);
parameter real l = 1k from (0:inf);
parameter real dw = 0 from [0:w);
parameter real dl = 0 from [0:l);
parameter real r = 0 from [0:inf);
parameter real lr = 0;
parameter real wr = 0;
parameter real ar = 0;
real leff, weff, aeff;
leff = l - 2.0 * dl;
weff = w - 2.0 * dw;
aeff = leff*weff;
.r=r + lr/leff + wr/weff + ar/aeff;
endparamset
Is this indeed what is intended by this paragraph? Of course, these variables
are essentially auxillary variables and I can write everything out witout
them, but that (1) significantly reduces readability, and (2) requires
me to rely on the compiler's ability to optimize these expressions. And
(3) for calculations that can not be written in closed form the code will
have to move to the module itself. This kind of breaks the analogy with
analog functions...
Cheers,
Marq
Marq Kole
Competence Leader Robust Design
Research
NXP Semiconductors
Received on Mon Dec 4 01:50:48 2006
This archive was generated by hypermail 2.1.8
: Mon Dec 04 2006 - 01:50:55 PST