The Spice Parser
This document describes the function of the software unit that reads a Spice file and stores its connectivity (with parameters) to the hierarchical database ZDB for later processing. It supports different Spice dialects and is not picky on syntax variances, but on the other side does not necessarily find/report all errors. The Spice parser can also save modified attributes back to the Spice file.
Overview
Introduction
In addition of using the SpiceVision PRO GUI to read Spice files either the stand alone binary spice2zdb
or the Tcl command zspice
can be used.
The spice2zdb
binary reads the given Spice file and creates a binfile containing the connectivity of the input file:
spice2zdb -o binfile.zdb <OPTIONS> <FILE.SP>
The zspice
Tcl command reads the given Spice file and returns the created in-memory database.
set db [zspice <OPTIONS> <FILE.SP>]
The Tcl command is available in the Console window of the SpiceVision PRO GUI.
This document describes the usage of this flow.
In addition to that, zspice
also supports another mode for updating previously parsed Spice file(s) - as described in the section Save Attributes to Spice Files.
Options
Option | Parameters | Description |
---|---|---|
|
Add top I/O ports from connectivity. |
|
|
Read cmdline arguments from file. |
|
|
Remove hierarchy if subckt has one device. |
|
|
Remove hierarchy if subckt has no device. |
|
|
Avoid shorted out ports and make them inout. |
|
|
Open this binfile as a precompiled library. |
|
|
Stop on errors during parsing. |
|
|
Create net wires and display bulk connections. If the mode is |
|
Read the input file as a Calibre netlist. |
||
Read the input file as a CDL netlist. |
||
|
Connect matching net by name, i.e. don’t route it. |
|
|
Name of the created top sub-circuit. |
|
|
Create hierarchy from flat instance names. Split the instance names at the given hierarchy separator. If the given hierarchy separator character is an empty string then the hierarchy separator character is guessed. |
|
|
Enable a specific debug flag. |
|
|
Define a subckt to be used as a device. In contrast to -subckt2dev here the port mapping defines the function of the ports.The port mappings consist of a comma separated list of pairs with the primitive port name and the function separated with an equal sign. E.g. -definedevice "nmos_macro" "NMOS" "s=SOURCE,b=BULK,d=DRAIN,g=GATE". |
|
Don’t cut long filenames in messages. |
||
|
The value |
|
Read the input file as an Eldo netlist. |
||
|
Evaluate parameters. |
|
|
Evaluate AC voltage sources to top input ports. |
|
|
Evaluate DC voltage sources to power. |
|
|
Expand subckt after parser has finished. |
|
|
Input Spice file is interpreted as a library file. |
|
Overwrite existing symbols with the symbols from the given symbol library files (option -symlib). |
||
|
Define global ground node (this option can be repeated multiple times). |
|
|
Group instances with same basename before given separator. |
|
|
Guess buses based on net and port names with a bit subscript enclosed in the given 'open' and 'close' characters. |
|
|
Guess instance arrays based on instance names with a bit subscript enclosed in the given 'open' and 'close' characters. |
|
|
Guess macro model devices. |
|
|
Guess power/ground nets connected to bulks. |
|
Print a help text with a short description of each option. |
||
|
Hide subckt power/ground ports. |
|
|
Set the desired hierarchy separator 'hiersepchar' of your choice. Any character can be used. To be able to identify the hierarchy separator, a character that is not already used in an identifier should be used. |
|
Read the input file as a HSpice netlist. |
||
|
Add comments to instances. |
|
|
Ignore (remove) capacitors if the threshold value is lower or equal than the specified number (in Farad, Spice units accepted). Additionally a glob style model name prefixed by 'model:' can be used to ignore all instances of the specified model. |
|
|
Case-insensitive parser. |
|
|
Ignore duplicate includes. |
|
|
Define an include directory (this option can be repeated multiple times). |
|
|
Level of verbosity for issued messages. |
|
|
Compile the given files into an already existing database. |
|
|
Add attributes for layout coordinates. |
|
Append to logfile. |
||
|
Generate log file. |
|
Read the input file as an LTSpice netlist. |
||
|
Merge parallel transistors into one. |
|
|
Merge parallel capacitors into one. |
|
|
Merge parallel diodes into one. |
|
|
Variation to treat device values as equal for the merge parallel options (enter a value between 0.0 and 1.0). |
|
|
Merge parallel instances of matching cells. Details are described here. |
|
|
Merge parallel resistors into one. |
|
|
Merge serial transistors into one. |
|
|
Merge serial capacitors into one. |
|
|
Merge serial resistors into one. |
|
|
Define a model. |
|
|
Name of the multiplier attribute for parallel devices (default is "M"). |
|
|
Define global negpower node (this option can be repeated multiple times). |
|
|
Define input/output or power/ground node per subckt. |
|
Don’t search for a hierarchy separator. |
||
Don’t perform include commands. |
||
Print no greeting message. |
||
|
Name of the zdb output binfile. |
|
|
Define global power node (this option can be repeated multiple times). |
|
Print progress information. |
||
Read the input file as a PSpice netlist. |
||
|
Control power propagation of the Spice parser. Propagation of power can be turned off, go all the way down the hierarchy or stop if the name of the power node changes. |
|
|
Define a range in the file to read. |
|
|
Recognize transistors that form a gate. |
|
|
Create box for non recognized groups. |
|
|
Create supply ports on recognized gates. |
|
|
Fold recognized gates using one of the following methods: Use 'nofold' to disable folding, use 'fold' to fold all recognized gates, use 'autofold' to fold only recognized gates with equal attribute values and use 'noflat' to fold all recognized gates but do not create flat attributes. |
|
|
Do not recognize gates with transistors in parallel paths. |
|
|
Do not recognize transfer gates. |
|
|
Remove capacitors connected to only one net. |
|
|
Remove empty modules. |
|
|
Remove leading chars from inst names. |
|
|
Remove spurious MOS transistors (e.g. if the gate pin is connected to power/ground, if all pins are dangling or shortened, etc.). |
|
|
Remove resistors connected to only one net. |
|
|
Suffix for renaming duplicate cells. |
|
|
Resolve duplicate cells. If "off" all duplicate cells are renamed. |
|
|
Ignore (short-cut) resistors if the threshold value is lower or equal than the specified number (in Ohm, Spice units accepted). Additionally a glob style model name prefixed by 'model:' can be used to ignore all instances of the specified model. |
|
Read the input file as a Spectre netlist. |
||
Read the input file as a Spice2 netlist. |
||
Read the input file as a Spice3 netlist. |
||
|
Set the Spice dialect for the input file. |
|
|
Create source code references. |
|
|
Exclude object from collection spos info |
|
|
Define a subckt to be used as a device. Ports must match the sequence defined for the function. E.g. -subckt2dev "nmos_macro" "NMOS". |
|
|
Suppress messages which match pattern. |
|
Preload symbol library file(s) given with the -symlib option. |
||
|
Specify a symbol library file. |
|
|
Define three term devices. |
|
Print CPU time consumption (requires enabled progress updates). |
||
|
Define this module as the top module. If * is set, then all unreferenced cells are used as top. |
|
Validate DB before creating the zdb output file. |
||
|
Wait 'sec' seconds for a license. If the value is -1 then the started tool will not wait for the next free license. Use a value of 0 to wait forever. |
What the Spice Parser Does
The parser reads the input files twice. In the first pass subckt and model names are processed. The second pass handles instances and nodes. Details of the Spice parsing depends on the selected Spice dialect: one of SPICE2, SPICE3, PSPICE, HSPICE, CDL or Calibre, identified by "2", "3", "P", "H" or "C" respectively (see right-most column in the tables device types, Spice models, comments, control and sub-circuits below — a "*" is a wild-card that matches all dialects).
Most of the instance parameters are added as instance attributes (with identical names). Some special instance and cell attributes are created by the Spice parser, they are described in the section "Special Attributes Created by the Spice Parser" below.
Interpretation of Spice Device Types
Spice example |
Created database objects |
Dialect |
|
---|---|---|---|
Prim Name |
Description |
||
|
_RES_ |
creates an instance of the built-in RES primitive called "_RES_". The given unnamed parameter value is added as instance attribute "R=value". If the value is less than 100 ohm the weakflow flag is set. If there is a TC parameter, two instance attributes are created, "TC1" storing the first value and "TC2" storing the second value. |
* |
|
model |
creates an instance of a RES primitive called model with two pins. Parameters like R and TC are created as instance attributes, the TC parameter is handled as described above. |
* |
|
_CAP_ |
creates an instance of the built-in CAP primitive called "_CAP_". The given unnamed parameter value is added as instance attribute "C=value". The TC parameter is handled as described at the R element above. |
* |
|
model |
creates an instance of a CAP primitive called model with two pins. Parameters like C and TC are created as instance attributes, the TC parameter is handled as described above. |
* |
|
_IND_ |
creates an instance of the built-in INDUCTOR primitive called "_IND_". The given unnamed parameter value is added as instance attribute "L=value". The TC parameter is handled as described at the R element above. |
* |
|
model |
creates an instance of a INDUCTOR primitive called model with two pins. Parameters like L and TC are created as instance attributes, the TC parameter is handled as described above. |
* |
|
_COUPLED_ |
creates an instance of the built-in UNKNOWN primitive called "_COUPLED_" with no pins. The given coef parameter is added as attribute "#COUPLING=coef". The names of the coupled instances are stored in special attributes "$INST1", "$INST2" … |
* |
|
_COUPLED_ |
same as above, but for transmission lines. |
P |
|
model |
creates an instance of the built-in SWITCH primitive with four pins. |
* |
|
model-n |
creates an instance of the built-in UNKNOWN primitive with the given number of pins. The primitive name is a concatenation of the given mname and the number of pins. |
H |
|
model |
creates an instance of a SWITCH primitive called model with two pins. A special attribute "$CTRL=Vn" is added to the instance to refer to the voltage source. |
23PC |
|
model-n |
creates an instance of a UNKNOWN primitive called "model-n", where n is the number of pins. |
H |
|
file-n |
creates an instance of a UNKNOWN primitive called "file-n", where n is the number of pins. |
H |
|
_VSOURCE_ |
creates an instance of the built-in VSOURCE primitive called "_VSOURCE_". A special attribute "$PARAM" will contain all parameters following the two nodes. A "#VOLTAGE" will be added, if the source is identified as a DC voltage source (if the param string has the form "DC 1.2" or "1.2"). A "#GUESSPWR" will be added with a score value between 0 and 100 (how safe the guessing is). |
* |
|
_ISOURCE_ |
creates an instance of the built-in ISOURCE primitive called "_ISOURCE_" or - if the value of the source is "0.0" then "_ZEROISOURCE_". A special attribute "$PARAM=params" will be added, containing all parameters following the two nodes. |
* |
|
_VISOURCE_ |
creates an instance of the built-in ISOURCE primitive called "_VISOURCE_". |
* |
|
_VISOURCE_-n |
creates an instance of the built-in ISOURCE primitive called "_VISOURCE_-n". The integer n is used to determine the number of pins (n = 2k+2). |
* |
|
_ISOURCEB_ |
creates an instance of the built-in ISOURCE primitive called "_ISOURCEB_". |
* |
|
_VISOURCE |
creates an instance of the built-in ISOURCE primitive called "_VISOURCEDELAY_" with four pins. |
* |
|
_PWLISRC_f_-n |
creates an instance of the built-in UNKNOWN primitive called "_PWLISRC_f_-n". The f is one of PWL, NPWL or PPWL depending on the function. The integer n is used to determine the number of node pairs which follow (n = 2k+2). |
H |
|
_ISOURCE_f_-n |
creates an instance of the built-in UNKNOWN primitive called "_ISOURCE_f_-n". The f is one of AND, NAND, OR, NOR depending on the function. The integer n is used to determine the number of node pairs which follow. |
H |
|
_ISOURCE_ |
creates an instance of the built-in ISOURCE primitive called "_ISOURCE_". A special attribute "$PARAM" will contain the keyword (VALUE, TABLE, etc). |
P |
|
_PWLVSRC_-n |
creates an instance of the built-in UNKNOWN primitive called "_PWLVSRC_-n". The integer n is used to determine the number of pins (n = 2k+2). |
H |
|
_VSOURCE_f_-n |
creates an instance of the built-in UNKNOWN primitive called "_VSOURCE_f_-n". The f is one of AND, NAND, OR, NOR depending on the function. The integer n is used to determine the number of node pairs which follow. |
H |
|
_VVSOURCE_ |
creates an instance of the built-in VSOURCE primitive called "_VVSOURCE_". |
* |
|
_VVSOURCE_-n |
creates an instance of the built-in VSOURCE primitive called "_VVSOURCE_-n". The integer n is used to determine the number of pins (n = 2k+2). |
* |
|
_VSOURCE_ |
creates an instance of the built-in VSOURCE primitive called "_VSOURCE_". A special attribute "$PARAM" will contain the keyword (VALUE, TABLE, etc). |
P |
|
creates an instance of the built-in ISOURCE primitive called "_IISOURCE_" or "\_IISOURCE_f". The f is one of "POLY", "PWL", "AND", "NAND", "OR", "NOR" or "_DELAY". The special attributes "$CTRL=V1..Vn" and "#GAIN=gain1..gainn" will be added. |
* |
|
|
creates an instance of the built-in VSOURCE primitive called "_IVSOURCE_" or "\_IVSOURCE_f". The f is one of "POLY", "PWL", "AND", "NAND", "OR", "NOR" or "_DELAY". The special attributes "$CTRL=V1..Vn" and "#TRANS=trans1..transn" will be added. |
* |
|
|
_TRANS_ |
creates an instance of the built-in TRANSLINE primitive called "_TRANS_". The given unnamed parameter value is added as instance attribute "LEN=value". |
* |
|
model |
creates an instance of the built-in TRANSLINE primitive. |
* |
|
model |
creates an instance of the built-in TRANSLINE primitive. |
23HC |
|
The digital devices of pspice generate the corresponding primitive and instance. All pspice digital devices are supported. |
P |
|
|
model-n |
creates an instance of the built-in UNKNOWN primitive called "model-n". Where n is the number of nodes. |
H |
|
model |
creates an instance with three pins. The primitive function is UDRC. |
23C |
|
type |
The given ibis file is searched in the include path and opened. The model is searched in that ibis file. If not found, "IBIS-n" is used, where n is the number of pins. If found, then the found type is used. |
H |
|
model |
creates an instance with three pins. The given unnamed parameter value is added as instance attribute "AREA=value". |
P |
|
_DISOURCE_ |
creates an instance of the built-in ISOURCE primitive called "_DISOURCE_". A special attribute "$PARAM" will contain all parameters following the two nodes. |
23C |
|
_DVSOURCE_ |
creates an instance of the built-in VSOURCE primitive called "_DVSOURCE_". A special attribute "$PARAM" will contain all parameters following the two nodes. |
23C |
|
model |
creates an instance with two pins. The given unnamed parameter value is added as instance attribute "AREA=value". |
* |
|
model |
creates an instance with four pins. If no substrate node is given "0" is used. In pspice square brackets around the substrate node are removed. The given unnamed parameter value is added as instance attribute "AREA=value". |
* |
|
model |
creates an instance with three pins. The given unnamed parameter value is added as instance attribute "AREA=value". |
* |
|
model |
creates an instance with four pins. If the W / L ration is less than 1.0 the weakflow flag is set. |
* |
|
model |
in Hspice the bulk pin is optional. If present it is handled like above else the 4th pin is connected to the net "0", or the net mentioned in the "BULK" attribute of the referenced model. Unnamed parameter values are assigned to the two instance attributes "L" and "W". If the .OPTION WL is found, the values are swapped. |
H |
|
model |
creates an instance of a NPN primitive called model with three pins. |
P |
|
model |
creates an instance of a NMOS or PMOS primitive called model with three pins. |
23HC |
Interpretation of Spice Models
Each ".MODEL" creates a primitive with the given name. If the model is nested in subckts a unique name is created by prepending the subckt names separated by dots. The given type determines the primitive function used. Additional parameter are used to create attributes at the primitive.
At the end of parsing references from the instances to these models are resolved by using the model name given at the instance element. If no model is found, a warning is generated and a primitive function is guessed by looking a the element type and, if needed, by searching a 'P' or 'N' in the model name. The guessed primitive is created.
Model type | Created database objects | D |
---|---|---|
D |
Creates a Diode or, if the BV attribute is less than 100 a ZDiode primitive. |
* |
R |
Creates a Resistor primitive. |
* |
C |
Creates a Capacitor primitive. |
* |
NPN |
Creates a NPN primitive. |
* |
PNP |
Creates a PNP primitive. |
* |
NMF |
Creates a three pin NMOS primitive. |
* |
NIGBT |
Creates a three pin NPN primitive. |
* |
PMF |
Creates a three pin PMOS primitive. |
* |
NMOS |
Creates a four pin NMOS primitive. |
* |
PMOS |
Creates a four pin PMOS primitive. |
* |
SW |
Creates a SWITCH primitive. |
* |
CSW |
Creates a SWITCH primitive. |
* |
LTRA |
Creates a TRANSLINE primitive. |
* |
UDRC |
Creates a UDRCLINE primitive. |
* |
IND |
Creates a IND primitive. |
* |
AMP |
Depending on the presence of a "COMP" parameter a AMP primitive with five or seven pins is created. |
* |
Interpretation of Spice Comments and Logical Lines
Spice example | SPICE Parser Behavior | D |
---|---|---|
|
Lines beginning with '*' are ignored in Spice2 and Spice3. |
23 |
|
Lines beginning with '+' continue lines but not comments in Spice2, Spice3, CDL and Calibre. |
23C |
|
Lines beginning with '*' or after '$' are treated like blanks in Hspice. Leading tabs and blanks are ignored. |
H |
|
Lines beginning with '+' continue lines. Comment lines in between are ignored in HSpice and PSpice. |
HP |
|
Lines ending with a backslash continue lines in HSpice. |
H |
|
Lines beginning with '*' or after ';' are treated like blanks in Pspice. Leading blanks are ignored. |
P |
|
Lines beginning with '*' or after '$' followed by a blank are treated like blanks in CDL and Calibre. |
C |
|
Comment lines can be continued with '*+' in CDL and Calibre. |
C |
|
Control Statements can start with a comment in CDL and Calibre. |
* |
Interpretation of Spice Control Statements
Spice example | Description | D |
---|---|---|
.INCLUDE 'fname' |
Parses the named file. If the given filename is relative it is searched in the following directories: '-incdir' option, the base directory of the current file, the base directory of the main file and the current working directory. |
* |
.LIB 'fname' entry |
Same as .INCLUDE, but source lines outside matching .LIB and .ENDL are ignored. |
* |
.ALTER |
Because the database can only store one alternative, everything after .ALTER is ignored and a warning is issued. |
* |
.CONNECT n1 n2 |
The two given nets get merged at the end of the subckt processing. |
* |
.DATA … |
Everything between these control statements is currently ignored by the spice parser. |
* |
.END |
Everything after .END is ignored. This control statement must be in the main file. If it occurs in an included file a warning message is generated by the parser. |
* |
.GLOBAL n1 … |
All listed node names are added to the list of global nets. In PSpice node names beginning with "$G_" are added automatically to the list of globals. "0", "GND" (Spice3,HSpice,PSpice,CDL), "GND!" and "GROUND" (HSpice) are automatically added to the list of ground nets. In CDL and Calibre an optionally appended ":"-modifier is currently ignored. |
* |
.IF … |
A conditional Spice netlist is currently only supported for constant expressions. The parser will issue a warning, when this control statement occurs in the input stream without a constant expression. |
* |
.MODEL name type |
Creates a primitive with the given name. The interpretation of the type can be found in the Interpretation of Spice Models. |
* |
.OPTION WL |
Changes the order of unnamed parameters at the M elements. |
* |
.OPTION PARHIER=local |
Changes the default priority of the '-evalParams' parameter evaluation. |
* |
.PARAM name[=value] |
All parameters and the optionally values are converted into attributes of the current subckt. Top-level parameters are added to the top-level "sub-circuit". Repeated .PARAM control statements with same name on same subckt level overwrite previous values. |
* |
*.PININFO n1:I n2:O n3:B … |
Searches the ports of the current subckt and sets the direction to In, Out or Inout. |
* |
.PROTECT… |
All lines between these control statements are ignored, because decryption is not supported by the current parser. If the .UNPROT can’t be seen by the parser, because it is hidden in the protected source lines, the first recognized control statement will switch back to unprotected mode. |
* |
Interpretation of Spice Sub-Circuits
Spice example | Created database objects | D |
---|---|---|
|
Creates a sub-circuit with ports p1, p2, etc. All given parameters (here: A, B) are stored at the sub-circuit. |
* |
|
Same as normal .SUBCKT, but ports before the slash ('/') are marked as outputs, ports after the slash are marked as inputs. |
C |
|
Creates an instance with pins connected to the listed nodes. The referenced subckt is resolved by using "name". Attributes following name are added to the instance (see notes). |
23H |
|
Creates an instance with pins connected to the listed nodes. The referenced subckt is resolved by using "name". Attributes following PARAMS: are added to the instance (see notes). |
P |
|
Creates an instance with pins connected to the listed nodes. The referenced subckt is resolved by using "name". Attributes following name are added to the instance (see notes). |
C |
|
Creates an instance with pins connected to the listed nodes. The referenced subckt is resolved by using "name". Connectivity is created by searching the named ports instead of the normal connection by sequence order (see notes). |
C |
Notes for sub-circuit instances: If the name refers to
-
a subckt which has less ports than the instance line, surplus pins are ignored and a warning is issued.
-
a subckt which has more ports than the instance line, surplus pins are left unconnected and a warning is issued.
-
a subckt which is not declared elsewhere, a blackbox is created and a warning is issued.
-
an undeclared subckt, then a file like
name.inc
is searched in the directories defined by the-incdir
search path [HSpice only]. -
an AMP model, the AMP primitive is instantiated instead of a sub-circuit [HSpice only].
Special Attributes Created by the Spice Parser
Depending on the Spice device types some special attributes are created to store information from the Spice file that cannot easily be stored elsewhere. As a general rule, non-numerical attributes (e.g. string values), that do not need optional parameter evaluation get a '$' prefix. Numerical attributes that do not need optional parameter evaluation get a '#' prefix. Cell attributes to control the display of other attributes (meta attributes) get a '@' prefix.
Special attribute | Object | Description |
---|---|---|
AREA |
inst |
unnamed value of D, Q, J, B, Z, M element. |
C |
inst |
unnamed or renamed 'VALUE' attribute of C element. Used to ignore small capacitors with -ignoreCaps option. |
$CONSISTINGOF |
inst |
instance names of transistors merged by -mergeParallel or -mergeSerial option. |
#COUPLING |
inst |
the coupling coefficient see K element. |
$CTRL |
inst |
the name of the controlling element, see W, F or H element. |
#GAIN |
inst |
gain value of controlling source. |
#GUESSPWR |
inst |
probability whether the source is a power source used for power guessing. |
$IC |
inst |
name of vsource in Eldo Y element. |
$ICOMMENT |
inst |
inline comments, mentioned on the same line, if enabled with -icomment option. |
$INITIAL |
inst |
Some elements can switch the initial condition to ON or OFF. In this case the instance attribute "$INITIAL=OFF" is created. |
$INST1 .. $INSTn |
inst |
Instance names of all instances coupled by K element. |
K |
inst |
couple coefficient for voltage controlled transformer vsources in HSpice and Eldo. |
L |
inst |
unnamed attribute of L element. |
MNAME |
inst |
model name of S element in HSpice. |
MODEL |
inst |
model name of Eldo Y element. |
$PARAM |
inst |
all parameters of voltage or current source, which are not parsed in detail. |
PERI |
inst |
unnamed value of D element in CDL. |
R |
inst |
unnamed or renamed 'VALUE' attribute of R element. |
RON, CREC |
inst |
unnamed attribute of S element, in Eldo. |
TC1, TC2 |
inst |
Some elements have multiple TC values, which are split into these separate attributes. |
#TRANS |
inst |
trans value of controlling source. |
$TYPE |
inst |
type (2nd token) of Eldo Y element. |
UMODEL |
inst |
model name of W element in HSpice. |
V1 |
inst |
split IC value of T element. |
VBE |
inst |
initial voltage of Q element. |
VD |
inst |
initial voltage of D element. |
VDS |
inst |
initial voltage of J, Z element. |
VDS |
inst |
initial voltage of M element. |
#VOLTAGE |
inst |
the DC value of a independent vsource, used for power guessing. |
W |
inst |
unnamed values of D element, if there were two unnamed values. |
W |
inst |
unnamed values of J, M element, in CDL. |
W |
inst |
unnamed values of M element, sequence depends on .OPTION WL'. |
LEN |
inst |
unnamed value of T element. |
BULK |
cell |
default name of bulk net. |
BV |
cell |
if value is less than 100 'D' model is treated as ZDiode. |
$MODEL |
cell |
if there is a model specified, the parser creates a "$MODEL=model" cell attribute. This attribute is not created for builtin models like '_RES_'. |
$SUBCKT |
name |
the parser creates a "$SUBCKT=name" attribute with the Spice sub-circuit name. |
$NESTED |
cell |
For cells which are defined in .SUBCKT/.END blocks, the parser creates a "$NESTED=path" attribute. |
$PREFIX |
cell |
prefix like "R" or "MN" used to identify the device function. |
$TYPE |
cell |
model type like "NMOS", "D", "RES" etc. as mentioned in .MODEL. |
@nlv |
cell |
attribute display information. |
#GUESSPWR |
net |
probability of power guess. |
#VOLTAGE |
net |
the guessed voltage of a power net. |
$VSOURCE |
net |
instance name of voltage source of a power net. |
What the Spice Post-Processing Does
Controlled by the options the following modifications on the database are done.
-
power nets and port directions user defined by options are set.
-
sub-circuits are expanded.
-
power nets and port directions are guessed. During this process "$VSOURCE" and "#VOLTAGE" attributes are added to the flagged power nets.
-
power ports get hidden.
-
small resistors are flagged to be removed and the connected nets get merged.
-
parallel capacitors are merged by changing "C" from the first instance to the sum of all. The other instances of each group are flagged for removal.
-
serial resistors are merged by changing "R" from the first instance to the sum of all. The other instances of the group are flagged for removal.
-
parallel transistors are merged by adding a new attribute "$CONSISTINGOF" to the first instance. All other instances of the group are flagged for removal.
-
serial transistors are merged by adding a new attribute "$CONSISTINGOF" to the first instance. All other instances of the group are flagged for removal.
-
during cleanup all flagged instances get deleted from the database.
-
new hierarchy is created if the instances names contain hierarchy separator characters.
-
the hide flag of bulk pins is set dependent on the option settings.
Limitations
The parser tries its best to read most of the input data. It is not a validating parser. This means that wrong input can produce unpredictable results instead of issuing an error or warning.
The following constructs are not implemented.
-
Spectre
-
ahdl_include ignored
-
CPP #include ignored
-
OOM node references (with ".") treated like local nodes
-
modelbinning attributes ignored
-
spice3 ignored
-
userdefined functions
-
ignored keywords: altergroup, correlate, vary, export, for, function, ic, invisible, plot, print, return, save, sense, to, truncate, local, march, paramset, nodeset, pwr, statistics, sweep, montecarlo, reliability, ignored models, assert, bit, node, paramtest, pattern, quantity, ac, alter, check, checklimit, cosim, dc, dcmatch, envlp, hb, hbac, hbnoise, hbsp, info, loadpull, noise, options, pac, pdisto, pnoise, psp, pss, pstb, pxf, pz, qpac, qpnoise, qpsp, qpss, set, shell, sp, stb, stp, tdr, tran, uti, xf, analogmodel, bsource
-
ignored models: analogmodel assert bit bsource node paramtest pattern quantity ac alter check checklimit cosim dc dcmatch envlp hb hbac hbnoise hbsp info loadpull noise options pac pdisto pnoise psp pss pstb pxf pz qpac qpnoise qpsp qpss set shell sp stb stp tdr tran uti xf
-
-
All dialects
-
conditionals with if can only be evaluated, if the Boolean expression only contains constants or top-level parameters
-
Save Attributes to Spice Files
After database attributes have been modified in the database, zspice -save
can be called to update (overwrite) the Spice source file.
Only the instance attributes get updated — all other parts of the Spice file stay character-identical.
This makes the resulting Spice file diff-able against the original one.
The zspice -check
command may be used to check if the modification with -save
is possible.
zspice -save $db
zspice -check $db file.spc
The option -save $db
will save all modified attributes.
The option -check $db spicefile
will check whether the Spice file exists and check several conditions to make sure, the Spice file is ok to get modified.
Here is an usage example that reads the Spice file buf.sp
and adds a new instance attribute test=12
to each device (primitive) and sub-circuit (module) instance.
set db [zspice -hspice buf.sp]
$db foreach module module {
$db foreach inst $module inst {
$db attr $inst add test=12
}
}
zspice -save $db