Understanding the Netlist Template
The Netlist Template allows access to the information that is entered into the XSpice netlist for a given component. It is accessed by clicking on the Netlist Template tab, at the bottom of the Sim Model dialog.
For all of the predefined model kinds and sub-kinds, the Netlist Template is read-only. If, however, one of these predefined entries does not allow enough control over the information placed in the netlist, you can define your own template.
To edit the Netlist Template, you need to select Generic Editor in the Model Sub-Kind region of the Sim Model dialog - ensuring that the Model Kind field is first set to General. This will be the default model kind/sub-kind setting when adding a new simulation model to a schematic component. For all other General model sub-kinds, you can effectively change to Generic Editor and edit the predefined template - massaging it to your own requirements.
When defining the Netlist Template, the information entered should be in accordance with the requirements of SPICE3f5/XSpice and the syntax rules described below.
Netlist Template Syntax
Characters that are entered into the template are written to the XSpice netlist verbatim, except for the following special characters:
% | percent sign |
@ | commercial at |
& | ampersand |
? | question mark |
~ | tilde |
# | number sign |
These characters are translated when creating the netlist, as shown in the following table:
Syntax in Netlist Template... | Netlister replaces with... |
---|---|
@<param> | Value of <param>. An error is raised if a parameter of this name does not exist or if there is no value assigned to it. |
&<param> | Value of <param>. No error is raised if the parameter is undefined. |
?<param>s...s | Text between s...s separators if <param> is defined. |
?<param>s...ss...s | Text between first s...s separators if <param> is defined, else the second s...s separators. |
~<param>s...s | Text between s...s separators if <param> is NOT defined. |
~<param>s...ss...s | Text between first s...s separators if <param> is NOT defined, else the second s...s separators. |
#<param>s...s | Text between s...s separators if <param> is defined, but ignore the rest of the template if <param> is NOT defined. |
#s...s | Text between s...s separators if there is any text to be entered into the XSpice netlist from subsequent entries in the Netlist Template. |
%<pin id> | The net name of the net to which the schematic pin mapped to <pin id> connects. |
%% | A literal percent character. |
In the above table,
- s represents a separator character (, . ; / |).
- <param> refers to the name of a parameter.
If the parameter name contains any non-alphanumeric characters, it should be enclosed in double quotes. For example:
@"DC Magnitude"
- double quotes used here because the name contains a space.
&"Init_Cond"
- double quotes used here because the name contains an underscore.
Double quotes should also be used when you wish to add an alphanumeric prefix to a parameter name. For example:
@"DESIGNATOR"A
- the use of the double quotes ensures that A is appended to the component designator.
Syntax Examples
The following are examples of the special character syntax entries in the previous table. Information is given in each case, about how the syntax entry is translated by the Netlister.
@"AC Phase"
The parameter name AC Phase is enclosed in braces because of the space. This will be replaced in the netlist with the value of the AC Phase parameter. If there is no parameter of this name, or its value is blank then an error will be given.
&Area
If a parameter named Area exists and has a value, then it's value will be entered into the netlist. If the parameter is undefined (i.e. either it does not exist or has no value assigned) then nothing will be written to the netlist, but no error will be raised. This can be used for optional parameters.
?IC|IC=@IC|
If the parameter named IC is defined then the text within the || separators will be inserted into the netlist. For example if the parameter IC had value 0.5 then IC=0.5 would be inserted into the netlist in place of this entry. If the parameter is undefined then nothing will be inserted into the netlist.
?IC/IC=@IC//IC=0/
This is the same as the previous example, except that if the parameter IC is undefined then IC=0 will be inserted into the netlist. Note also that a different separator character has been used.
~VALUE/1k/
If a parameter named VALUE is NOT defined then the text 1k will be inserted into the netlist.
~VALUE/1k//@VALUE/
This is the same as the previous example, except that if the parameter VALUE is defined then its text value will be inserted into the netlist.
#"AC Magnitude"|AC@"AC Magnitude"|@"AC Phase"
This example can be seen in the predefined netlist template for the sinusoidal voltage source.
If the AC Magnitude parameter has been defined then the contents of the separators is evaluated and inserted into the netlist. All following entries in the netlist are also evaluated and entered into the netlist (in this case @"AC Phase").
If for example AC Magnitude=1 and AC Phase=0 then AC 1 0 will be inserted into the netlist. If, however, AC Phase was undefined, an error would be raised.
If the parameter AC Magnitude is undefined then nothing following the #"AC Magnitude" entry in the netlist template will be entered into the netlist.
#|PARAMS:|?Resistance|Resistance=Resistance|?Current|Current=@Current|
This example can be seen in the predefined netlist template for a parameterized subcircuit (see F1 in Fuse.PrjPcb).
If the Resistance and Current parameters are both undefined then there will be no text to be inserted into the netlist following the #|PARAMS:| entry, so the text in the separators will be omitted also.
If for example the parameters have values Resistance=1k and Current=5mA then this will result in text following the #|PARAMS:| entry and PARAMS: Resistance=1k Current=5mA will be the entry made in the netlist.
@DESIGNATOR%1%2@VALUE
This example is to demonstrate the use of the % character.
If for example the parameters have values DESIGNATOR=R1 and VALUE=1k, and the pins are mapped on the Port Map tab of the Sim Model dialog according to the following table:
Schematic Pin | Model Pin | Net name to which Schematic Pin connects |
---|---|---|
1 (N+) | 1 (1) | GND |
2 (N-) | 2 (2) | OUT |
Then the text R1 GND OUT 1k will be placed into the XSpice netlist for this component.
Checking the Netlist Template
To check the Netlist Template, simply click on the Netlist Preview tab at the bottom of the Sim Model dialog. The text displayed in this tab is exactly as it will be written to the XSpice netlist file when a netlist is generated or a simulation is run. The following exception applies:
- If you are in the Schematic Library Editor, or the document/project has not been compiled, the net names that the model pins map to will not be available. In this case, the schematic pin designators are inserted, enclosed in <> braces.
Any errors that occur while parsing user-defined entries in the Netlist Template will also be displayed, so that any errors can be resolved prior to exiting the dialog.