In the previous topic, 3.0.1 What Happens When You Press F9?, you followed the process of netlist creation and netlist preprocessing to generate the final simulation deck file. In that topic you followed the expression {Rload} from symbol to netlist to the deck file where the expression {Rload} was evaluated and replaced with the numeric value 2.5.
In this topic you will learn how subcircuits can be defined in a library and how the netlist preprocessor copies these subcircuit definitions to the deck file. The netlist preprocessor searches the installed libraries for any subcircuit not already contained in the netlist, then copies the subcircuit definition from the library and inserts the definition into the deck file. Additionally, any parameters and expressions in the model definition are evaluated, resulting in the final model used in the simulation.
To download the examples for Module 3, click Module_3_Examples.zip
In this topic:
This topic addresses the following key concepts:
In this topic, you will learn the following:
Almost all complex devices made up of more than a single primitive device are implemented as subcircuits. In this topic you will learn how subcircuits, when combined with parametrization, can be extremely powerful.
In this exercise you will follow the path of the electrolytic output capacitor C1 from schematic symbol to netlist to deck file definition. The electrolytic capacitor model is built-into SIMetrix/SIMPLIS as a subcircuit library device. The preprocessor will copy the definition of the electrolytic capacitor from the library, preprocess any .IF and .ELSE statements in the model, and evaluate any expressions. The resulting text entered into the deck will have purely numerical values.
The Edit Properties dialog allows you to view or edit all properties for a
symbol. Symbol properties determine the instantiation line created in the netlist.
Two properties are of particular interest:<ref> <nodelist> %PARAM_MODEL_NAME% vars: %VALUE%
During the netlist process, the SIMPLIS_TEMPLATE property is resolved by the netlister. The netlister evaluates the template keywords enclosed in the greater-than and less-than brackets and substitutes literal properties enclosed in the percent signs, such as %PARAM_MODEL_NAME% and %VALUE%. Text which is not enclosed in the special characters, % and <>, is interpreted as literal text, and is passed on to the netlist without modification. There are several other template keywords, for a complete list, see: Template Property. Next, open the netlist file and find the netlist entry for C1.
The netlist entry created by the SIMPLIS_TEMPLATE is called the
instantiation, and this terminology will be used throughout the rest of the
course. The SIMPLIS_TEMPLATE and the netlist instantiation for C1 has five distinct
pieces, or tokens. These tokens are: | SIMPLIS_TEMPLATE Token | Netlist Value |
| <ref> | X$C1 |
| <nodelist> | 17 0 |
| %PARAM_MODEL_NAME% | ELEC_CAP_L13 |
| vars: | vars: |
| %VALUE% | LEVEL=2 CC={1m*Gauss(0.20)} RSH_CC=1Meg IC=5 RESR=40m LESL=5n USEIC=1 |
The instantiation for C1 defines a number of things:
| Parameter Name | Parameter Value |
| LEVEL | 2 |
| CC | {1m*Gauss(0.20)} |
| RSH_CC | 1Meg |
| IC | 5 |
| RESR | 40m |
| LESL | 5n |
| USEIC | 1 |
A key concept to understand is that the instantiation only defines which model is used, it's connectivity, and the optional parameters used. The electrical model definition is stored in one of the locations listed in item 3 above.
At this point the only thing missing is the actual definition for the electrolytic capacitor. In the next exercise you will view the model for the subcircuit capacitor ELEC_CAP_L13.

The model text defines the electrolytic capacitor model used by the every electrolytic capacitor symbol on this schematic. Note the distinction between a model and a symbol. The symbol creates a netlist instantiation line; the model is the electrical definition that is called by the instantiation.
Every subcircuit definition in SIMPLIS begins with a .subckt statement, and ends with a .ends statement. As with almost everything in SIMetrix/SIMPLIS, the text is not case sensitive.
The first line defines the "subcircuit interface", that is:
The netlist contains three electrolytic capacitor instantiations, with reference designators C1, C2, and C7. The two entries for C1 and C2 are:

In the next exercise you will see how the netlist preprocessor creates custom subcircuits for C1 and C2.
Notice the difference between the netlist and deck file instantiations as shown in the below:
| Netlist |
|
| Deck |
|
The two differences are ...
Next, look at the subcircuit definitions for the two subcircuits called by the deck instantiations for C1 and C2.
To search for ELEC_CAP_L13$1 in the netlist editor, follow these steps:
The capacitor C1 is a Level 2 capacitor - meaning the capacitor is a network of an ideal capacitor, a shunt resistance, and a series resistance. The parameters passed into the subcircuit are used to both determine the schematic configuration of the subcircuit capacitor, as well as to set the values for each circuit element. Note: Extra parameters can be passed into the subcircuit at the netlist stage. In this case, the LESL parameter is not used by the subcircuit after the preprocessor has been run, because there is logic contained in the model that keys off the value of the LEVEL parameter. This logic determined that the equivalent series inductor was not to be included in the final simulation deck file.
The subcircuit definition for the capacitor C2 immediately precedes the subcircuit for C1. Note the subcircuit contains the same devices, connected to the same subcircuit net numbers, but the circuit element values are different.
The following slideshow shows the netlist preprocessor as it steps through the model definition from the library, and generates the actual subcircuit. Note that the netlist preprocessor eliminates any blank lines and all comment lines which begin with an asterisk.