next up previous contents index
Next: Pre-Defined Parameters Up: .param Line Previous: .param Line   Contents   Index

Subcircuit Parameters

Parameters can also be defined in subcircuit invocation (.subckt) and call lines. When given in a .subckt line, the definition applies within that subcircuit, unless overridden. When given in a call line, the definition applies when expanding lines for that instance only.

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.

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.

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.

Parameter expansion is applied to all lines of input, with an attempt made to be smart about what tokens are expanded and which are not. For example:

.subckt tline 1 2 3 4
T1 1 2 3 4 l=l c=c len=len
.ends tline


This can be called as
xt1 1 0 2 0 l=1.5nh c=12ff len=1e-6
Which expands to
T1.xt1 1 0 2 0 l=1.5nh c=12ff len=1e-6

This illustrates that in param=value constructs, the value is parameter expanded, not the param. Thus, a device parameter name keyword will not be expanded by a user-given parameter of the same name.

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.


next up previous contents index
Next: Pre-Defined Parameters Up: .param Line Previous: .param Line   Contents   Index
Stephen R. Whiteley 2022-09-18