The loop command is used to perform a simulation analysis over a range of conditions.
loop [-c] [min1 [max1 [step1]] [min2 [max2 [step2]]] [analysis]]The loop command is used to perform a simulation analysis over a range of conditions. The command works something like a dc sweep, however the shell variables value1 and value2, which are accessible in the circuit as $value1 and $value2, are incremented, as in operating range analysis. The specified analysis is performed at each point, yielding multidimensional output vectors. If analysis is omitted, an analysis specification is expected to be found in the circuit deck.
There are several methods for introducing the variations into the circuit deck.
set value1 = foo1 value2 = foo2
loop ...
The most important example is temperature sweeping, using the temp option. A temperature sweep would look like
set value1=temp
loop -50 50 25 analysis
This will run the analysis at -50, -25, 0, 25, and 50 Celsius.
let vec[10] = 0
let checkN1 = 5 checkN2 = 6
set value = vec
loop ...
The first line creates a vector named ``vec'' of size sufficient to contain the indices. The iterated values will be placed in vec[5] and vec[6]. The circuit should reference these values, either through shell substitution (e.g., $&vec[5]) or directly as vectors.
Alternatively, a variable named ``checkN1'' can be set. If the value of this variable is an integer, that integer will be used as the index. If the variable is a name token, then the index will be supplied by a vector of the given name. The same applies to checkN2. The following example illustrates these alternatives:
let vec[10] = 0
set checkN1 = 5
let foo = 6
set checkN2 = foo
loop ...
set &vector = value
it is possible to iterate vectors with the loop command. The form above is equivalent to
let vector = value
Note, however, that the `&' character has special significance to the WRspice shell, so when this form if given on the command line the ampersand should be quoted, e.g., by preceding it with a backslash.
Thus, suppose that the circuit depends on a vector named delta. One can set up iteration using this vector as
set value1 = '&delta'
loop ...
@devname[param]
where devname is the name of a device or model in the circuit, and param is one of the parameter keywords for the device or model. These keywords can be listed with the show command.
For example, if the circuit contains a MOS device m1 one might have
set value1 = '&@m1[w]'
loop 1.0u 2.0u 0.25u analysis
This will perform the analysis while varying the m1 w (device width) parameter from 1.0 to 2.0 microns in 0.25 micron increments.
If an analysis loop is paused, for example by pressing Ctrl-C, it can be resumed by entering the loop command again. No arguments are required in this case, however if the -c option is given the old analysis is cleared, and a new analysis started if further parameters are supplied. The -c is ignored if there was no loop analysis in progress. The resume command will also resume a paused loop analysis. The reset command given with the -c option will also clear any paused loop analysis.