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
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
r1 n1 n2 1k
r2 n2 n3 1k
.tran 3?
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?
Note that unique names based on the subcircuit name
and the subcircuit definition element names are made
for the circuit elements inserted by subcircuit

Leave a Reply