Documentation /  Analog Insydes /  Reference Manual /  Expanding Subcircuits and Device Models /

IntroductionContents

3.4.1 ExpandSubcircuits

Command structure of ExpandSubcircuits.

Given a Netlist or Circuit object, ExpandSubcircuits expands all model references and stores model definitions to the global model data base. It returns a Netlist object. Expanding subcircuits is taken care of automatically by CircuitEquations, so that there is usually no need to call ExpandSubcircuits explicitly nor to take care of its options.

ExpandSubcircuits has the following options:

Options for ExpandSubcircuits, Part I.

Options for ExpandSubcircuits, Part II.

Options Description

A detailed description of all ExpandSubcircuits options is given below in alphabetical order:

AutoloadModels

With the option AutoloadModels, you can specify how ExpandSubcircuits handles references to device models which have not been loaded into the global subcircuit database or defined locally in the netlist. The following values are possible:

Values for the AutoloadModels option.

DefaultSelector

With the option DefaultSelector, you can specify the key used by ExpandSubcircuits to replace the right-hand sides of generic device model selector specifications in netlists generated with ReadNetlist. The setting DefaultSelector -> selector causes all generic selectors to be replaced by the key selector. Possible values are:

Values for the DefaultSelector option.

Usually ExpandSubcircuits is automatically called by CircuitEquations which sets the DefaultSelector option to an appropriate value based on the chosen analysis mode.

HoldModels

With HoldModels -> patterns, you can specify a list of Mathematica patterns matching the names and selectors of model references ExpandSubcircuits should not expand. Note that the application of the HoldModels option is only necessary for advanced tasks. Usually there is no need to use this option.

A practical application of the HoldModels option is to stop expansion of a hierarchical circuit description at the device level. The function ReadNetlist makes use of this feature to assign small-signal data read from a simulator output file to individual devices in a circuit which contain subcircuit definitions. The following values are allowed:

Values for the HoldModels option.

KeepLocalModels

When you expand the model references in a Circuit only partially using the HoldModels option, then the held model references may still contain unresolved links to local model definitions and model parameter sets. By default, local model data is discarded after subcircuit expansion, so that essential information for expanding the netlist completely may be lost. The setting KeepLocalModels -> True tells ExpandSubcircuits to keep local model data for future reference. Note that for usual applications there is no need to change the default value of this option. Possible values are:

Values for the KeepLocalModels option.

Examples

Load Analog Insydes.

In[1]:= <<AnalogInsydes`

Import PSpice netlist.

In[2]:= buffer = ReadNetlist[
"AnalogInsydes/DemoFiles/Buffer.cir",
Simulator -> "PSpice"]

Out[2]=

The following call to ExpandSubcircuits results in an error because the model "BJT/AC" needs to be loaded from the model library.

Turn off model autoloading.

In[3]:= ExpandSubcircuits[buffer, DefaultSelector -> AC,
AutoloadModels -> False]

Out[3]=

With AutoloadModels -> True, ExpandSubcircuits searches the model library for undefined device models.

Load undefined models from the library.

In[4]:= ExpandSubcircuits[buffer, DefaultSelector -> AC,
AutoloadModels -> True, Protocol -> Notebook]

Out[4]=

The following command tells Analog Insydes to load a model from the library into memory and store it in the global subcircuit database for future reference. Further requests for the model "BJT/AC" will not invoke a library search.

Load the model "BJT/AC" and store it in the global subcircuit database.

In[5]:= Circuit[
LoadModel["BJT", "AC", Scope -> Global]
] // ExpandSubcircuits;

List the contents of the global subcircuit database.

In[6]:= GlobalSubcircuits[]

Out[6]=

Now that the model "BJT/AC" has been loaded into memory, turning off the autoloading mechanism no longer results in an error when expanding the netlist buffer.

Use only model definitions from the subcircuit database; do not search the library.

In[7]:= ExpandSubcircuits[buffer, DefaultSelector -> AC,
AutoloadModels -> False, Protocol -> Notebook]

Out[7]=

Clear the subcircuit database.

In[8]:= RemoveSubcircuit[All]

Out[8]=

To illustrate how to write patterns for HoldModels, we make a list off all Model and Selector specifications in the netlist buffer.

List the Model and Selector specifications.

In[9]:= Cases[buffer, _Model | _Selector, Infinity] // InputForm

Out[9]//InputForm= {Model["BJT", "Q2N2222", "Q$T1"], Selector["BJT", "Q2N2222", "Q$T1"], Model["BJT", "Q2N2907A", "Q$T3"], Selector["BJT", "Q2N2907A", "Q$T3"], Model["BJT", "Q2N2907A", "Q$T4"], Selector["BJT", "Q2N2907A", "Q$T4"], Model["BJT", "Q2N2907A", "Q$T5"], Selector["BJT", "Q2N2907A", "Q$T5"], Model["BJT", "Q2N2222", "Q$T2"], Selector["BJT", "Q2N2222", "Q$T2"]}

You can use HoldModels to prevent expansion of a particular device type or model instance.

Do not expand references to "Q2N2222" devices.

In[10]:= ExpandSubcircuits[buffer,
DefaultSelector -> AC, Protocol -> Notebook,
HoldModels -> Model[_, "Q2N2222", _]]

Out[10]=

If you want to flatten a netlist completely after partial expansion, you must specify KeepLocalModels -> True to prevent local model definitions and parameter sets from being discarded by ExpandSubcircuits.

Keep the transistor instance "Q$T3" and references to "Q2N2222" devices; do not discard local model card data for these devices.

In[11]:= xbuffer = ExpandSubcircuits[buffer,
DefaultSelector -> AC, Protocol -> Notebook,
HoldModels -> {{Model[_, "Q2N2222", _], _},
{Model[__, "Q$T3"], _}},
KeepLocalModels -> True]

Out[11]=

Expand the held model references.

In[12]:= ExpandSubcircuits[xbuffer,
DefaultSelector -> AC, Protocol -> Notebook]

Out[12]=

IntroductionContents