.SUBCKT

As an aid to defining a circuit, repetitive circuitry
can be enclosed in a subcircuit definition and used as
multiple instances in the same circuit. Before the
simulation runs, the circuit is expanded to a flat
netlist by replacing each invocation of a subcircuit
with the circuit elements in the subcircuit
definition. There is no limit on the size or
complexity of subcircuits.

The end of a subcircuit definition must be a .ends
directive.
Here is an example using a subcircuit:
*
* This is the circuit definition
X1 a b 0 divider
V1 a 0 pulse(0 1 0 .5μ .5μ 0 1μ)
* this is the definition of the subcircuit
.subckt divider n1 n2 n3
96
r1 n1 n2 1k
r2 n2 n3 1k
.ends
.tran 3μ
.end
Which runs after expanding to
* Expand X1 into two resistor network
r:1:1 a b 1k
r:1:2 b 0 1k
*
v1 a 0 pulse(0 1 0 .5μ .5μ 0 1μ)
.tran 3μ
.end
Note that unique names based on the subcircuit name
and the subcircuit definition element names are made
for the circuit elements inserted by subcircuit
expansion.

Leave a Reply

What is 6 + 8 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)