SPICE Syntax

Title line

The title line must be the first line in the input file and is required. Its contents will be printed verbatim as the heading for each section of output.

.END line

The “.END” line must always be the last in the input file and is required.

Comments

The asterisk in the first column indicates that the line is a comment line. Comment lines may be placed anywhere in the circuit description.

.SUBCKT line

A circuit definition begins with a “.SUBCKT” line. The subcircuit name is identified by “SUBNAM” and “N1, N2...” are the external nodes, which cannot be zero. The general form of this line as follows:

.SUBCKT SUBNAM N1 <N2 N3...>

The group of element lines, which immediately follows the “.SUBCKT” line, defines the subcircuit. The last line in a subcircuit definition is the “.ENDS” line. Control lines may not appear within a subcircuit definition. Subcircuit definitions may contain anything else, including other subcircuit definitions, device models and subcircuit calls. Any device models or subcircuit definitions included as part of a subcircuit definition are strictly local (that is such models and definitions are not known outside the subcircuit definition). In addition, any element nodes not included on the “.SUBCKT” line are strictly local, with the exception of 0 (ground) which is always global.

.ENDS line

The “.ENDS” line must be the last one for any subcircuit definition and has the following general form:
.ENDS <SUBNAM>

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 defining nested subcircuits.

.INCLUDE lines

Portions of circuit descriptions will often be reused in several input files by using the “.INCLUDE” line with the following general form:
.INCLUDE filename
Commonly used models and subcircuits can be copied as if the copied file appeared instead of the “.INCLUDE” line in the main file. There is no restriction on the file name imposed by SPICE beyond those imposed by the local operating system.

Resistors

Resistors can be included as follows:
RXXXXXXX N1 N2 VALUE

“N1” and “N2” are the two element values. “VALUE” is the resistance (in Ohm) and may be positive or negative, but not zero.

Capacitors

Capacitors can be included as follows:
CXXXXXXX N+ N- VALUE

“N+” and “N-” are the positive and negative element nodes respectively and “VALUE” is the capacitance in Farad.

Inductors

Inductors can be included as follows:
LXXXXXXX N+ N- VALUE

“N+” and “N-” are the positive and negative element nodes respectively and “VALUE” is the capacitance in Henry.

Coupled (Mutual) Inductors

Coupled inductors can be included as follows:
KXXXXXXX LYYYYYYY LZZZZZZZ VALUE

“LYYYYYYY” and “LZZZZZZZ” are the names of the two coupled inductors. The parameter “VALUE” is the coefficient of coupling, K, which must be greater than zero and less than or equal to one.

Lossless transmission lines

Lossless transmission lines can be included as follows:
TXXXXXXX N1 N2 N3 N4 Z0=VALUE <TD=VALUE> <F=FREQ <NL=NRMLEN>

“N1” and “N2” are the nodes at port one while “N3” and “N4” are the nodes at port two. “Z0” is the characteristic impedance. “N2” and “N4” are usually used as the ground connections of the transmission line.

The length of the line may be expressed in either of two forms. The transmission delay, “TD”, may be specified directly (for example as “TD=10 ns”). Alternatively, a frequency F may be given, together with “NL”, the normalised electrical length of the transmission line with respect to the wavelength in the line at the frequency “F”. If a frequency is specified but “NL” is omitted, a value of 0.25 is assumed (that is the frequency is assumed to be the quarter-wave frequency). Although both forms for expressing the line length are indicated as optional, one of the two must be specified.