next up previous contents index
Next: Subcircuit/Model Cache Up: Subcircuits Previous: .ends Line   Contents   Index


Subcircuit Calls

General Form:
xname n1 [n2 n3 ...] subnam [param1=val1 param2=val2 ...]
Example:
x1 2 4 17 3 1 multi

Subcircuits are used in WRspice by specifying pseudo-elements beginning with the letter `x' or `X', followed by the circuit nodes to be used in expanding the subcircuit.

When a circuit is parsed, all devices and local nodes in subcircuits are renamed as

devicetype[sep]subcktname[sep]devicename,
where [sep] is a separation character. In SPICE3 and WRspice prior to release 3.2.4, this was the colon (`:') character. However, this choice can lead to conflicts and parser trouble due to the use of the colon in the ternary conditional operator a?b:c. In release 3.2.4, the separation character was changed to the underscore (`_').

The character employed can be set from the shell with the shell variable subc_catchar. If this variable is set to a string consisting of a single punctuation character, then this character becomes the [sep] character.

Nested subcircuit instances will have multiple [sep]-separated qualifiers.

The names and default values of the params are specified in the .subckt line. During subcircuit expansion, the param tokens are replaced by their corresponding value tokens in the text. If a list of params is given in the subcircuit instantiation line, those values will supersede the defaults in that subcircuit instance, and parameters set in .param lines.

Example:
.subckt resistor 1 2 resis=1k
r1 1 2 resis
.ends

x1 3 4 resistor resis = 500
x2 5 6 resistor
x3 7 8 resistor resis=2k


next up previous contents index
Next: Subcircuit/Model Cache Up: Subcircuits Previous: .ends Line   Contents   Index
Stephen R. Whiteley 2024-10-26