next up previous contents index
Next: Pre-Defined Parameters Up: Parameters and Expressions Previous: Single-Quoted Expressions   Contents   Index


.param Line

General Form:
.param name = value [name = value] ...
.param func(arg1, ...) = expression

Example:
.param p1 = 1.23 p2 = '2.5*p1'
.param myabs(a) = 'a < 0 ? -a : a'

This assigns the text value to the text token name. The name must start with a letter or underscore. If the text string name, delimited by space or one of ,)([]='" but not with `=' to the right is found in the text, it is replaced by its value. The `%' concatenation character is recognized. The concatenation character is used to separate the token from the other text: for example RES%K allows RES to be identified as a token, and if RES is `1' the substitution would yield `1K'. The name token must be surrounded by non-alphanumeric characters.

The concatenation character can be set to a different character with the var_catchar variable. If this variable is set to a string consisting of a single punctuation character, then that character becomes the concatenation character.

Substitutions occur on a second pass, so the order of definition and reference is not important (except when used in .if or .elif, described below). Substitutions are not performed in Verilog blocks, but are performed everywhere else. The .param lines always have global scope, meaning that they apply to the entire circuit, whether or not they are located within .subckt blocks.

Values can contain parameter references, i.e., nesting is accepted.

The default scoping of parameter substitution when there is more than one definition for a name is global. This means that the highest level definition has precedence in a subcircuit hierarchy. The scoping rules are identical those of HSPICE.

Warning: in releases prior to 3.2.15, the scoping rules were different, and different from HSPICE rules but closer to ``local'' mode.

The scoping rule set can be changed with the parhier option. This can be set in a .options line to one of two literal keywords: ``global'' or ``local''. The global setting is the default. When ``local'' is specified, the precedence order is bottom-up, with the lowest level definition having precedence.

A parameter defined in a subcircuit instantiation line will override a definition given in a .param line in the subcircuit body, which in turn will override a parameter definition provided in the .subckt line. This sub-precedence is not affected by the parhier setting.

It is also possible to define ``user defined'' functions using the second form above. This is similar to to the define shell function, but functions defined in this manner exist only transiently, and will override a function of the same name and argument count defined with the define command.

The scoping for function definitions follows that of normal parameters, taking into account the parhier setting.

In general, these function definitions disappear from memory after parameter expansion has been performed, however is some cases ``promoted macros'' will be created and saved with the current circuit. This occurs when a single-quoted expression references a circuit variable, and also calls a function defined with the parameters. The function cannot be evaluated and is retained for later evaluation (during analysis). For this to succeed, the referenced macros must be available as well, so these are ``promoted'' to a persistent database within the circuit data structure. It is not possible to undefine these functions, excapt by destroying or changing the current circuit. In the listing of functions provided by the define command without arguments, functions from the current circuit are listed with an asterisk in the first column.

References to parameters outside of any .subckt definition are evaluated after variable expansion. References within .subckt definitions are evaluated after variable substitution, during subcircuit expansion.

The value must be a single token, or be enclosed by single or double quotes. If double quotes are used, they are stripped when the substitution is applied. Single quotes are retained in the substitution, as single quotes have significance in delimiting an expression. Parameter substitution is performed whether or not the substitution variable in part of a single or double quoted string.

Parameters can be accessed as vectors through the syntax ``@paramname''. The value of the vector is the numerical value of the parameter-expanded value string. These vectors are read-only, i.e., parameters can not be set through vectors.



Subsections
next up previous contents index
Next: Pre-Defined Parameters Up: Parameters and Expressions Previous: Single-Quoted Expressions   Contents   Index
Stephen R. Whiteley 2012-09-24