| Physics and Astronomy |
|
| Physics Home | Study here | Our Teaching | Our Research | Our Centres | News | Work here | EMPS |
Back to top
SPICE 3 User's Manual - Section 5
5 INTERACTIVE INTERPRETERSpice3 consists of a simulator and a front-end for data analysis and plotting. The front-end may be run as a separate "stand-alone" program under the name Nutmeg. Nutmeg will read in the "raw" data output file created by Spice -r or with the write command in an interactive Spice3 session. Nutmeg or interactive Spice3 can plot data from a simulation on a graphics terminal or a workstation display. Most of the commands available in the interactive Spice3 front end are available in nutmeg; where this is not the case, Spice-only commands have been marked with an asterisk ("*"). Note that the raw output file is different from the data that Spice2 writes to the standard output, which may also be produced by Spice3 with the "-b" command line option. Spice and Nutmeg use the X Window System for plotting if they find the environment variable DISPLAY. Otherwise, a graphics-terminal independent interface (MFB) is used. If you are using X on a workstation, the DISPLAY variable should already be set; if you want to display graphics on a system different from the one you are running Spice3 or Nutmeg on, DISPLAY should be of the form "machine:0.0". See the appropriate documentation on the X Window System for more details. Command Synopsis
Options are:
Further arguments to Spice are taken to be Spice3 input files, which are read and saved (if running in batch mode then they are run immediately). Spice3 accepts most Spice2 input file, and output ascii plots, fourier analyses, and node printouts as specified in .PLOT, .FOUR, and .PRINT cards. If an out parameter is given on a .WIDTH card, the effect is the same as set width = .... Since Spice3 ascii plots do not use multiple ranges, however, if vectors together on a .PLOT card have different ranges they are not provide as much information as they would in Spice2. The output of Spice3 is also much less verbose than Spice2, in that the only data printed is that requested by the above cards. For Nutmeg, further arguments are taken to be data files in binary or ascii format (see sconvert(1)) which are loaded into Nutmeg. If the file is in binary format, it may be only partially completed (useful for examining Spice2 output before the simulation is finished). One file may contain any number of data sets from different analyses. 5.1 EXPRESSIONS, FUNCTIONS, AND CONSTANTSSpice and Nutmeg data is in the form of vectors: time, voltage, etc. Each vector has a type, and vectors can be operated on and combined in algebraic ways consistent with their types. Vectors are normally created when a data file is read in (see the load command below), and when the initial datafile is loaded. They can also be created with the let command. An expression is an algebraic formula involving vectors and scalars (a scalar is a vector of length 1) and the following operations: + - * / ^ % % is the modulo operator, and the comma operator has two meanings: if it is present in the argument list of a user-definable function, it serves to separate the arguments. Otherwise, the term x,y is synonymous with x+j(y). Also available are the logical operations & (and), | (or), ! (not), and the relational operations <, >, >=, <=, =, and <> (not equal). If used in an algebraic expression they work like they would in C, producing values of 0 or 1. The relational operators have the following synonyms:
These are useful when < and > might be confused with IO redirection (which is almost always). The following functions are available:
A vector may be either the name of a vector already defined or a floating-point number (a scalar). A number may be written in any format acceptable to Spice, such as 14.6Meg or -1.231e-4. Note that you can either use scientific notation or one of the abbreviations like MEG or G, but not both. As with Spice, a number may have trailing alphabetic characters after it. The notation expr[num] denotes the num'th element of expr. For multi-dimensional vectors, a vector of one less dimension is returned. Also for multi-dimensional vectors, the notation expr[m][n] will return the n'th element of the m'th subvector. To get a subrange of a vector, use the form expr[lower,upper]. [Note: The parser is not very sophisticated so it may sometimes be necessary to delimit element names with spaces, e.g. 'foo[ bar ]'. CDHW.] The notation vector[[lower,upper]] denotes the values in vector corresponding to the range from lower to upper in the scale, so that v(1)[[10, 20]] gives all the values of v(1) for which the TIME value is between 10 and 20. If there is one argument it picks out the values which have that scale value. Multi-dimensionality is ignored here; the result is a 1-dimensional vector. To reference vectors in a plot that is not the current plot (see the setplot command, below), the notation plotname.vecname can be used. Either a plotname or a vector name may be replaced by the wildcard all. If the plotname is all, matching vectors from all plots are specified, and if the vector name is all, all vectors in the specified plots are referenced. Note that you may not use binary operations on expressions involving wildcards - it is not obvious what all + all should denote, for instance. Thus some (contrived) examples of expressions are:
cos(TIME) + db(v(3))
sin(cos(log([1 2 3 4 5 6 7 8 9 10])))
TIME * rnd(v(9)) - 15 * cos(vin#branch) ^ [7.9e5 8]
not ((ac3.FREQ[32] & tran1.TIME[10]) gt 3)
[Note: The Berkeley 3f4/5 release code does not correctly parse vectors like [ 1 2 3 ], so the above examples only work in patched distributions. The compose command can be used as a workround in unpatched versions. Conflicts within the standard Spice syntax makes specifying vectors with [] ambiguous so some developers have used other methods. For example the MacSpice defines a semicolon operator to facilitate construction of vectors and n-dimensional matrices. e.g. the commands:
let foo = ((11;12);(21;22)) creates a 2x2 matrix
let bar = (foo;(31;32)) creates a 3x2 matrix
let baz = (1;(3,4);5) creates a complex vector with 3 elements
The ()'s protect the semicolon and prevent it being treated as a command separator. CDHW.] Vector names in Spice may have a name such as @name[param], where name is either the name of a device instance or model. This denotes the value of the param parameter of the device or model. See Appendix B for details of what parameters are available. The value is a vector of length 1. This function is also available with the show command, and is available with variables for convenience for command scripts. There are a number of pre-defined constants in Nutmeg. They are:
These are all in MKS units. If you have another variable with a name that conflicts with one of these then it takes precedence. 5.2 COMMAND INTERPRETATIONIf a word is typed as a command, and there is no
built-in command with that name, the directories in the
sourcepath list are searched in order for the file. If it
is found, it is read in as a command file (as if it were
sourced). Before it is read, however, the variables Note that for the script to work with Spice3, it must begin with a blank line (or whatever else, since it is thrown away) and then a line with .CONTROL on it. This is an unfortunate result of the source command being used for both circuit input and command file execution. Note also that this allows the user to merely type the name of a circuit file as a command and it is automatically run. The commands are executed immediately, without running any analyses that may be specified in the circuit (to execute the analyses before the script executes, include a run command in the script). There are various command scripts installed in
5.3 COMMANDS5.3.1 Ac*: Perform an AC, small-signal frequency response analysisGeneral form:
ac [ dec | oct | lin ] N Fstart Fstop
Do an ac analysis. See the previous sections of this manual for more details. 5.3.2 Alias: Create an alias for a commandGeneral form:
alias [word] [text ... ]
Causes 5.3.3 Alter*: Change a device or model parameterGeneral form [3f4]:
alter dev = expression
alter dev param = expression
alter @dev[param] = expression
General form [pre 3f4]:
alter device value
alter device parameter value [ parameter value ]
Alter changes the value for a device or a specified parameter of a device or model. The first form is used by simple devices which have one principal value (resistors, capacitors, etc.) the other forms are for more complex devices (bjt's, etc.). Model parameters can be changed with the second form if the name contains a "#". For specifying vectors as values, start the vector with "[", followed by the values in the vector, and end with "]". Be sure to place a space between each of the values and before and after the "[" and "]". 5.3.am Altermod*: Change a model parameterGeneral form:
altermod mod = expression
altermod mod param = expression
altermod @mod[param] = expression
Altermod is a version of the alter command which operates on models and is used in the same manner. [Note: Code for this command was present but inactive in the original Berkeley release of Spice 3f4. CDHW.] 5.3.4 Asciiplot: Plot values using old-style character plotsGeneral form:
asciiplot plotargs
Produce a line printer plot of the vectors. The plot is sent to the standard output, so you can put it into a file with asciiplot args ... > file. The set options width, height, and nobreak determine the width and height of the plot, and whether there are page breaks, respectively. Note that you will have problems if you try to asciiplot something with an X-scale that isn't monotonic (i.e, something like sin(TIME)), because asciiplot uses a simple-minded linear interpolation. 5.3.5 ASpice: Asynchronous Spice runGeneral form:
aSpice input-file [output-file]
Start a Spice-3 run, and when it is finished load the resulting data. The raw data is kept in a temporary file. If output-file is specified then the diagnostic output is directed into that file, otherwise it is thrown away. 5.3.6 Bug: Mail a bug reportGeneral form:
bug
Send a bug report. Please include a short summary of the problem, the version number and name of the operating system that you are running, the version of Spice that you are running, and the relevant Spice input file. (If you have defined BUGADDR, the mail is delivered to there.) 5.3.7 Cd: Change directoryGeneral form:
cd [ directory ]
Change the current working directory to directory, or to the user's home directory if none is given. 5.3.co Compose: Compose a vectorGeneral form:
compose name values value1 [ value2 ... ]
compose name parm = val [ parm = val ... ]
[Note: This command was not fully implemented in the Berkeley release, however it is a way to create a vector from a list of values, which is lucky because the Berkeley frontend parser rejects expressions like [ 11 22 33 ].] The first form takes the values and creates a new vector, the values may be arbitrary expressions. The second form has the following possible parameters:
5.3.cs Cross: Create a vectorGeneral form:
cross vecname n [ vector1 vector2 ... ]
Create a new vector vecname from the nth elements of the listed vectors. Note: If any input vector is complex then the output vector will be complex, and vector[n] is the first element of vector. If n is a vector only the real part of its first element is used. 5.3.8 Destroy: Delete a data setGeneral form:
destroy [ plotnames | all ]
Release the memory holding the data for the specified runs.
5.3.9 Dc*: Perform a DC-sweep analysisGeneral form:
dc Source-Name Vstart Vstop Vincr [ Source2 Vstart2 Vstop2 Vincr2 ]
Do a dc transfer curve analysis. See the previous sections of this manual for more details.
5.3.10 Define: Define a functionGeneral form:
define function(arg1 [ , arg2 ... ]) expression
Define the user-definable function with the name function and arguments arg1, arg2, ... to be expression, which may involve the arguments. When the function is later used, the arguments it is given are substituted for the formal arguments when it is parsed. If expression is not present, any definition for function is printed, and if there are no arguments to define then all currently active definitions are printed. Note that you may have different functions defined with the same name but different arities [i.e. number of arguments.]. Some useful definitions are:
define max(x,y) (x > y) * x + (x <= y) * y
define min(x,y) (x < y) * x + (x >= y) * y
5.3.dt Deftype: Define type of plot or vectorGeneral form:
deftype v vectype [ units ]
deftype p plottype [ pattern ... ]
Define addtional vector and plot types. The first form refers to vectors, for example:
This second form of this command seems to have been intended for use in the Command: field of rawfiles. It defines additional plot-types. The short name given to a plot with any of the patterns present in its Name: field will be plottypeN, where N is a distinctive number. 5.3.11 Delete*: Remove a trace or breakpointGeneral form:
delete [ debug-number ... ]
Delete the specified breakpoints, traces and saves. The debug numbers are those shown by the status command (unless you do status > file, in which case the debug numbers are not printed). 5.3.12 Diff: Compare vectorsGeneral form:
diff plot1 plot2 [ vec ...]
Compare all the vectors in the specified plots, or only the named vectors if any are given. There are different vectors in the two plots, or any values in the vectors differ significantly the difference is reported. The variable diff_abstol, diff_reltol, and diff_vntol are used to determine what is meant by a significant difference. 5.3.13 Display: List known vectors and typesGeneral form:
display [ varname ...]
Prints a summary of currently defined vectors, or of the names specified. The vectors are sorted by name unless the variable nosort is set. The information given is the name of the vector, the length, the type of the vector, and whether it is real or complex data. Additionally, one vector is labeled [scale]. When a command such as plot is given without a vs argument, this scale is used for the X-axis. It is always the first vector in a rawfile, or the first vector defined in a new plot. If you undefine the scale (i.e., let TIME = []), one of the remaining vectors becomes the new scale (which is undetermined). See also setscale. 5.3.14 Echo: Print textGeneral form:
echo [ -n ] [ text ... ]
Echos the given text to the screen. If the first argument is -n the terminating newline is suppressed. 5.3.15 Edit*: Edit the current circuitGeneral form:
edit [ file ]
Print the current Spice3 input file into a file, call up the editor on that file and allow the user to modify it, and then read it back in, replacing the original file. If a filename is given, then edit that file and load it, making the circuit the current one. 5.3.16 Fourier: Perform a Fourier transformGeneral form:
fourier fundamental [ value ...]
Does a Fourier analysis of each of the given values, using the first 10 multiples of the fundamental frequency (or the first nfreqs, if that variable is set - see below). The output is like that of the .FOUR Spice3 line. The values may be any valid expression. The values are interpolated onto a fixed-space grid with the number of points given by the fourgridsize variable, or 200 if it is not set. The interpolation is of degree polydegree if that variable is set, or 1. If polydegree is 0, then no interpolation is done. This is likely to give erroneous results if the time scale is not monotonic, though. 5.3.17 Hardcopy: Save a plot to a file for printingGeneral form:
hardcopy file plotargs
Just like plot, except creates a file called file containing the plot in the format specified by the variable hcopydevtype. The default file format is an image in plot(5) format, and can be printed by either the [unix] plot(1) program or lpr with the -g flag. See also the hcopy variables. 5.3.18 Help: Print summaries of Spice3 commandsGeneral form:
help [all] [command ...]
Prints help. If the argument all is given, a short description of everything you could possibly type is printed. If commands are given, descriptions of those commands are printed. Otherwise help for only a few major commands is printed. 5.3.19 History: Review previous commandsGeneral form:
history [ -r ] [number]
Print out the history, or the last number commands typed at the keyboard. Note: in Spice3 version 3a7 and earlier, all commands (including ones read from files) were saved. The -r option reverses the printing order. [See also the page on history substitutions in commands.] 5.3.20 Iplot*: Incremental plotGeneral form:
iplot [ node ...]
Incrementally plot the values of the nodes while Spice3 runs. The iplot command can be used with the where command to find trouble spots in a transient simulation; it is essentially a graphical version of trace. Several iplots may be active simulataneously. Iplotting is not applicable for all analyses. The status command displays a list of current iplots, and these can be removed with the delete command. 5.3.21 Jobs: List active asynchronous Spice runsGeneral form:
jobs
Report on the asynchronous Spice-3 jobs currently running. Nutmeg checks to see if the jobs are finished every time you execute a command. If it is done then the data is loaded and becomes available. 5.3.22 Let: Assign a value to a vectorGeneral form:
let name = expr
Assigns the value specified by expr, an expression as described above, to the vector called name which is created in the current plot if it is not found. If expr is [] (a zero-length vector) then the vector becomes undefined [Note: This doesn't work with the Berkeley 3f4/5 release code, try unlet instead.]. Individual elements of a vector may be modified by appending a subscript to name (e.g. name[0]). If there are no arguments, let is the same as display. [Note: Do not use the form
to abbreviate
because Spice will perform an unwanted and time-consuming search for commands and/or
files matching 'myvec' before using the let command as the default behaviour.]
The command let creates a vector in the current plot, use setplot to create a new plot. See also unlet, compose, and setplot. 5.3.23 Linearize*: Interpolate to a linear scaleGeneral form:
linearize [ vec ... ]
Create a new plot with all of the vectors in the current plot, or only those mentioned if arguments are given. The new vectors are interpolated onto a linear time scale, which is determined by the values of tstep, tstart, and tstop in the currently active transient analysis. The currently loaded input file must include a transient analysis (a tran command may be run interactively before the last reset, alternately), and the current plot must be from this transient analysis. This command is needed because Spice3 doesn't output the results from a transient analysis in the same manner that Spice2 did. 5.3.24 Listing*: Print a listing of the current circuitGeneral form:
listing [ logical | physical | deck ] [ expand ]
If the logical argument is given, the listing is with all continuation lines collapsed into one line, and if the physical argument is given the lines are printed out as they were found in the file. The default is logical. A deck listing is just like the physical listing, except without the line numbers it recreates the input file verbatim (except that it does not preserve case). If the word expand is present, the circuit is printed with all subcircuits expanded. 5.3.25 Load: Load rawfile dataGeneral form:
load [ filename ... ]
Loads either binary or ascii format rawfile data from the files named. The default filename is rawSpice.raw, or the argument to the -r flag if there was one when Spice was invoked. 5.3.ns Noise*: Perform a noise analysisGeneral form:
noise v(output [,ref]) src [ dec | lin | oct ] Pts Fstart Fstop [PPS];
Do an noise analysis. See the previous sections of this manual for more details. 5.3.26 Op*: Perform an operating point analysisGeneral form:
op
Do an operating point analysis. See the previous sections of this manual for more details. 5.3.27 Plot: Plot values on the displayGeneral form:
plot exprs [ylimit ylo yhi] [xlimit xlo xhi] [xindices xilo xihi]
[xcompress comp] [xdelta xdel] [ydelta ydel] [xlog] [ylog] [loglog]
[vs xname] [xlabel word] [ylabel word] [title word] [samep]
[keyword ... ]
Plot the given exprs on the screen (if you are on a graphics
terminal). The The If The The following keywords are available in Spice3f:
[Note: The Berkeley release version of this command seems to ignore the variables that one would expect to influence this command. CDHW.] 5.3.28 Print: Print valuesGeneral form:
print [col] [line] expr [ expr2 ... ]
Prints the vector described by the expression expr. If the col argument is present, print the vectors named side by side. If line is given, the vectors are printed horizontally. col is the default, unless all the vectors named have a length of one, in which case line is the default. The options width, height, and nobreak are effective for this command (see asciiplot). If the expression is all, all of the vectors available are printed. Thus print col all > file prints everything in the file in Spice2 format. The scale vector (time, frequency) is always in the first column unless the variable noprintscale is true. 5.3.pz PZ: Pole-Zero AnalysisGeneral form:
pz node1 node2 node3 node4 { cur | vol } { pol | zer | pz }
Performs a pole-zero analysis of the current circuit, as described earlier.
5.3.29 Quit: Leave Spice3 or NutmegGeneral form:
quit
Quit nutmeg or Spice. 5.3.30 Rehash: Reset internal hash tablesGeneral form:
rehash
Recalculate the internal hash tables used when looking up UNIX commands, and make all UNIX commands in the user's PATH available for command completion. This is useless unless you have set unixcom first (see below). 5.3.31 Reset*: Reset an analysisGeneral form:
reset
Throw out any intermediate data in the circuit (e.g, after a breakpoint or after one or more analyses have been done already), and re-parse the input file. The circuit can then be re-run from its initial state, overriding the affect of any set or alter commands. In Spice-3e and earlier versions this was done automatically by the run command. 5.3.32 Reshape: Alter the dimensionality or dimensions of a vectorGeneral form:
reshape vector vector ...
or
reshape vector vector ... [ dimension, dimension, ... ]
or
reshape vector vector ... [ dimension ][ dimension ] ...
This command changes the dimensions of a vector or a set of vectors. The final dimension may be left off and it will be filled in automatically. If no dimensions are specified, then the dimensions of the first vector are copied to the other vectors. An error message of the form 'dimensions of x were inconsistent' can be ignored. 5.3.33 Resume*: Continue a simulation after a stopGeneral form:
resume
Resume a simulation after a stop or interruption (control-C). 5.3.34 RSpice: Remote Spice submissionGeneral form:
rSpice input file
Runs a Spice-3 remotely taking the input file as a Spice-3 input file, or the current circuit if no argument is given. Nutmeg or Spice3 waits for the job to complete, and passes output from the remote job to the user's standard output. When the job is finished the data is loaded in as with aSpice. If the variable rhost is set, nutmeg connects to this host instead of the default remote Spice3 server machine. This command uses the "rsh" command and thereby requires authentication via a ".rhosts" file or other equivalent method. Note that "rsh" refers to the "remote shell" program, which may be "remsh" on your system; to override the default name of "rsh", set the variable remote_shell. If the variable rprogram is set, then rSpice uses this as the pathname to the program to run on the remote system. Note: rSpice will not acknowledge elements that have been changed via the alter or altermod commands. [Note: Altermod is absent from many implemetations, use alter instead.] 5.3.35 Run*: Run analysis from the input fileGeneral form:
run [ rawfile ]
Run the analyses specified in the input file for the current circuit. If there are any of the control lines specified in Section 4.3 present they are executed. The output is put in rawfile if it is given, in addition to being available interactively. In Spice-3e and earlier versions, the input file would be re-read and any affects of the set or alter commands would be reversed. This is no longer the effect. [Note. Interactive commands specified using the .command/.endc mechanism are not executed by this command.] 5.3.36 Rusage: Resource usageGeneral form:
rusage [ resource ...]
Print resource usage statistics. If any resources are given,
just print the usage of that resource. Most resources require that a
circuit be loaded. Currently valid resources are:
5.3.37 Save*: Save a set of outputsGeneral form:
save [ all | output ...]
Save a set of outputs, discarding the rest. If a node has been mentioned in a save command, it appears in the working plot after a run has completed, or in the rawfile if Spice is run in batch mode. If a node is traced or plotted (see below) it is also saved. For backward compatibility, if there are no save commands given, all outputs are saved. When the keyword "all" appears in the save command, all default values (node voltages and voltage source currents) are saved in addition to any other values listed. See also the status and delete commands. 5.3.38 Sens*: Run a sensitivity analysisGeneral form:
sens output
sens output ac [ dec | oct | lin ] N Fstart Fstop
Perform a sensitivity analysis. The variable output is either a node voltage (e.g. "v(1)" or "v(A,out)") or a current through a voltage source (e.g. "i(vtest)"). The first form calculates DC sensitivities, the second form calculates AC sensitivities. The output values are in dimensions of change in output per unit change of input (as opposed to percent change in output or per percent change of input). 5.3.39 Set: Set the value of a variableGeneral form:
set [ word ]
set [ word = value ] ...
Set the value of word to be value, if it is present. You can set any word to be any value, numeric or string. If no value is given then the value is the boolean 'true'. The value of word may be inserted into a command by writing $word. If a variable is set to a list of values that are enclosed in parentheses (which must be separated from their values by white space), the value of the variable is the list. The variables affecting Nutmeg are listed in the following section (5.5). The 'set' command can also be used to change simulator parameters for the current circuit (see setcirc below). Set values will be used (until the circuit is reset) when the current circuit is run and take precedence over a .options statement. See also the discussion in section D.5.3.40 Setcirc*: Change the current circuitGeneral form:
setcirc [ cktname ]
Selects cktname as the 'current' circuit. When a circuit is loaded with the source command it is added to a list of available circuits and becomes the current circuit. The setcirc without an argument prints a menu of available circuits. 5.3.41 Setplot: Switch the current set of vectorsGeneral form:
setplot [ plotname ]
Set the current plot to the plot with the given name, or if no name is given, prompt the user with a menu. (Note that the plots are named as they are loaded, with names like tran1 or op2. These names are shown by the setplot and display commands and are used by diff, above.) If the plotname 'new' is selected, the current plot becomes one with no vectors defined and name 'unknown'. Note that here the word "plot" refers to a group of vectors that are the result of one Spice analysis run. When more than one file is loaded in, or more than one plot is present in one file, Nutmeg keeps them separate and only shows you the vectors in the current plot. 5.3.ss Setscale: Set the scale vector for current plotGeneral form:
setscale [ vector ]
Defines the scale vector for the current plot. If no argument is given, the current scale vector is printed. 5.3.42 Settype: Set the type of a vectorGeneral form:
settype type vector [ vector ... ]
Change the type of the named vectors to type. Type names can be found in the manual page for sconvert. 5.3.43 Shell: Call the command interpreterGeneral form:
shell [ command ]
Call the operating system's command interpreter; execute the specified command or call for interactive use. 5.3.44 Shift: Alter a list variableGeneral form:
shift [ varname ] [ number ]
If varname is the name of a list variable, it is
shifted to the left by number elements (i.e, the number
leftmost elements are removed). The default varname is
5.3.45 Show*: List device stateGeneral form:
show devices [ : parameters ] , ...
Old form:
show -v @device [ [ name ] ]
The show command prints out tables summarizing the operating condition of selected devices (much like the Spice2 operation point summary). If device is missing, a default set of devices are listed, if device is a single letter, devices of that type are listed; if device is a subcircuit name (beginning and ending in ":") only devices in that subcircuit are shown (end the name in a double-":" to get devices within sub-subcircuits recursively). The second and third forms may be combined ("letter:subcircuit:") or "letter:subcircuit::") to select a specific type of device from a subcircuit. A device's full name may be specified to list only that device. Finally, devices may be selected by model by using the form "#modelname" or ":subcircuit#modelname" or "letter:subcircuit#modelname". If no parameters are specified, the values for a standard set of parameters are listed. If the list of parameters contains a "+", the default set of parameters is listed along with any other specified parameters. For both devices and parameters, the word "all" has the obvious meaning. Note: there must be spaces separating the ":" that divides the device list from the parameter list. The "old form" (with "-v") prints the data in an older, more verbose pre-Spice3f format. 5.3.46 Showmod*: List model parameter valuesGeneral form:
showmod models [ : parameters ] , ...
The showmod command operates like the show command (above) but prints out model parameter values. The applicable forms for models are a single letter specifying the device type letter, "letter:subckt:", "modelname", ":subckt:modelname", or "letter:subcircuit:modelname". 5.3.47 Source: Read a Spice3 input fileGeneral form:
source file
For Spice3: Read the Spice3 input file file. Nutmeg and Spice3 commands may be included in the file, and must be enclosed between the lines .control and .endc. These commands are executed immediately after the circuit is loaded, so a control line of ac ... works the same as the corresponding .AC card. The first line in any input file is considered a title line and not parsed but kept as the name of the circuit. The exception to this rule is the file .Spiceinit. Thus, a Spice3 command script must begin with a blank line and then a control line. Also, any line starting with the characters *# is considered a control line. This makes it possible to embed commands in Spice3 input files that are ignored by earlier versions of Spice2. For Nutmeg: Reads commands from the file filename. Lines beginning with the character * are considered comments and ignored. 5.3.sp Spec: Create a frequency domain plotGeneral form:
spec start_freq stop_freq step_freq vector [vector ...]
Calculates a new complex vector containing the Fourier transform of the input vector (typically the linearized result of a transient analysis). The default behaviour is to use a Hanning window, but this can be changed by setting the variables specwindow and specwindoworder appropriately. Typical usage:
spice3 > linearize
spice3 > set specwindow = "blackman"
spice3 > spec 10 1000000 1000 v(out)
spice3 > plot mag(v(out))
Possible values for specwindow are: none, hanning, cosine, rectangular, hamming, triangle, bartlet, blackman, gaussian. In the case of a gaussian window specwindoworder is a number specifying its order. [Note: This command was not part of the original Berkeley Spice release. The source code was released by its author, and is often incorporated. A command script version is (Hanning window only) available for use in other cases. 5.3.48 Status*: Display breakpoint informationGeneral form:
status
status > file
Display all of the save, trace, iplot and breakpoint events currently in effect. If the output is redirected to a file, it is assumed that the intention is to re-import it later using the source command so the event numbers are omitted.See also the delete command. 5.3.49 Step*: Run a fixed number of timepointsGeneral form:
step [ number ]
Iterate number times, or once, and then stop. 5.3.50 Stop*: Set a breakpointGeneral form:
stop [ after n ] [ when value cond value ] ...
Set a breakpoint. The argument 'after n' means stop after iteration number n, and the argument 'when value cond value' means stop when the first value is in the given relation with the second value, the possible relations being
IO redirection is disabled for the stop command, since the relational operations conflict with it (stop doesn't produce any output anyway). The values above may be node names in the running circuit, or real values. If more than one condition is given, e.g. stop after 4 when v(1) > 4 when v(2) < 2, the conjunction of the conditions is implied. See also status. 5.3.sc Strcmp: Compare stringsGeneral form:
strcmp result str1 str2
The strcmp command compares two string variables str1 and str2 for equality and sets result as follows:
Some implementations consider "ABC" to be equal to "abc". 5.3.51 Tf*: Run a Transfer Function analysisGeneral form:
tf outvar ipsource
Examples:
tf v(node1,node2) vsource
tf i(vload) isource
The tf command performs a transfer function analysis, returning the transfer function (output/input), output resistance, and input resistance for the given output and input sources. The analysis assumes a small-signal DC (slowly varying) input. 5.3.52 Trace*: Trace nodesGeneral form:
trace [ node ... ]
For every step of an analysis, the value of the node is printed. Several traces may be active at once. Tracing is not applicable for all analyses. To remove a trace, use the delete command. 5.3.53 Tran*: Perform a transient analysisGeneral form:
tran Tstep Tstop [ Tstart [ Tmax ] ] [ uic ]
Perform a transient analysis. See the previous sections of this manual for more details. 5.3.54 Transpose: Swap the elements in a multi-dimensional data setGeneral form:
transpose vector [ vector ... ]
This command transposes a multidimensional vector. No analysis in
Spice3 produces multidimensional vectors, although the DC transfer curve may be run with two varying
sources. You must use the reshape command to reform the
one-dimensional vectors into two dimensional vectors. In addition,
the default scale is incorrect for plotting. You must plot
versus the vector corresponding to the second source, but you
must also refer only to the first segment of this second source
vector. For example (circuit to produce the transfer characteristic
of a MOS transistor):
5.3.55 Unalias: Retract an aliasGeneral form:
unalias [ word ... ]
Removes any aliases present for the words. 5.3.56 Undefine: Retract a definitionGeneral form:
undefine function
Definitions for the named user-defined functions are deleted. 5.3.ul Unlet: Delete a vectorGeneral form:
unlet vector [ vector ... ]
Delete the specified vector(s). See also let. 5.3.57 Unset: Clear a variableGeneral form:
unset word [ word ... ]
Clear the value of the specified variable(s) (word).
5.3.58 Version: Print the version of SpiceGeneral form:
version [ verid ]
Print out the version of nutmeg that is running. If there are arguments, it checks to make sure that the arguments match the current version of Spice. (This is mainly used as a Command: line in rawfiles.) 5.3.59 Where: Identify troublesome node or deviceGeneral form:
where
When performing a transient or operating point analysis, the name of the last node or device to cause non-convergence is saved. The where command prints out this information so that you can examine the circuit and either correct the problem or make a bug report. You may do this either in the middle of a run or after the simulator has given up on the analysis. For transient simulation, the iplot command can be used to monitor the progress of the analysis. When the analysis slows down severly or hangs, interrupt the simulator (with control-C) and issue the where command. Note that only one node or device is printed; there may be problems with more than one node. 5.3.60 Write: Write data to a fileGeneral form:
write [ file ] [ expr ... ]
Writes out the expressions to file. First, vectors are grouped together by plots, and written out as such (i.e, if the expression list contained three vectors from one plot and two from another, then two plots are written, one with three vectors and one with two). Additionally, if the scale for a vector isn't present, it is automatically written out as well. The default format is ascii, but this can be changed with a set filetype = command. The default filename is rawSpice.raw, or the argument to the -r flag on the command line, if there was one, and the default expression list is 'all'. 5.3.61 Xgraph: use the xgraph(1) program for plotting.General form:
xgraph file [ expr ... ] [ options ]
The Spice3/nutmeg xgraph command plots data like
the plot command but via xgraph, a popular X11 plotting
program.
If file is either "temp" or "tmp" a temporary file is used to hold the data while being plotted. For available plot options, see the plot command. All options except for polar and Smith plots are supported. 5.4 CONTROL STRUCTURES[Note: In the original Berkeley release of Spice 3f4/5 the implementation of the following control structures contained several bugs. Many of the above commands leak memory so rapidly that they are all but useless in loops containing a significant number of repetitions. Subsequent workers (including MacSpice, and Spice Opus) have made serious attempts to correct these problems.] 5.4.1 While - EndGeneral form:
while condition
statement
...
end
While condition, an arbitrary algebraic expression, is true, execute the statements. 5.4.2 Repeat - EndGeneral form:
repeat [ number ]
statement
...
end
Execute the statements number times, or forever if no argument is given. 5.4.3 Dowhile - EndGeneral form:
dowhile condition
statement
...
end
The same as while, except that the condition is tested after the statements are executed. 5.4.4 Foreach - EndGeneral form:
foreach var value ...
statement
...
end
The statements are executed once for each of the values, each time with the variable var set to the current one. (var can be accessed by the $var notation - see below). 5.4.5 If - Then - ElseGeneral form:
if condition
statement
...
else
statement
...
end
If the condition is non-zero then the first set of statements are executed, otherwise the second set. The else and the second set of statements may be omitted. 5.4.6 LabelGeneral form:
label word
If a statement of the form goto word is encountered, control is transferred to this point, otherwise
this is a no-op.
5.4.7 GotoGeneral form:
goto word
If a statement of the form label word is present in
the block or an enclosing block, control is transferred
there. Note that if the label is at the top level, it
must be before the goto statement (i.e. a forward goto)
may occur only within a block).
5.4.8 Continue
continue
If there is a 5.4.9 BreakGeneral form:
break
If there is a Of course, control structures may be nested. When a block is entered and the input is the terminal, the prompt becomes a number of >'s corresponding to the number of blocks the user has entered. The current control structures may be examined with the debugging command cdump. 5.5 VARIABLESThe operation of both Nutmeg and Spice3 may be affected by setting variables with the "set" command. In addition to the variables mentioned below, the set command in Spice3 also affect the behaviour of the simulator via the options previously described under the section on ".OPTIONS". The variables meaningful to nutmeg which may be altered
by the set command are:
There are several set variables that Spice3 uses but Nutmeg does not. They are:
5.6 MISCELLANEOUSIf there are subcircuits in the input file, Spice3 expands instances of them. A subcircuit is delimited by the cards .SUBCKT and .ENDS, or whatever the value of the variables substart and subend is, respectively. An instance of a subcircuit is created by specifying a device with type 'x' - the device line is written
xname node1 node2 ... subcktname
where the nodes are the node names that replace the formal
parameters on the .SUBCKT line. All nodes that are not formal parameters are prepended with the name given to the
instance and a ':', as are the names of the devices in the
subcircuit. If there are several nested subcircuits, node
and device names look like subckt1:subckt2:...:name. If the
variable subinvoke is set, then it is used as the prefix
that specifies instances of subcircuits, instead of 'x'.
Nutmeg occasionally checks to see if it is getting close to running out of space, and warns the user if this is the case. (This is more likely to be useful with the Spice front end.) C-shell type quoting with "" and '', and backquote substitution may be used. Within single quotes, no further substitution (like history substitution) is done, and within double quotes, the words are kept together but further substitution is done. Any text between backquotes is replaced by the result of executing the text as a command to the shell. Tenex-style ('set filec' in the 4.3 C-shell) command, filename, and keyword completion is possible: If EOF (control-D) is typed after the first character on the line, a list of the commands or possible arguments is printed (If it is alone on the line it exits nutmeg). If escape is typed, then nutmeg trys to complete what the user has already typed. To get a list of all commands, the user should type <space> ^D. The values of variables may be used in commands by writing $varname where the value of the variable is to appear. The special variables $$ and $< refer to the process ID of the program and a line of input which is read from the terminal when the variable is evaluated, respectively. If a variable has a name of the form $&word, then word is considered a vector (see above), and its value is taken to be the value of the variable. If $foo is a valid variable, and is of type list, then the expression $foo[low-high] represents a range of elements. Either the upper index or the lower may be left out, and the reverse of a list may be obtained with $foo[len-1]. Also, the notation $?foo evaluates to 1 if the variable foo is defined, 0 otherwise, and $#foo evaluates to the number of elements in foo if it is a list, 1 if it is a number or string, and 0 if it is a boolean variable. History substitutions, similar to C-shell history substitutions, are also available - see the C-shell manual page for all of the details. The characters ~, {, and } have the same effects as they do in the C-Shell, i.e., home directory and alternative expansion. It is possible to use the wildcard characters *, ?, [, and ] also, but only if you unset noglob first. This makes them rather useless for typing algebraic expressions, so you should set noglob again after you are done with wild-card expansion. Note that the pattern [^abc] matchs all characters except a, b, and c. IO redirection is available - the symbols >, >>, >&, >>&, and < have the same effects as in the C-shell. You may type multiple commands on one line, separated by semicolons. If you want to use a different mfbcap file than the default (usually ~cad/lib/mfbcap), you have to set the environment variable Spice_MFBCAP before you start nutmeg or Spice. The -m option and the mfbcap variable no longer work. If X is being used, the cursor may be positioned at any point on the screen when the window is up and characters typed at the keyboard are added to the window at that point. The window may then be sent to a printer using the xpr(1) program. Nutmeg can be run under VAX/VMS, as well as several other operating systems. Some features like command completion, expansion of *, ?, and [], backquote substitution, the shell command, and so forth do not work. On some systems you have to respond to the -more- prompt during plot with a carriage return instead of any key as you can do on UNIX. 5.7 BUGSThe label entry facilities are primitive. You must be careful to type slowly when entering labels -- nutmeg checks for input once every second, and can get confused if characters arrive faster.If you redefine colors after creating a plot window with X, and then cause the window to be redrawn, it does not redraw in the correct colors. When defining aliases like
alias pdb plot db( '!:1' - '!:2' )
you must be careful to quote the argument list substitutions in this manner. If you quote the whole argument
it might not work properly.
In a user-defined function, the arguments cannot be part of a name that uses the plot.vec syntax. For example:
define check(v(1)) cos(tran1.v(1))
does not work.
If you type plot all all, or otherwise use a wildcard reference for one plot twice in a command, the effect is unpredictable. The asciiplot command doesn't deal with log scales or the delta keywords. Often the names of terminals recognized by MFB are different from those in /etc/termcap. Thus you may have to reset your terminal type with the command
set term = termname
where termname is the name in the mfbcap file.
The hardcopy command is useless on VMS and other systems without the plot command, unless the user has a program that understands plot(5) format. Spice3 recognizes all the notations used in Spice2 .PLOT cards, and translates vp(1) into ph(v(1)), and so forth. However, if there are spaces in these names it won't work. Hence v(1, 2) and (-.5, .5) aren't recognized. BJTs can have either 3 or 4 nodes, which makes it difficult for the subcircuit expansion routines to decide what to rename. If the fourth parameter has been declared as a model name, then it is assumed that there are 3 nodes, otherwise it is considered a node. To disable this, you can set the variable "nobjthack" which forces BJTs to have 4 nodes (for the purposes of subcircuit expansion, at least). The @name[param] notation might not work with The first line of a command file (except for the .Spiceinit file) should be a comment, otherwise Spice may create an empty circuit. Files specified on the command line are read before .Spiceinit is read. |