Sub Circuit Models and Parameters

.subckt models support the passing of parameters from the component instance to its subckt model. These parameters can be used in mathematical expressions. This allows generic subckt models to be customized for specific applications.

.subckt schematic symbol input parameters may be directly set from the schematic symbol's properties setup dialog, "Labels" tab. There is a text parameter field where the parameters can be set. e.g.

Parameters: ind=1.2e-6 res=3k3 cap=10n

Each symbol instance of the .subckt will use its own parameter list set in its own properties dialog setup. Nominal values in the actual .subckt model will be ignored.

Parameters may also be defined within the .subckt itself by the use of the key word ".params"

Parameters of .subckt params: and .param:

The following syntax is allowed:

.subckt name 1 2 ind=1.2e-6 res=3k3 cap=10n
.param z={x*sin(ind)*2}
.param res_value1=10k res_value2=20k res_value3=30k
r1 1 2 {x+ln(y)} TC1={r/z}
r2 1 2 {res_value1/res_value2 * res_value3}
c1 1 2 {cap * z}
B1 1 2 i={x+y}*v(1,2) + v(3,2)*{z+y} + {z}
.ends
.subckt name 1 2 params: x=1.2 y=4.3
.param z=x*sin(y)*2
.param p=2.4 r=8.54
r1 1 2 {x+ln(y)}
c1 1 2 {x*y} IC={p}
b1 1 2 v=v(1,2)*{x/y} + 2*v(1) +{z}
.ends

That is, the PSpice originated syntax statement of "params:" is not necessary and may be omitted from the main title line. All schematic symbol input parameters must be placed on the first line. Continuation lines are not supported.

Equations between brackets "{}" will be evaluated and passed onto the engine. Most normal mathematical expressions can be used, but note that powers are calculated by x^y, the PSpice syntax of pow(x,y) is not supported. Parameters in expressions must be fully resolved prior to their use. They are evaluated in order from top to bottom of the file.

The brackets "{}" are not necessary for .param variable setting lines. They are only required in netlist lines

If an internal to subckt .param uses an expression, only one variable may be defined on that line.

If an internal to subckt .param sets a variable to a contestant, then several variables may be set on one line.

Parameters passed in from the subckt dialog box may be in multiplier format such as, 1.2k, 3.6u

Parameters statements contained within the .subckt model .param

.param lines may be included in the .subckt to further define common parameters to be used in subsequent expressions, as in the example above. These parameters are not changeable via the schematic and must be set directly in the .subckt.

.param lines within the subckt may be mathematical expressions of the input parameters.

Checking Expression Evaluation

Expansion of parameters may be checked by viewing the "Model" file passed onto the XSpice engine. To view this file, press the pink "M" toolbar button. This file will contain each instance of the subckt with all expression evaluated to pure numbers. Each instance of the subckt will have a modified name containing its parameters in its name.

Expression Evaluation

The following constants are defined in the mathematical expression evaluator, and can not be used as variables of a different value.

pi, e, 2pi, radian, k_boltzmann, q_electron, c_light, h_plank, mu_0, e_0

The following mathematical functions are supported

sin(), cos(), tan(), asin(), acos(), atan(), sinh(), cosh(), tanh(), asinh(), acosh(), atanh(), exp(), log(), ln(), sqrt(), floor(), ceil(), abs(), deg(), rad(), rand(), db()

Pin Current Probing

DC and Transient pin currents are implemented by the automatic insertion of 0V DC voltage sources in series to the .subckt model pins.

The input pin names have the character "!" as a delimiter flag pre-appended to the original names when this is done. This character is checked to identify that voltage sources have been added. Manually adding a "!" will prevent the voltage sources being inserted. This may be useful when minimizing the number of nodes in order to reduce simulation time

Node name expansion restrictions

Do not "V" , "v" , "+" or "-" as the first letter of pin/node names. This will sometimes result in simulation failure.

Do not use "V" , "v" , "+" or "-" as subckt pin/node names. This will sometimes result in simulation failure.

The component symbol pin names are not restricted.

Nested Subckts

For all of the features in SuperSpice to work correctly, the main .subckt model must contain all of the subcircuits that it references within its enclosing .subckt/.ends. This may require some manufactures model files to be modified. SuperSpice re-expands these nested .subckts before it passes them to the engine. It is possible to to use a manual included include file as is, but this may defeat some SuperSpice functionality.

Nested subckts name expansion restrictions

Most times subckts/.ends can be nested deeper. i.e one .subckt can contain another .subckt/.ends section. However, there are some core engine bugs in expansion of names within nested defined .subckts. that sometimes cause such nested definitions to fail. A workaround is to use the "PO" and select flatten .subckt netlists. This is the preferred method.

Another workaround, if the above fails, i.e. this option only works for one level of subckt within another subckt, is to manual remove the nested .subckt/ends from its enclosing .subckt/ends and paste that .subckt into the SuperSpice include file, i.e. the pink "I" button.

A typical error report for this is:

a:2::3:$poly$fb: unknown controlling source v:2::3:b

Contents