Electronic – .SUBCKT command in SPICE

spice

In the User’s Guide and Reference of SPICE I see this definition of .SUBCKT command

.SUBCKT SubcircuitName N1 [N2 N3 ... NN ]

As I can understand SubcircuitName and the first node of the subcircuit are mandatory.

I have a spice file which is valid (it is from working program).

.SUBCKT intrpsr_inv8 GND! IIN1 IIN2 IIN3 IN IOUT1 IOUT2 IOUT3 IVDD OUT SLL_IN1
+ SLL_IN2 SLL_IN3 SLL_OUT1 SLL_OUT2 SLL_OUT3 VDD
.ENDS intrpsr_inv8

.SUBCKT inv7 GND! IN OUT
.ENDS inv7

.SUBCKT top_inv8
XI3  GND! NET33 NET18 inv7
XI4  GND! NET12 NET39 inv7
XI5  GND! NET22 NET23 inv7
XI2  GND! NET33 NET12 NET22 IN NET18 NET39 NET23 NET24 OUT NET34 NET10 NET26
+ NET34 NET38 NET41 NET24 intrpsr_inv8
.ENDS top_inv8

The third .SUBCKT command has only SubcircuitName but not the first node of the subcircuit.
How can it be explained?

Best Answer

.SUBCKT is a macro function, meaning that when encountered it gets substituted. .LIB is similar but for long term files.

Node names within a .SUBCKT have local scope (Except GND).

Node names on the same line as .SUBCKT are the external node names.

subckt's are called using X prefix.

Your SPICE deck above for top_inv8 is saying, "This is a standalone cell, made up of 3 inv7's and 1 intrpsr_inv8.

Who ever wrote this gave that cell the name of Top, this is the cell that is at the very top level of the design.