next up previous contents index
Next: Title, Comments, Job Separation, Up: WRspice Input Format Previous: Units   Contents   Index


Variable Expansion in Input

WRspice provides a unique and very useful feature: as the circuit description is being read, any shell variable references found in the element lines or most dotcards are expanded. The reader should be aware that just about any text within the circuit description can be specified through the shell substitution mechanism.

Shell variables are tokens which begin with ``$'', that have been previously defined within WRspice. They most often appear for numeric values in the deck, and the actual value replaces the ``$'' token. These variables are evaluated as the circuit is read in, or with the reset command once the circuit is loaded. The variables must be known to the shell before the circuit is parsed, so if they are defined in the input file, the definition must occur in .exec blocks or .options lines, which are evaluated before the circuit is parsed, and not .control blocks, which are evaluated after the circuit is parsed. If the `$' is preceded with a backslash (` \ '), the shell substitution is suppressed, but the construct forms a comment delimiter so that the remainder of the line is ignored.

Another type of expansion, single-quote expansion, is also performed as input is read. This is most often used in .param lines, and is another means by which the circuit can be configured before simulating through prior WRspice operations. Any text enclosed in single quotes (') will be evaluated as an expression as the file is read (before shell substitution) and the string will be replaced by the result. Since evaluation is performed before shell substitution, the expression can not contain shell variables or other `$' references, but it can contain vectors (which must be defined before the circuit is read).


next up previous contents index
Next: Title, Comments, Job Separation, Up: WRspice Input Format Previous: Units   Contents   Index
Stephen R. Whiteley 2024-10-26