plot command uses the same syntax as in the original Berkeley verion of SPICE
Since version 2.01 plots with multiple scales can be created:
plot v1 v2 vs vscl1 v3 v4 vs vscl2 v5 v6
The above plot command would display vectors v1 and v2 against vscl1,
v3 and v4 against vscl2 and v5 and v6 against default plot scale.
In case 'vs' options are ommited, the vectors are plotted against
the default scale of the active plot.
Colors for the plot window can be set by setting colorn variables.
Example:
set color0 = r255g255b255
set background color to white
set color1 = r000g000b000
set grid and text color to black
set color2 = r000g255b000
set the first vector color to green
set color3 = r255g000b000
set the second vector color to red
plot v(1) v(2)
the result is graph with the white background and black grid; v(1) is green and v(2) is red
unset color2
unset the first vector color; the default will be used; also color3 variable will be ignored now
Default plot type can be set using the plottype variable. Available types are:
normal, point and comb.
set plottype=normal
Default line width can be 0, 1 or 2. Set it with:
set linewidth=1
Default plot window width and height in pixels:
set plotwinwidth=360
set plotwinheight=360
If you want to show the info frame (coordinates) in plot windows use:
set plotwininfo
Default vector identification mode is now manual identification. Manual identification
can be initiated by right-clicking in the plot window. To make automatic identification
the default (as in version 2.0 and below), enter:
set plotautoident
Note that all of these settings are valid only for plot windows opened after these
setting have been chosen by the appropriate set/unset commands.
Thespec command written by Anthony Parker, Macquarie University, was added.
DC analysis syntax is now:
dc parameter1 start1 stop1 [dec|oct|lin] step1
[parameter2 start2 stop2 [dec|oct|lin] step2]
Parameter can be specified in the following manner:
Instance parameters:
@inst[param] ... example is '@r1[resistance]'
@inst ... '@r1' would mean r1 default
parameter (resistance)
inst ... 'r1' would mean r1 resistance, 'v1' would
mean v1 dc voltage
@inst[param][i] ... i-th component of vector parameter param of
instance inst
Model parameters:
@@mod[param] ... example is '@rm[tc1]' ... tc1 parameter for
model rm
@@mod ... '@rm' would mean default parameter for model
rm (in case rm is a resistance model this
would be rsh)
@@mod[param][i] ... i-th component of vector parameter param of
model mod
Temperatures:
@@@temp ... circuit global temperature in degrees celsius
@@@tnom ... global nominal temperature in degrees celsius for
instance and model parameter recalculation
@@@tempk ... circuit global temperature in Kelvins
@@@tnomk ... global nominal temperature in Kelvins for instance
and model parameter recalculation
In case dec/oct/lin is ommited, step is the linear step size. In case dec/oct is used, step is the number of points
per decade/octave. In case lin is used, step is the number of points in range between start and stop
(for 10, 11 points are evaluated including start and stop point).
Examples:
dc @r1[resistance] 1m 1meg dec 10 ... sweep resistance for
instance r1 from 1m to
1meg, 10 points per decade
dc @@rm[rsh] 50 90 lin 100 ... sweep rsh for model rm from
50 to 90 with 100
equidistant steps
dc @@@temp -20 50 0.01 ... sweep global temperature
from -20 to 50 (degrees
celsius), step is 0.01
Improved let syntax. LHS can now be specified using the following syntax:
let plot.vector[index1]...[indexn] = expression
Examples:
let dc2.a[3]=5 ... vector a in plot dc2, assign 5 to 4th
element
let dc2.a=vector(5) ... assign a vector with elements 0..4 to
vector a in plot dc2
An arbitrary expression can be used for index.
If plot name is ommited, the referenced vector is created or modified in current plot.
Instance/model parameters can be altered using the let command:
let @r1[resistance]=5000 ... set parameter resistance for
instance r1 to 5000
let @@rm[tc1]=0.05 ... set model parameter tc1 for model rm
to 0.05
The syntax for parameters is the same as with the DC analysis. @@@temp and @@@tnom are not supported yet.
Index into a vector parameter can be an arbitrary expression:
let @v1[coeffs][2*1]=0.01 ... set 3rd element of parameter coeffs
for instance v1 to 0.01.
Extended syntax for vectors in expressions:
let c=dc1.a*2 ... take vector a in plot dc1 and mutiply it by
2, assign the result to vector c in current
plot
let c=dc1.a[2]*2 ... vector a in plot dc1, take 3rd element,
mutiply by 2 and assign the result to vector
vector c in current plot
let c=a[2][3]*2 ... a is a 2D vector, indices into this vector
are 2 and 3
An exception are vectors with names staring with @ generated by the use of the save command:
let c=@r1[p][3] ... Wrong! This won't take the 4th element from
vector @r1[p].
let c=(@r1[p])[3] ... This is correct. Use braces.
Note that you don't have to use () when assigning into a vector element for such a vector:
let @r1[p][3]=0.05
Of course such vectors can be referenced in other plots too:
let a=dc1.@r1[p]
Note again the use of braces in the above example when accessing a vector element:
let a=(dc1.@r1[p])[3]
Instance/model parameters can be used in expressions. Some examples:
let c=@r1[resistance]
let c=@@rm[tc1]
let c=@v1[coeffs] ... assign coeffs vector parameter value
of instance v1 to c
let c=@v1[coeffs][2*1] ... assign coeffs vector parameter's 3rd
element (from instance v1) to vector c
To construct a vector from its components
let a=(10;20;30)
let b=(12;22;32;a;a*2;90)
b would now be a vector with the following elements: 12 22 32 10 20 30 20 40 60 90.
Display simulator information (analyses, devices, (user defined) nodes):
siminfo [analyses] [devices] [nodes] [all]
Code models are marked with '++'
Load code models and user defined nodes from a .cm file:
cmload filename.cm
New command nameplot renames the current plot. The following command
sequence performs an op analysis and names the plot with the results firstop:
op
nameplot firstop
Keywords next and previous when using setplot set the current plot
to the next/previous plot. Examples:
setplot next
setplot previous
Functions min() and max() return the smallest/largest component of
a vector. For complex vectors the smallest/largest component is determined by comparing the
absolute value of the components.
Function sum() returns the sum of the components of a vector. Examples:
* Real vector
let a=(1;2;3;4)
* Complex vector
let b=((0,-1);(2,1);(0,0))
* min() example
* c <- 1
let c=min(a)
* c <- (0,0)
let c=min(b)
* max() example
* c <- 4
let c=max(a)
* c <- (2,1)
let c=max(b)
* sum() example
* c <- 10
let c=sum(a)
* c <- (2,0)
let c=sum(b)
Variable badcktfree forces the simulator to release a circuit if
any errors are found in the circuit. It is usually set in the spinit file.
Variable badcktstop prevents the simulator from running the script
in the .control block if any errors are found in the circuit. It is usually set in
the spinit file.
Test netlist
* Include section1 from lib1.lib
.lib 'lib1.lib' section1
* Include section2 from lib1.lib
.lib 'lib1.lib' section2
.end
Let now allows vector length to be modified. Example:
let a=(1;2;3)
let a=(1;2)
let a=(2;3;4;5)
* a now contains (2;3;4;5)
To create a plot and name it use setplot new and then nameplot. The first
vector you create in that plot becomes the default scale.
setplot new
nameplot plot10
let a=(2;4;5;9)
let b=(1;2;3;4)
* a is the default scale for plot10
Vector operator [|low,high] selects a range from a vector that corresponds to the
range low <= default_scale_value <= high on the default scale. Example:
setplot new
nameplot plot10
let a=(2;4;5;9)
let b=(1;2;3;4)
* Select values for b for which the scale value is
* between 2.5 and 5.5
let x1=b[|2.5,5.5]
* Select values for b for which the scale value is
* between 4 and 5
let x2=b[|4,5]
* Both x1 and x2 contain now (2;3)
Graph tagging. A graph is automatically tagged as plotn if no tag is
specified (iplotn for the plots generated by iplot commands). n is automatically set by Nutmeg
and is unique for a plot in a Spice session. The plot tag is displayed in the title bar of the
graph as tag: graph_name
To create and tag a graph, use plot create tag vectors:
* Create a graph, tag it plota and display
* vectors a and b vs default scale
plot create plota a b
In case a graph with the given tag exists, the new graph is tagged with it. This makes it
impossible to refer to the older graph.
To append some more data to a graph, use plot append tag vectors:
* Appends vector c to graph tagged plota
plot append plota c
In case there are scaling and graph type commands in the plot append clause, they are applied
to the graph. If the graph doesn't exist (the user has closed it), the graph is recreated and
tagged with the given tag.
A graph can be closed with plot destroy tag:
* Close graph plota
plot destroy plota
Nutmeg function floor() returns an integer vector with largest
components not exceeding the components of the operand. ceil() returns an integer vector
with smallest components not below components of the operand. round() rounds the vector
components to the nearest integer. In case the operand is complex, these functions operate
on real and imaginary parts independently.
Vector operator [%index] returns an element with the corresponding
index from the vector if the index is integer. If the index is real, linear interpolation is
used to calculate the return value. Example:
setplot new
nameplot plot10
let a=(2;4;5;9)
let b=(1;2;3;4)
* x1 becomes 4
let x1=a[%1]
* x2 becomes 2.5 (in the middle between components
* b[1] (2) and b[2] (3))
let x2=b[%1.5]
Nutmeg command cursor manipulates cursors. A cursor is a vector of length
1 (vector component) that represents a real index into a vector. To initialize a cursor, create
a vector:
* Creates two cursors, cleft and cright
let cleft=0
let cright=0
To move a cursor to the left edge of a vector, use:
* Moves cleft to the left edge and cright to the right edge
* of vector 'time'
cursor cleft left time
cursor cright right time
To move a cursor to a certain level on a vector, use:
* Moves cleft towards right until it reaches
* level 0.5 on vector pulse
cursor cleft right pulse 0.5
* Moves cright towards left until it reaches
* level 0.5 on vector pulse
cursor cright left pulse 0.5
Cursors are real indices into vectors. Since time is the scale for vector pulse, the
time difference between cleft and cright is the pulse width (if vector pulse contains only one
pulse with bottom level 0 and top level 1). Pulse width can be obtained by:
* See explanation of the [%index] vector operator
let pulsewidth=time[%cright]-time[%cleft]
To put it in short: the syntax for the cursor command is:
* Initialize a cursor
cursor vec_el left|right
* Move a cursor
cursor vec_el left|right vector_expression level_expression
The cursor position is stored in vec_el (either a real vector of length 1 or a real vector element
of the form vector_name[element_index]).
The following example measures the rise time of a signal named pulse using time for scale:
* Create scalar c1 and c2 (cursors)
let c1=0
let c2=0
* Get the bottom and the top level of the pulse
let bottom=min(pulse)
let top=max(pulse)
* Move c1 and c2 to the left edge of vector pulse
cursor c1 left pulse
cursor c2 left pulse
* Move c1 to 10% level between bottom and top
cursor c1 right pulse bottom+0.1*(top-bottom)
* Move c2 to 90% level between bottom and top
cursor c2 right pulse bottom+0.9*(top-bottom)
* Calculate difference between c1 and c2 using time for scale
let trise=time[%c2]-time[%c1]
* Display result
echo Rise time $&trise
Transient waveforms for independent voltage and current sources can be changed. For the purpouse
of the explanation consider the following netlist:
Transient source netlist
v1 1 0 dc 0 pulse 0 1V 1ms 1us 1us 2ms 4ms
r1 1 0 1
To change the pulse width for v1 from 2ms to 3ms, type:
let @v1[coeffs][5]=3m
* This would also do the trick. Note that the following
* assignment changes the type of the source to PULSE no matter
* what the current type is whereas the previous assignment (using
* the coeffs parameter) changes only the 6th parameter to 3m no
* matter what type of transient source is currently set for v1.
let @v1[pulse][5]=3m
To change the transient waveform for v1 from pulse to sin with parameters 0 1 1kHz, type:
let @v1[sine][5]=(0;1;1k)
* or
let @v1[sin][5]=(0;1;1k)
The same goes for the independent current sources.
First iteration voltages for finding dc or initial transient solution can be set by nodeset command. Similarly the initial conditions for transient analysis can be set by ic command. Both commands have the same syntax:
nodeset [plot_name |
v(node_name_1) = [voltage_1] [v(node_name_2) = [voltage_2]
[v(node_name_3) = [voltage_3] ... ]]] and
ic [plot_name |
v(node_name_1) = [voltage_1] [v(node_name_2) = [voltage_2]
[v(node_name_3) = [voltage_3] ... ]]] Examples:
Without any arguments commands nodeset and ic list defined nodesets or initial conditions, respectively.
nodeset
Nodesets:
v(1) = 1.000000e+001
v(3:x1) = 5.000000e-001or
ic
Initial conditions:
v(2) = 3.000000e+000
v(6:x1) = 1.000000e-001If one wants to delete nodeset for node 1 (or initial condition for node 6:x1), and at the same time set additional nodeset for node 4 to 3V (or initial condition for node 7:x2 to 2V), then one has to issue:
nodeset v(1)= v(4)=3Vor
ic v(6:x1)= v(7:x2)=2VAll nodeset voltages (or initial conditions) can be set to an arbitrary analysis results. Commands:
nodeset op1and
ic tran3set all nodeset voltages to values of vectors in op1 plot (results of operating point analysis) and all initial conditions to final values of vectors in tran3 plot (results of transient analysis).