Spice3f5

alter

Change a device or model parameter

General form

alter device [=] value
alter device parameter [=] value
alter @device[parameter] [=] value
alter @device [=] value

Change a parameter of a device in the current circuit. The new value is used from the next analysis on: alter doesn't run anything itself. The change lasts until the circuit is loaded again or reset.

alter device value
Sets the device's principal value: the resistance of a resistor, the capacitance of a capacitor, the dc value of a source, and so on. Devices with no principal value, such as transistors, need a parameter name.
alter device parameter value
Sets the named instance parameter, for example alter m1 w = 20u. The parameters of each device are listed in the device reference, and show prints their current values.
alter @device[parameter] value
The same, written as the parameter's vector name, as used in print and in expressions. @device on its own is the principal value.

The = is optional in every form. Parameter names are not case sensitive.

The value is an expression, so it may use variables and vectors, for example alter r1 = $rvalue or alter c1 = 2*cload. It must be real.

Some parameters take a list of values, such as the sin, pulse and pwl coefficients of a source. Give these in square brackets, separated by spaces or commas:

alter @vin[sin] = [ 0 1 750 ]
alter @vin[pulse] = [0, 5, 1u, 10n, 10n, 1u, 2u]

To change a model parameter, use altermod. alter on a model's name, with a parameter, does the same, but alter on a device can't set a parameter of its model.

Examples

alter r1 2k
alter r1 = 2k
alter r1 resistance = 2k
alter @r1[resistance] = 2k
alter @r1 2k
alter vdd = 3.3
alter m1 l = 0.5u
alter @vin[sin] = [ 0.0, 1.0, 750 ]

A .control script can use alter in a loop to run a circuit with several values (from examples/alter_demo.cir):

foreach rvalue 330 1.0k 3.3k
    alter @r1[resistance] = $rvalue
    tran 0.1ms 10ms 0.0ms 0.2ms
    plot v(2)
end

.step does this for you, and collects the results of all the runs.

All commands