Circuit Description Overview
Circuit Description Overview
Nodes names may be arbitrary character strings. The datum (ground) node must be named '0'. Note the difference in SPICE3 where the nodes are treated as character strings and not evaluated as numbers, thus '0' and '00' are distinct nodes in SPICE3 but not in SPICE2. The circuit cannot contain a loop of voltage sources and/or inductors and cannot contain a cut-set of current sources and/or capacitors. Each node in the circuit must have a dc path to ground. Every node must have at least two connections except for transmission line nodes (to permit unterminated transmission lines) and MOSFET substrate nodes (which have two internal connections anyway).
The title line must be the first in the input file. Its contents are printed verbatim as the heading for each section of output. .End line Examples:
.END
The "End" line must always be the last in the input file. Note that the period is an integral part of the name. Comments General Form:
* <any; comment>
Examples:
* RF=1K Gain should be 100 * Check open-loop gain and phase margin
The asterisk in the first column indicates that this line is a comment line. Comment lines may be placed anywhere in the circuit description. Note that SPICE3 also considers any line with leading white space to be a comment.
DEVICE MODELS
General form:
.MODEL MNAME TYPE(PNAME1=PVAL1 PNAME2=PVAL2 ... )
Examples:
.MODEL MOD1 NPN (BF=50 IS=1E-13 VBF=50)
Most simple circuit elements typically require only a few parameter values. However, some devices (semiconductor devices in particular) that are included in SPICE require many parameter values. Often, many devices in a circuit are defined
by the same set of device model parameters. For these reasons, a set of device model parameters is defined on a separate .MODEL line and assigned a unique model name. The device element lines in SPICE then refer to the model name. For these more complex device types, each device element line contains the device name, the nodes to which the device is connected, and the device model name. In addition, other optional parameters may be specified for some devices: geometric factors and an initial condition (see the following section on Transistors and Diodes for more details). MNAME in the above is the model name, and type is one of the following fifteen types:
Semiconductor resistor model Semiconductor capacitor model Voltage controlled switch Current controlled switch Uniform distributed RC model Lossy transmission line model Diode model NPN BJT model PNP BJT model N-channel JFET model P-channel JFET model N-channel MOSFET model P-channel MOSFET model N-channel MESFET model P-channel MESFET model
C SW CSW URC LTRA D NPN PNP NJF PJF NMOS PMOS NMF PMF
Parameter values are defined by appending the parameter name followed by an equal sign and the parameter value. Model parameters that are not given a value are assigned the default values given below for each model type. Models, model parameters, and default values are listed in the next section along with the description of device element lines.
SUBCIRCUITS
A subcircuit that consists of SPICE elements can be defined and referenced in a fashion similar to device models. The subcircuit is defined in the input file by a grouping of element lines; the program then automatically inserts the group of elements wherever the subcircuit is referenced. There is no limit on the size or
complexity of subcircuits, and subcircuits may contain other subcircuits. An example of subcircuit usage is given in \\*(AA. .SUBCKT General form:
.SUBCKT subnam N1 <N2; N3 ...>
Examples:
.SUBCKT OPAMP 1 2 3 4
A circuit definition is begun with a .SUBCKT line. SUBNAM is the subcircuit name, and N1, N2, ... are the external nodes, which cannot be zero. The group of element lines which immediately follow the .SUBCKT line define the subcircuit. The last line in a subcircuit definition is the .ENDS line (see below). Control lines may not appear within a subcircuit definition; however, subcircuit definitions may contain anything else, including other subcircuit definitions, device models, and subcircuit calls (see below). Note that any device models or subcircuit definitions included as part of a subcircuit definition are strictly local (i.e., such models and definitions are not known outside the subcircuit definition). Also, any element nodes not included on the .SUBCKT line are strictly local, with the exception of 0 (ground) which is always global. .ENDS General form:
.ENDS <SUBNAM;>
Examples:
.ENDS OPAMP
The "Ends" line must be the last one for any subcircuit definition. The subcircuit name, if included, indicates which subcircuit definition is being terminated; if omitted, all subcircuits being defined are terminated. The name is needed only when nested subcircuit definitions are being made. Subcircuit Calls General form:
XYYYYYYY N1 <N2; N3 ...> SUBNA
Examples:
X1 2 4 17 3 1 MULTI
Subcircuits are used in SPICE by specifying pseudo-elements beginning with the letter X, followed by the circuit nodes to be used in expanding the subcircuit.
Examples:
.INCLUDE /users/spice/common/wattmeter.cir
Frequently, portions of circuit descriptions will be reused in several input files, particularly with common models and subcircuits. In any spice input file, the ".include" line may be used to copy some other file as if that second file appeared in place of the ".include" line in the original file. There is no restriction on the file name imposed by spice beyond those imposed by the local operating system.