<< Click to Display Table of Contents >> Navigation: Designing a PCB with DEX > Projects > Circuit Simulation > The Spice Reference Manual > Circuit Description > Sub-circuits |
A sub circuit that consists of SPICE Simulation Program for Integrated Circuit Emulation. elements can be defined and referenced in a fashion similar to device models. The sub circuit is defined in the input file by a grouping of element lines; the program then automatically inserts the group of elements wherever the sub circuit is referenced. There is no limit on the size or complexity of sub-circuits, and sub-circuits may contain other sub-circuits. An example of sub circuit 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 sub circuit 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 sub circuit. The last line in a sub circuit definition is the .ENDS line (see below). Control lines may not appear within a sub circuit definition; however, sub circuit definitions may contain anything else, including other sub circuit definitions, device models, and sub circuit calls (see below). Note that any device models or sub circuit definitions included as part of a sub circuit definition are strictly local (i.e., such models and definitions are not known outside the sub circuit 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 sub circuit definition. The sub circuit name, if included, indicates which sub circuit definition is being terminated; if omitted, all sub-circuits being defined are terminated. The name is needed only when nested sub circuit definitions are being made.
Subcircuit Calls
General form:
XYYYYYYY N1 <N2; N3 ...> SUBNA
Examples:
X1 2 4 17 3 1 MULTI
Sub-circuits are used in SPICE by specifying pseudo-elements beginning with the letter X, followed by the circuit nodes to be used in expanding the sub circuit.