# 幸运飞艇超稳计划群

MacSpice > User's Guide > Interactive Interpreter

# MacSpice User's Guide

## 5 INTERACTIVE INTERPRETER

MacSpice is distributed as a Mac OS X application bundle. It provides an enhanced versions of the Spice 3 simulator and the Nutmeg front-end command interpreter for data analysis and plotting. Installation notes and release notes are published on www.macpsice.com. MacSpice has several mechanisms for inter-process communication幸运飞艇超稳计划群 with other applications and shells.

spice 3 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 Spice 3 session. Nutmeg or interactive Spice 3 can plot data from a simulation on a graphics terminal or a workstation display. Most of the commands available in the interactive Spice 3 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 Spice 3 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 Spice 3 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

     Spice [ -n ] [ -t term ] [ -r rawfile ] [ -b ] [ -i ] [ inpfile ... ]

     nutmeg [ - ] [ -n ] [ -t term ] [ datafile ... ]


Options are:

-
Don't try to load the default data file ("rawspice.raw") if no other files are given. Nutmeg only.

-n (or -N)
Don't try to source the file ".spiceinit" upon startup. Normally Spice and Nutmeg try to find the file in the current directory, and if it is not found then in the user's home directory.

-t term (or -T term)
The program is being run on a terminal with mfb name term.

-b (or -B)
Run in batch mode. Spice 3 reads the default input source (e.g. keyboard) or reads the given input file and performs the analyses specified; output is either Spice2-like line-printer plots ("ascii plots") or a Spice rawfile. See the following section for details. Note that if the input source is not a terminal (e.g. using the IO redirection notation of "<") Spice 3 defaults to batch mode (-i overrides). This option is valid for Spice 3 only.

-s (or -S)
Run in server mode. This is like batch mode, except that a temporary rawfile is used and then written to the standard output, preceded by a line with a single "@", after the simulation is done. This mode is used by the Spice daemon. This option is valid for Spice 3 only.

-i (or -I)
Run in interactive mode. This is useful if the standard input is not a terminal but interactive mode is desired. Command completion is not available unless the standard input is a terminal, however. This option is valid for Spice 3 only.

-r rawfile (or -P rawfile)
Use rawfile as the default file into which the results of the simulation are saved. This option is valid for Spice 3 only.

Further arguments to Spice are taken to be Spice 3 input files, which are read and saved (if running in batch mode then they are run immediately). Spice 3 accepts most Spice2 input file, and output ascii plots, Fourier analyses, and node printouts as specified in .PLOT, .FOUR, and .PRINT control lines. If an out parameter is given on a .WIDTH control line, the effect is the same as set width = .... Since Spice 3 ascii plots do not use multiple ranges, however, if vectors together on a .PLOT control line have different ranges they are not provide as much information as they would in Spice2. The output of Spice 3 is also much less verbose than Spice2, in that the only data printed is that requested by the above control lines.

For Nutmeg, further arguments are taken to be data files in binary or ascii format (see ) 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 CONSTANTS

Spice (the simulator) and Nutmeg (the front-end) 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 the simulator performs an analysis, or a data file is read in (see the load command below). 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, '^' is the power operator. The unary minus has a higher precedence than both of these, i.e. -x^2 is interpreted as (-x)^2, but 0-x^2 is interpreted as -(x^2). 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).

The relational operations '<', '>', '>=', '<=', '=', and '<>' are available. When used in an algebraic expression they work like they would in C, returning values of 0 or 1. Also available are the logical operations 'and', 'or', 'xor', and 'not'. The traditional Boolean definitions of these operations have been extended by using the floating-point exception value 'NaN' (e.g. 0/0) to represent the 'unknown' state of so-called Kleene tri-state logic. The relational and logical operators have the following synonyms:

 & and | or # xor ~ not > gt >= ge < lt <= le = eq <> ne >< ne

 mag(vector) The magnitude of vector. [Note: magnitude() is a synonym for this.] ph(vector) The phase of vector. [Note: phase() is a synonym for this.] real(vector) The real parts of vector. imag(vector) The imaginary parts of vector. j(vector) The vector is multiplied by sqrt(−1). db(vector) 20log10(vector). If vector is complex, its magnitude is taken. MacSpice changes the pre-factor to 10 if the units of vector are identified as being proportional to power. log(vector) The logarithm (base 10) of vector. ln(vector) The natural logarithm (base e) of vector. exp(vector) e to the vector power. abs(vector) The absolute value of vector. sqrt(vector) The square root of vector. sin(vector) The sine of vector. cos(vector) The cosine of vector. tan(vector) The tangent of vector. atan(vector) The inverse tangent of vector. norm(vector) The vector normalized to 1 (i.e. the largest magnitude of any element is 1). pos(vector) 1 if the real part of vector is positive (greater than zero), 0 otherwise. [Note: present, but undocumented in Berkeley Spice 3.] rnd(vector) A vector with random integer components in the range [0..n−1] where n is the largest integer not greater than the absolute value of the corresponding component of vector and not greater than 231. The MacSpice (v3.1.20) implementation of rnd() avoids modulo bias and generates a uniform distribution for all values of n≤253. See also the compose command below. mean(vector) The result is a scalar (a length 1 vector) that is the arithmetic mean of all the elements of vector. Calculated using extended precision summation. See also the average(array) function below. unitvec(number) The result is a vector of length number, with elements 1. If number is a vector then just the first element is taken, and if it isn't an integer then the floor of the (real) value or (complex) magnitude is used. [Note: present, but undocumented in Berkeley Spice 3.] vector(number) The result is a vector of length number, with elements 0, 1, ... number−1. If number is a vector then just the first element is taken, and if it isn't an integer then the floor of the (real) value or (complex) magnitude is used. length(vector) The length of vector. interpolate(vector) The result of interpolating the named vector onto the current scale of the current plot. This function uses the variable polydegree to determine the degree of interpolation. Both the argument vector, and its scale, must be real. deriv(vector) Interpolates its argument onto the current scale and differentiates the interpolating polynomial with repect to the current scale. The order is set by the variable dpolydegree. (N.B. Numerical differentiation may produce noisy or inaccurate results, particularly when iterated to obtain nth-order derivatives.) Both the argument vector, and its scale, must be real.

 acos(vector) The inverse cosine of vector. asin(vector) The inverse sine of vector. integral(vector) Interpolates its argument onto the current scale and integrates the interpolating polynomial with repect to the current scale. The order is set by the variable ipolydegree. Both the argument vector, and its scale, must be real. unwrap(vector) Unwraps a vector that contains a sequence of phase angles; affected by the current units and unwraptol settings. wrap(vector) Wraps vector containg a sequence of phase angles so that they all lie within the range [−180°,+180°) or [−π,+π) as indicated by the current units setting.

The following functions operate on array幸运飞艇超稳计划群 argument-types and have this property:

\begin{align*} f( \;\mathbf{a}_0 \;;\; \mathbf{a}_1 \;;\; ... \;;\; \mathbf{a}_n \;) = ( \;f(\; \mathbf{a}_0 ) \;;\; f( \mathbf{a}_1 ) \;;\; ... \;;\; f( \mathbf{a}_n ) \;) \end{align*}

Hence, with n-dimensional arguments, these functions iterate over additional dimensions and construct a vector or array of results. (See also the reshape and transpose commands.)

 average(array) Returns the arithmetic mean of a vector. Calculated using extended precision summation. See also mean(vector) above. cumsum(array) Returns the cumulative sum of vector elements. Calculated using extended precision summation. fft(array) The discrete Fourier transform (DFT) of a vector. See Appendix E for details. fftconvert(array) Converts the result of the FFT of a real vector between the layouts. See Appendix E for details. hash(array) Returns a 52-bit integer hash, i.e. 0 ≤ h < 252, for vector keys. ifft(array) The inverse DFT of a vector. See Appendix E for details. maximum(array) Returns the maximum element of a real vector. See also §5.3.10. minimum(array) Returns the minimum element of a real vector. See also §5.3.10. structure(array) Returns the first-order structure function of a time-series sampled at regular intervals. transpose(array) Transposes the rows and columns in the last two dimensions of the argument. See also §5.3.54. sortorder(array) Returns the positions of the elements in a real vector after they have been sorted into increasing order using a stable method (mergesort).

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 Spice 3 grammar used by the frontend is difficult to parse. In some cases it may be necessary to delimit element names with spaces, e.g. 'foo[ bar[n] ]'. A related problem arises when refering to vectors with names which start with characters that are a valid number, e.g. '2a'. (See below for a detailed explanation.)

MacSpice defines a semicolon operator to facilitate construction of vectors and n-dimensional matrices. It allows an (n+1)-dimensional vector to be constructed from two n-dimensional vectors, or an n-dimensional vector to be extended by appending/prepending an (n−1)-dimensional element. e.g. the commands:

    let foo = ((11;12);(21;22)) creates a 2×2 matrix
let bar = (foo;(31;32))     creates a 3×2 matrix
let baz = (foo;foo)         creates a 2×2×2 matrix
let qux = (1;(3,4);5)       creates a 3-element complex vector

The notation expr[num] denotes the num'th element of expr. For multi-dimensional vectors, a vector of dimension one lower is returned. Also for multi-dimensional vectors, the notation expr[m][n] will return the n'th element of the m'th subvector. If the index is a complex value its real and imaginary parts are interpreted as the first and last elements of a range. So, to get a subrange of a vector, use the form expr[lower,upper].

The notation vector[[lower,upper]] denotes the values in vector corresponding to the range from lower to upper in its scale, so that v(1)[[10,20]] gives all the values of v(1) for which the scale values associated with v(1)幸运飞艇超稳计划群 are in the range 10 to 20 inclusive. If there is one argument it picks out the values which have that scale value. Multi-dimensionality is ignored here; the result is a one-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 wild-card 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: Berkeley Spice 3 does not correctly parse vectors so, if code-portability is required, consider using the compose command.]

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.

The grammar of the expressions used by the Spice 3 command line interpreter is ambiguous. Node names can be 'arbitrary character strings' (see section 2.1), but numerical values have the property that 'letters immediately following a number that are not scale factors are ignored'. This means that it is impossible to distinguish node names from numbers merely by inspecting an expression containing them.

MacSpice normally gives precedence to numbers. This means that the value of sin(123m) is 2.146753e-03 and does not depend on whether or not the current plot has a vector called '123m' in it. The 'v()' and 'i()' functions are exceptions to this rule, their arguments are interpreted as character strings. Hence, it is possible to extract the values of vectors whose names are valid numbers by quoting them carefully, e.g.

	MacSpice 1 -> let 123m = 999
MacSpice 2 -> print 123m
123m = 1.230000e-01
MacSpice 3 -> print v(123m)
v(123m) = 9.990000e+02
MacSpice 4 -> print \"123m\"
"123m" = 9.990000e+02
MacSpice 5 ->


There are a number of pre-defined constants in Nutmeg. The values in MacSpice (version 3.1.19 et seq.) include yes/no, true/false, and:

 pi π, 3.14159... e The base of natural logarithms, 2.71828... i The square root of −1 c The speed of light, 299792458 m s−1 kelvin Absolute zero in centigrade, −273.15 °C echarge The elementary charge, 1.602176634×10−19 C boltz Boltzman's constant, 1.380649×10−23 J K−1 planck Planck's constant, 6.62607015×10−34 J Hz−1

These are all in SI units. Constants should normally be referred to by including the plotname, e.g. 'const.boltz幸运飞艇超稳计划群', because this will avoid clashes with homonymous variables in the current plot. The above values are recommended exact values for adoption by SI and differ slightly from those used in the original Berkeley Spice 3 and previous versions of MacSpice. It is possible to delete, or modify the values of, the pre-defined vectors in the 'const' plot but this is not normally wise.

there are a number of pre-defined constants in nutmeg. they are:

 pi π (3.14159...) e The base of natural logarithms (2.71828...) c The speed of light (299,792,500 m/s) i The square root of −1 kelvin Absolute zero in centigrade (−273.15°C) echarge The elementary charge (1.6021918×10−19 C) boltz Boltzman's constant (1.3806226×10−23 J/K) planck Planck's constant (6.626200×10−34 J/Hz)

### 5.2 COMMAND INTERPRETATION

If 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 argc and argv are set to the number of words following the filename on the command line, and a list of those words respectively. After the file is finished, these variables are unset. Note that if one command file calls another, it must save its argv and argc幸运飞艇超稳计划群 since they are altered. Also, command files may not be re-entrant since there are no local variables. (Of course, the procedures may explicitly manipulate a stack...) This way one can write scripts analogous to shell scripts for Nutmeg and Spice 3.

Note that for the script to work with Spice 3, 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 /usr/local/lib/spice/scripts (or whatever the path is on your machine), and the default sourcepath includes this directory, so you can use these command files (almost) like built-in commands.

### 5.3 COMMANDS

#### 5.3.1 Ac*: Perform an AC, small-signal frequency response analysis

General form:

     ac [ dec | oct | lin ] N Fstart Fstop


Perform an ac analysis. See the previous sections of this manual for more details.

#### 5.3.2 Alias: Create an alias for a command

General form:

     alias [word] [text ... ]


Causes word to be aliased to text. History substitutions may be used, as in C-shell aliases.

#### 5.3.3 Alter*: Change a device or model parameter

General form [3f4]:

     alter dev = expression
alter dev param = expression
alter @dev[param] = expression


Alternative 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, either give the name of a vector or start the vector with '(', followed by the values in the vector separated with semicolons, and end with ')'.

Appendix B幸运飞艇超稳计划群 lists the 'input' parameters for each model that can be modified by 'alter'.

#### 5.3.am Altermod*: Change a model parameter

General 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 Berkeley Spice 3f4.]

#### 5.3.ap Applescript: Compile and run Applescript

General form:

	applescript [-x] [-v] [-r resvar] line1 [line2 ...]


Example of usage:

	applescript -x -r result 'say "Hello"' 'return { 123, 456 }'


This command facilitates interaction with other Mac applications. Each line of the script must be appropriately quoted so that it is treated as a single token when parsed. If the '-x' modifier is present the script will be compiled and executed, otherwise the lines will be sent to the application for inspection/testing. The '-r' modifier sets the associated variable resvar to a list of the results. The first element of resvar is used to indicate whether an error has occurred. If so, the second element of resvar幸运飞艇超稳计划群 will be an error message.

	set result = "date"


#### 5.3.4 Asciiplot: Plot values using old-style character plots

General 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, because asciiplot uses a simple-minded linear interpolation.

#### 5.3.5 Aspice: Asynchronous Spice run

General 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 report

General 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 directory

General 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 vector

General form:

     compose name values value1 [ value2 ... ]
compose name parm = val [ parm = val2 ... ]


In the second form possible values for parm are as follows.

for vectors with equally-spaced points:

 start Value at which the vector should start. stop Value at which the vector should end. center Value at the midpoint of the vector. lin Number of points, linearly spaced. step Difference between sucessive elements. span Span (start–stop) of values.

for vectors with logarithmically-spaced points:

 start Value at which the vector should start. stop Value at which the vector should end. center Value at the midpoint of the vector. log Number of points, logarithmically spaced. ratio Ratio between sucessive elements. range Range (stop/start) of values. dec Number of points per decade.

 unif Number of random points (uniform [0,1) distribution). gauss Number of random points (Gaussian distribution). mean Mean of the Gaussian distribution, default=0. sd Standard deviation of the Gaussian distribution, default=1.

 cdf Vector tablulating the distribution. binned Number of random points (discrete distribution) smooth Number of random points (continuous distribution)

The vector defining cdf幸运飞艇超稳计划群 must be non-decreasing and real, with the first element zero and the last element unity.

The MacSpice (v3.1.20) generates random variates using . By default, this is seeded with but the seed can be set explicitly using the srandom command below.

[note: the 'compose' command was not fully implemented in berkeley spice 3, however it can be a viable way to create a vector from a list of values in a portable manner.]

#### 5.3.cs Cross: Create a vector

General 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 vector1[n] will be the value of the first element of vecname. If n is a vector only the real part of its first element is used.

#### 5.3.8 Destroy: Delete a data set

General form:

     destroy [ all | plotname [ plotname2 ... ] ]


#### 5.3.9 Dc*: Perform a DC-sweep analysis

General form:

     dc source vstart vstop vincr [ source2 vstart2 vstop2 vincr2 ]


Perform a dc transfer curve analysis. See the previous sections of this manual for more details.

#### 5.3.10 Define: Define a function

General 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


These are pre-defined in Nutmeg, but can be modified or removed with undefine, if required.

     define max(x,y) maximum(transpose(x;y))
define min(x,y) minimum(transpose(x;y))


They may be supplemented with versions that handle additional arguments, e.g.:

     define max(x,y,z) maximum(transpose(x;y;z))


#### 5.3.dt Deftype: Define type of plot or vector

General form:

     deftype v vectype units
deftype p plottype pattern [ pattern ... ]


Define addtional vector and plot types. The first form refers to vectors, for example:

     MacSpice 1 -> deftype v money USD
MacSpice 2 -> let cost = 0.15 * vector(10)
MacSpice 3 -> settype money cost
MacSpice 4 -> plot cost vs vector(10)


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.dc Delcirc*: Delete a circuit

General form:

     delcirc [ cktname | "" | all ]


Deletes the most recent circuit with a title starting with cktname from the list of available circuits and recovers the memory it was using. The delcirc command without an argument prints a menu of available circuits. Use the empty string, "", to match the current circuit.

#### 5.3.11 Delete*: Remove a trace or breakpoint

General form:

     delete [ all | [ debug-number ... ] ]


Delete the specified breakpoints, traces and saves. The debug numbers are those shown by the status command (unless you use status > file, in which case the debug numbers are not printed).

#### 5.3.12 Diff: Compare vectors

General form:

     diff plot1 plot2 [ vec ...]


compare all the vectors in the specified plots, or only the named vectors if any are given. if there are different vectors in the two plots, or any values in the vectors differ significantly, the differences are reported. the following variables are used to determine what is meant by a significant difference:

 diff_abstol absolute current tolerance, diff_reltol relative tolerance, diff_vntol absolute voltage tolerance.

#### 5.3.13 Display: List known vectors and types

General 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 [default 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 (e.g. unlet time幸运飞艇超稳计划群), an arbitrary member of the remaining vectors becomes the new default scale.

#### 5.3.di Disto*: Perform a small-signal distortion analysis

General form:

     disto [ dec | oct | lin ] N Fstart Fstop [ F2OVERF1 ]


Perform a distortion analysis. See the previous sections of this manual for more details.

#### 5.3.du Dump: Print node voltages

General form:

     dump


#### 5.3.14 Echo: Print text

General 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 circuit

General form:

     edit [ file ]


Print the current Spice 3 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 analysis

General form:

     fourier fundamental [ expression ...]


Performs a Fourier analysis of each expression given, reporting the first ten (including the DC component) multiples of the fundamental frequency (or the first nfreqs, if that variable is set - see below). The output is like that of the .FOUR analysis. The expression is commonly a vector name but 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. However, this will give erroneous results if the time scale is not monotonic.

The Fourier analysis is performed over the interval <TSTOPperiod, TSTOP>, where TSTOP was the final time specified for the transient analysis, and period is one period of the fundamental frequency. For reasonable accuracy, the TMAX parameter (see tran) should be set to no greater than 0.1/(fundamental×nfreqs), and smaller for high-Q幸运飞艇超稳计划群 circuits.

#### 5.3.ga Gather: Indexed read from a vector

General form:

      gather dst src map


Gather adds the elements of src specified by the vector map, which must be real-valued, to the destination dst. Values in map that exceed the bounds of src are ignored. Arguments are interpreted as 1-d vectors. If dst does not exist it is created with elements that are initially zero.

this command is useful because indexed access to vectors is relatively slow. for example, the code-equivalent of the scatter command:

        let n = min( length(map), length(dst) )
let j = 0
while ( j < n )
if ( map[j] >= 0 )
let dst[j] = dst[j] + src[ map[j] ]
endif
let j = j + 1
endwhile


can take ca 1500 times as long to execute for large vectors.

See also the scatter and reshape commands.

#### 5.3.17 Hardcopy: Save a plot to a file for printing

General 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 format, and can be printed by either the [unix] plot(1) program or lpr(1) with the -g flag. The following variables modify the format of the output:

 hcopydev If this is set, when the hardcopy command is run the resulting file is automatically printed on the printer named hcopydev with the command lpr -Phcopydev -g file. hcopydevtype This variable specifies the type of the printer output to use in the hardcopy command. The recognized types are: plot5 postscript svg If variable hcopydevtype is not set, format is assumed. When used in conjunction with hcopydev, hcopydevtype should specify a format supported by the printer. hcopyfont This variable specifies the font name for output plots. The value is used verbatim in the emitted PostScript and SVG but is ignored by the plot5 format. hcopyfontsize Sets the font size in points to be used. hcopyheight Sets the height in points for the generated plot. hcopypscolor Enables color PostScript generation when set. hcopywidth Sets the width in points for the generated plot

#### 5.3.18 Help: Print summaries of Spice 3 commands

General 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 commands

General form:

     history [ -r ] [number]


Print out the history, or the last number commands typed at the keyboard.

Note: in Spice 3 version 3a7 and earlier, all commands (including ones read from files) were saved. The -r option reverses the printing order. [See also the appendix describing history substitutions in commands.]

#### 5.3.20 Iplot*: Incremental plot

General form:

     iplot [ node ...]


Incrementally plot the values of the nodes while Spice 3 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 runs

General 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 vector

General 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. 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.

    MacSpice 4 -> myvec = 0.15 * yourvec


to abbreviate

 	MacSpice 4 -> let myvec = 0.15 * yourvec


because MacSpice 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.

#### 5.3.23 Linearize*: Interpolate to a linear scale

General 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 Spice 3 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 circuit

General form:

     listing [ logical | physical | deck ] [ expand ]


General 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.no Nodesets*: Create a file of .nodeset statements

General form:

     nodesets [ filename ]


save the state of the current analysis as a file of nodeset commands suitable for inclusion in a netlist. this is useful in cases where the operating point is difficult to find.

#### 5.3.ns Noise*: Perform a noise analysis

General 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 analysis

General 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 display

General form:

     plot exprs [ylimit ylo yhi] [xlimit xlo xhi] [xindices xilo xihi]
[xcompress comp] [xdelta xdel] [ydelta ydel]
[vs xname] [xlabel word] [ylabel word]
[title word] [samep] [nointerp] [gridstyle] [plotstyle]


Plot the given exprs on the screen (if you are on a graphics terminal). The xlimit and ylimit arguments determine the high and low x- and y-limits of the axes, respectively. The xindices arguments determine what range of points are to be plotted - everything between the xiloth point and the xihith point is plotted. The xcompress argument specifies that only one out of every comp points should be plotted. For linear axes, if an xdelta or a ydelta parameter is present, it specifies the spacing between grid lines on the x- and y-axis. These parameter names may be abbreviated to xl, yl, xind, xcomp, xdel, and ydel respectively.

The xname argument is an expression to use as the scale on the x-axis. The xlabel and ylabel幸运飞艇超稳计划群 arguments cause the specified labels to be used for the x- and y-axes, respectively.

If samep is given, the values of the other parameters (other than xname) from the previous plot, hardcopy, or asciiplot command is used unless re-defined on the command line.

The displayed curves are interpolated between points using a polynominal of degree polydegree if that variable is set, or 1. The nointerp keyword disables interpolation between points.

The title argument is used in the place of the plot name in the graph caption.

The plotstyle may be one of the following values:

 linplot Plot points joined by lines. pointplot Plot points using unjoined symbols. multiplot Plot points using symbols joined by lines. combplot Plot points by drawing a vertical line from each to the x-axis.

The gridstyle幸运飞艇超稳计划群 may be one of the following values:

 lingrid Override a default log-scale plot, such as the output for an AC analysis, without tranforming the data. linear Synonym for 'lingrid'. xlog Logarithmic x-axis vs linear y-axis. ylog Logarithmic y-axis vs linear x-axis. loglog Logarithmic x- and y-axes. smith Smith plot – data is transformed by the function (x−1)/(x+1). smithgrid Polar plot with a Smith grid but without transforming the data. polar Plot the real and imaginary parts using polar coodinates. nogrid A linear plot with axis labels but no gridlines.

#### 5.3.28 Print: Print values

General 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 Analysis

General form:

     pz node1 node2 node3 node4 { cur | vol } { pol | zer | pz } [ vector | scalar ]


Performs a pole-zero analysis of the current circuit, as described earlier.

#### 5.3.29 Quit: Leave Spice 3 or Nutmeg

General form:

     quit


#### 5.3.30 Rehash: Reset internal hash tables

General 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 analysis

General 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 effect 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 vector

General 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.

the elements in a multidimensional vector are stored in row-major order. this command does not alter the order of values in memory, only the dimensions meta-data.

#### 5.3.33 Resume*: Continue a simulation after a stop

General form:

     resume


Resume a simulation after a stop or interruption (control-C).

#### 5.3.34 Rspice: Remote Spice submission

General 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 Spice 3 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 Spice 3 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 file

General form:

     run [ rawfile ]


Run the analyses specified by dotcommands 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 effects of the set or alter幸运飞艇超稳计划群 commands would be reversed. This is no longer the effect.

[Note. Interactive commands specified using the .control/.endc mechanism are not executed by this command.]

#### 5.3.36 Rusage: Resource usage

General form:

     rusage [ resource ...]


 all Everything below. elapsed Elapsed wall-clock time since the last 'rusage elapsed' call. totalelapsed Total elapsed wall-clock time. faults Number of page faults and context switches. space Data space used. cputime CPU time used since the last 'rusage cputime' call. totalcputime Total CPU time used so far. temp Operating temperature. tnom Temperature at which device parameters were measured.   equations Circuit Equations time Total Analysis Time totiter Total iterations accept Accepted timepoints rejected Rejected timepoints   loadtime Time spent loading the circuit matrix and RHS. reordertime Matrix reordering time lutime L-U decomposition time solvetime Matrix solve time   trantime Transient analysis time tranpoints Transient timepoints traniter Transient iterations trancuriters Transient iterations for the last time point (listed incorrectly as "Transient iterations per point") tranlutime Transient L-U decomposition time transolvetime Transient matrix solve time   everything All of the above.

#### 5.3.37 Save*: Save a set of outputs

General form:

      save [ all | output ...]


Save a set of output vectors, 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.sc Scatter: Indexed write to a vector

General form:

      scatter dst map src


Scatter adds the elements of src to the locations in dst specified by the vector map, which must be real-valued. Values in map that exceed the bounds of dst are ignored. Arguments are interpreted as 1-d vectors. If dst does not exist it is created with elements that are initially zero.

this command is useful because indexed access to vectors is relatively slow. for example, the code-equivalent of the scatter command:

        let n = min( length(map), length(src) )
let j = 0
while ( j < n )
if ( map[j] >= 0 )
let dst[ map[j] ] = dst[ map[j] ] + src[j]
endif
let j = j + 1
endwhile


can take ca 1500 times as long to execute for large vectors.

See also the gather and reshape commands.

#### 5.3.38 Sens*: Run a sensitivity analysis

General 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 variable

General 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'.

#### 5.4.5 If - Else - End

General form:

     if condition
statement
...
else
statement
...
end [ if ]


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 Label

General 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 Goto

General 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). This limitation can be avoided by using the 'begin/end' structure:

    begin
statement
...
end [ begin ]


#### 5.4.8 Continue

     continue [ n ]


If there is a while, dowhile, repeat, or foreach block enclosing this statement, control passes to the test, or in the case of foreach, the next value is taken. Otherwise an error results. The optional argument n幸运飞艇超稳计划群, default value 1, specifies how many levels of enclosing blocks the statement affects.

#### 5.4.9 Break

General form:

     break [ n ]


If there is a while, dowhile, repeat, or foreach enclosing this statement, control passes out of the block. Otherwise an error results. The optional argument n幸运飞艇超稳计划群, default value 1, specifies how many levels of enclosing blocks the statement affects.

#### 5.4.10 Assert: Interrupt execution if a condition is not true

General form:

     assert condition


No action is taken if condition evaluates to 'true'. Otherwise an interrupt, equivalent to typing ctl-C at the console, is raised. This will cause scripts to issue a diagnostic message and, normally, abort.

#### 5.4.11 User Interrupts

In MacSpice, user interrupts (e.g. by typing Command-'.') set the variable interrupt幸运飞艇超稳计划群. This allows scripts that repeatedly execute analyses to behave appropriately when interrupted. For example:

    begin
...
unset interrupt
while 1
tran 1u 500u 0 4u
if ($?interrupt) goto escape endif endwhile ... label escape ... end  The begin/end block in this example is explained in §5.4.7 above. ### 5.5 VARIABLES The operation of both Nutmeg and Spice 3 may be affected by setting variables with the "set" command. In addition to the variables mentioned below, the set command in Spice 3 also affects 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:  appendwrite Append output to the rawfile, if one already exists, e.g. when a write command is issued. colorN These variables determine the colors used, if X is being run on a color display. N may be between 0 and 17. Color 0 is the background, color 1 is the grid and text color, and colors 2 through 17 are used in order for vectors plotted. The value of the color variables should be the RGB encoded colour, e.g. 'rgb:00/88/FF'. consolebackground Sets the background colour for the console window. The color represented by this variable is hex-encoded RGB, e.g. 'rgb:FF/FF/FF' for white. consoleforeground Sets the foreground (i.e. font) colour for the console window. The color represented by this variable is hex-encoded RGB, e.g. 'rgb:00/00/FF' for blue. cpdebug Print command-interpreter debugging information. debug If set then a lot of debugging information is printed. device The name (/dev/tty??) of the graphics device. If this variable isn't set then the user's terminal is used. To do plotting on another monitor you probably have to set both the device and term variables. (If device is set to the name of a file, nutmeg dumps the graphics control codes into this file — this is useful for saving plots.) dpolydegree If dpolydegree is N > 0, then the deriv() function fits a degree N polynomial to every set of N+1 points and uses their coefficients to calculate the derivative values. The default value is 2. echo Print out each command before it is executed. fourgridsize How many points to use for interpolating into when doing Fourier analysis. gridsize If this variable is set to an integer, this will be the number of equally spaced points to use for the X-axis when plotting. Otherwise, the current scale is used (which may not have equally spaced points). If the current scale isn't strictly monotonic, then this option has no effect. gridstyle If set, its value is used as the default gridstyle, refer to the description of the plot command for recognised values. hcopy... The format of hardcopy output is controlled by variables with names beginning 'hcopy...'. These are described above in the hardcopy command section. hcopydev If this is set, when the hardcopy command is run the resulting file is automatically printed on the printer named hcopydev with the command lpr -Phcopydev -g file. hcopydevtype This variable specifies the type of the printer output to use in the hardcopy command. If hcopydevtype is not set, format is assumed. The standard distribution currently recognizes postscript as an alternative output format. When used in conjunction with hcopydev, hcopydevtype should specify a format supported by the printer. hcopyfont This variable specifies the font name for hardcopy output plots. The value is device dependent. hcopyfontsize This is a scaling factor for the font used in hardcopy plots. height The length of the page for asciiplot and print col. history The number of events to save in the history list. interrupt Set by user interrupts (i.e. typing Command-'.'). ipolydegree If ipolydegree is N > 0, then the integral() function fits a degree N polynomial to every set of N+1 points and uses their coefficients to calculate the integral values. The default value is 2. linestyleN These variables determine the line-styles used for plots. The thickness and/or dash-pattern N may be between 0 and 19. The axes and grid use linestyle0 and linestyle1 respectively, linestyles 2 through to 17 are used in sequence for plotting vectors. For example, set linetyle2 = 2 set linetyle3 = 4:1:1:1 set linetyle4 = 2/4:1:1:1 define a double-width (solid) line, a (single width) dash-space-dot-space pattern and a combined width and dash pattern. Linestyles scale with the pensize in use. lprplot5 This is a style format string used to specify the command to use for sending -style plots to a printer or plotter. The first parameter supplied is the printer name, the second parameter supplied is a file name containing the plot. Both parameters are strings. This is a style format string used to specify the command to use for sending plot(5)-style plots to a printer or plotter. It is trivial to cause Spice 3 to abort by supplying a unreasonable format string. lprps This is a style format string used to specify the command to use for sending PostScript plots to a printer or plotter. The first parameter supplied is the printer name, the second parameter supplied is a file name containing the plot. Both parameters are strings. It is trivial to cause Spice 3 to abort by supplying an unreasonable format string. noasciiplotvalue Don't print the first vector plotted to the left when doing an asciiplot. nobreak Don't have asciiplot and print col break between pages. noclobber Don't overwrite existing files when doing IO redirection. noglob Don't expand the global characters '*', '?', '[', and ']'. This is the default. nomoremode If nomoremode is not set, whenever a large amount of data is being printed to the screen (e.g, the print or asciiplot commands), the output is stopped every screenful and continues when a carriage return is typed. If nomoremode is set then data scrolls off the screen without check. nonomatch If noglob is unset and a global expression cannot be matched, use the global characters literally instead of complaining. nopadding Don't pad vectors with zeros to equalize lengths when writing rawfile output. noprintscale Don't print the scale in the leftmost column when a print col command is given. nosort Don't have display sort the variable names. numdgt The number of significant digits to print when printing tables of data (fourier, print col). The default precision is 6 digits. If the value to be displayed is positive, an extra space or digit may be printed to ensure constant widths in tables. On MacOS, approximately 16 decimal digits are available using double precision, so numdgt should not normally be more than 15. pensize If unset (or 0), the base pen-thickness used to draw is selected automatically and depends on the fontsize used for the graphs. This behaviour is overriden by 'set pensize = N' where 1≤N≤10 is measured in points. plotstyle If set, its value is used as the default plotstyle, refer to the description of the plot command for recognised values. pointchars defines the symbols to be used for plotting points in a graph, e.g. 'set pointchars = "abc"' polydegree The degree of the polynomial that the plot command should fit to the data. If polydegree is N, then nutmeg fits a degree N polynomial to every set of N+1 points and draws 10 intermediate points in between each endpoint. If the points aren't monotonic, then it tries rotating the curve and reducing the degree until a fit is achieved. polysteps The number of points to interpolate between every pair of points available when doing curve fitting. The default is 10. processor Unless set to something by the user, returns one of the following values identifying the processor and memory architecture: PPC_32, PPC_64, i386, x86_64 and UNKNOWN. Additional values may be added in future. program The name of the current program (argv[0]). prompt The prompt, with the character '!' replaced by the current event number. rawfile The default name for rawfiles created. remote_shell Overrides the name used for generating rspice runs (default is "rsh"). rhost The machine to use for remote Spice 3 runs, instead of the default one (see the description of the rspice command, below). rprogram The name of the remote program to use in the rspice command. slowplot Stop between each graph plotted and wait for the user to type return before continuing. sourcepath A list of the directories to search when a source command is given. The default is the current directory and the standard Spice library (/usr/local/lib/spice, or whatever LIBPATH is #defined to in the Spice 3 source). specdegree If specdegree is N > 0, then the spec command fits a degree N polynomial to every set of N+1 points and uses the interpolated values to calculate the spectrum. The default value is 3. spicepath The program to use for the aspice command. The default is /cad/bin/spice. term The mfb name of the current terminal. ticlist A list of points to highlight with a mark on a linear plot. ticmarks 'set ticmarks = n' will highlight every nth point on a linear plot. units If this is unset, or set to radians, then functions will treat angles as being measured in radians. The default 'spinit' startup script sets it to degrees. unixcom If a command isn't defined, try to execute it as a UNIX command. Setting this option has the effect of giving a rehash command, above. This is useful for people who want to use nutmeg as a login shell. unwraptol The tolerance (default 0.25, value must be in the range [0,1]) used by the unwrap() function when deciding whether a jump is large enough to be a wrap. vectors Unless set to something by the user, returns a list of the vectors. verbose Be verbose. This is midway between echo and debug / cpdebug. [Note: not implemented in Spice 3. CDHW] width The width of the page for asciiplot and print col. x11lineararcs Some X11 implementations have poor arc drawing. If you set this option, Spice 3 will plot using an approximation to the curve using straight lines. xbrushheight The height of the brush to use if X is being run. xbrushwidth The width of the brush to use if X is being run. xfont The name of the X font to use when plotting data and entering labels. The plot may not look good if this is a variable-width font. $ The current process (pid) number.

there are several set variables that spice 3 uses but nutmeg does not. they are:

 editor The editor to use for the edit command. modelcard The name of the model control line (normally .MODEL). noaskquit Do not check to make sure that there are no circuits suspended and no plots unsaved. Normally Spice-3 warns the user when he tries to quit if this is the case. nobjthack Assume that BJTs have 4 nodes. noparse Don't attempt to parse input files when they are read in (useful for debugging). Of course, they cannot be run if they are not parsed. nosubckt Don't expand subcircuits renumber Renumber input lines when an input file has .INCLUDE's. subend The control line to end subcircuits (normally .ENDS). subinvoke The prefix to invoke subcircuits (normally X). substart The control line to begin subcircuits (normally .SUBCKT).

### 5.6 MISCELLANEOUS

If there are subcircuits in the input file, Spice 3 expands instances of them. A subcircuit is delimited by the control lines .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 double-, single-, and back-quote substitution (e.g. "foo", 'foo', foo) 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 tries 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 (rounded to numdgt figures) of the variable. If$foo is a valid variable, and is of type list, then the expression $foo[n] returns the nth element and$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. The notation$?&foo can be used to test whether a vector foo already exists.

History substitutions, similar to C-shell history substitutions, are also available – see Appendix D 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 wild-card 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 BUGS

the maximum length of an interactive command line is approximately 510 characters.

the 'print' command lists the elements of a multidimensional vector sequentially with a single index number.

the 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.

     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. another issue with user-defined functions is that a complex value formed with the ',' operator, such as (2,3), is misinterpreted as a pair of values when used as an argument.

If you type plot all all幸运飞艇超稳计划群, or otherwise use a wild-card 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.

     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.

Spice 3 recognizes all the notations used in Spice2 .PLOT幸运飞艇超稳计划群 control lines, 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 trace, iplot, etc. yet.