Subcircuit Definitions (subckt)
Description
Hierarchical Circuit
The subckt statement is used to define a subcircuit. Subcircuit definitions are circuit macros that can be expanded anywhere in the circuit any number of times. When an instance in your input file refers to a subcircuit definition, the instances specified within the subcircuit are inserted into the circuit. Subcircuits may be nested. Therefore, a subcircuit definition may contain instances of other subcircuits. Subcircuits may also contain component, analysis, or model statements. Subcircuit definitions can also be nested, in which case the innermost subcircuit definition can only be referenced from within the subcircuit in which it is defined, and cannot be referenced from elsewhere.
Instances that instantiate a subcircuit definition are referred to as subcircuit calls. The node names (or numbers) specified in the subcircuit call are substituted, in order, for the node names given in the subcircuit definition. All instances that refer to a subcircuit definition must have the same number of nodes as are specified in the subcircuit definition and in the same order. Node names inside the subcircuit definition are strictly local unless declared otherwise in the input file with a global statement.
Subcircuit Parameters
Parameter specification in subcircuit definitions is optional. In the case of nested subcircuit definitions, parameters that have been declared for the outer subcircuit definition are also available within the inner subcircuit definition. Parameters that are specified are referred to by name, optionally followed by an = sign and a default value. If, when making a subcircuit call, you do not specify a particular parameter, this default value is used in the macro expansion. Subcircuit parameters can be used in expressions within the subcircuit consisting of subcircuit parameters, constants, and various mathematical operators. Run spectre -h expressions for details about Spectre expression handling capability. Run spectre -h parameters for details about how Spectre handles netlist parameters, including subcircuit parameters, and how they inherit within nested subcircuit definitions.
Subcircuits always have an implicitly defined parameter m. This parameter is passed to all components in the subcircuit, and each component is expected to multiply it by its own multiplicity factor. In this way, it is possible to efficiently model several copies of the subcircuit in parallel. Any attempt to explicitly define m on a parameters line results in an error. In addition, because m is only implicitly defined, it is not available for use in expressions in the subcircuit.
Inline Subcircuits
An inline subckt is a special case of a subckt where one of the devices or models instantiated within this subckt does not get its full hierarchical name. It instead inherits the subckt call name. An inline subckt is syntactically denoted by the presence of the keyword inline before the subckt. It is called in the same manner as a regular subcircuit. The body of the inline subcircuit can typically contain one of the following, based on different use models:
-
Multiple device instances, one of which is the
inlinecomponent -
Multiple device instances, one of which is
inlineand one or more parameterized models -
A single
inlinedevice instance and a parameterized model to which the device instance refers
The inline component is denoted by giving it the same name as the inline subcircuit. When the subcircuit is flattened, the inline component does not take on a hierarchical name such as X1.M1, it instead takes on the name of the subckt call, such as X1. Any non-inline components in the subckt take on the regular hierarchical name, as if the subcircuit were a regular subckt (that is, not an inline subckt).
Probing the inline device
Spectre allows the following list of items to be saved or probed for primitive devices. These would also apply to devices modeled as the inline components of inline subcircuits:
-
All terminal currents. For example,
save q1:currents -
Specific (index) terminal current. For example,
save q1:1 (#1=collector) -
Specific (named) terminal current. For example,
save q1:b ("b"=base) -
Save all operating point info. For example,
save q1:oppoint -
Save specific operating point info. For example,
save q1:vbe -
Save all currents and oppoint info. For example,
save q1
Parameterized Models and Inline Subckts
Inline subckts can be used in the same way as regular subcircuits to implement parameterized models, however, inline subckts provide some powerful new options. When an inline subcircuit contains both a parameterized model and an inline device that references that model, you can create instances of the device, and each device automatically gets an appropriately scaled model assigned to it. For example, the instance parameters to an inline subckt could represent something like emitter width and length of a BJT device, and within the subckt, a model card that is parameterized for emitter width and length and scales can be created accordingly. When you instantiate the macro, supply the values for the emitter width and length, and a device is instantiated with an appropriate geometrically scaled model. Again, the inline device does not get a hierarchical name and can be probed in the same manner as the inline device in the previous section on modeling parasitics, that is, the inline device can be probed just as if it were a simple device, and not actually embedded in a subckt
Automatic Model Selection using Inline Subckts
See spectre -h if for a description on how to combine Spectres structural if statement with inline subckts to perform automatic model selection based on any netlist/subckt parameter.
For additional information on subcircuits, see Subcircuits in the Spectre Classic Simulator, Spectre APS, Spectre X, and Spectre XPS User Guide.
Definition
[inline] subckt <Name> (<node1> ... <nodeN>)
subckt coax (i1 o1 i2 o2)
parameters zin=50 zout=50 vin=1 vout=1 len=0
inner i1 o1 i2 o2 tline z0=zin vel=vin len=len
outer o1 0 o2 0 tline z0=zout vel=vout len=len
ends coax
Defines a parameterized coaxial transmission line macro from two ideal transmission lines. To instantiate this subcircuit, one could use an instance statement such as:
Coax1 pin nin out gnd coax zin=75 zout=150 len=35m
Example 2: inline subckt - parasitics
Consider the following example of an inline subcircuit, which contains a mosfet instance, and two parasitic capacitances:
inline subckt s1 (a b) // "s1" is name of subckt
parameters p1=1u p2=2u
s1 (a b 0 0) mos_mod l=p1 w=p2 // "s1" is "inline" component
cap1 (a 0) capacitor c=1n
cap2 (b 0) capacitor c=1n
ends s1
The following circuit creates a simple mos device instance M1, and calls the inline subcircuit s1 twice (M2 and M3)
M1 (2 1 0 0) mos_mod
M2 (5 6) s1 p1=6u p2=7u
M3 (6 7) s1
M1 (2 1 0 0) mos_mod
M2 (5 6 0 0) mos_mod l=6u w=7u // the "inline" component, inherits call name
M2.cap1 (5 0) capacitor c=1n // a regular hierarchical name
M2.cap2 (6 0) capacitor c=1n
M3 (6 7 0 0) mos_mod l=1u w=2u // the "inline" component, inherits call name
M3.cap1 (6 0) capacitor c=1n
M3.cap2 (7 0) capacitor c=1n
Here, the final flattened names of the three mosfets (one for each instance) are M1, M2, and M3, rather than M1, M2.s1, and M3.s1 as they would be if s1 was a regular subcircuit. However, the parasitic capacitors (which you may not interested in, or perhaps, even aware of, if the inline subckt definition was written by a different modeling engineer) have full hierarchical names.
Example 3: inline subckt - scaled models
Consider the following example, in which a parameterized model is declared within an inline subcircuit for a bipolar transistor. The model parameters are emitter width, length, and area, and also the temperature delta (trise) of the device above nominal. Ninety-nine instances of a 4*4 transistor are then placed and one instance of a transistor with area=50 is placed. Each transistor gets an appropriately scaled model.
Declare a subckt, which instantiates a transistor with a parameterized model. The parameters are emitter width and length.
inline subckt bjtmod (c b e s)
parameters le=1u we=2u area=le*we trise=0
model mod1 bjt type=npn bf=100+(le+we)/2*(area/1e-12)
+ is=1e-12*(le/we)*(area/1e-12)
bjtmod (c b e s) mod1 trise=trise // "inline" component
ends bjtmod
q1 (2 3 1 0) bjtmod le=4u we=4u // trise defaults to zero
q2 (2 3 2 0) bjtmod le=4u we=4u trise=2
q3 (2 3 3 0) bjtmod le=4u we=4u
.....
.....
q99 (2 3 99 0) bjtmod le=4u we=4u
q100 (2 3 100 0) bjtmod le=1u area=50e-12
Return to top