UNDERSTANDING SPICE MODELS
Overview
A SPICE model is an ASCII netlist file. It contains no graphical information at all and cannot therefore be placed directly on a schematic, so you also need a schematic library part for the device concerned. There is no standard file format for schematic library parts, so unless the part is already in the supplied libraries you will usually need to draw it yourself.
Once you have both halves you have to tell the simulator how they fit together. That is what the rest of this chapter is about, and the sections below explain the two things that make it necessary: the way a model binds its nodes to circuit nodes, and the fact that not every dialect of SPICE in circulation is the same language.
Binding Circuit Nodes to Model Nodes
In a SPICE netlist, a model is called up by referring to a subcircuit using an X card. The binding of circuit nodes to model nodes is determined purely by the order in which the circuit nodes are given on that card. For example:
XU1 46 43 32
means that node 46 of the circuit is connected to node 1 of the model, node 43 binds to node 2 and node 32 binds to node 3.
Unfortunately this scheme means that the model nodes are not named. Worse still, there is rarely any tie up between the model node numbers and the physical device pin numbers. For one thing the physical package may have NC (not connected) pins, and these are hardly ever accounted for in numbering the nodes of a SPICE model. There can also be major complications with a multi element device such as a TL074: does the model implement one op-amp or four?
In practice this means that some kind of explicit cross-referencing is needed to tell the simulator which SPICE model node number to use for each pin on the device, since neither the schematic pin name nor the pin number can be used for the reasons given above. A special device property, SPICEPINS, exists to make this as painless as possible.
SPICE Dialects
There are many variants of SPICE in existence. The lowest common denominator is SPICE 2 and most published models appear to be written to that standard. A significant number of manufacturers, however, declare their models to be compatible with PSPICE™, a proprietary version of SPICE 2 which has been developed extensively beyond the original standard.
PROSPICE is based on SPICE3F5, which has many features that PSPICE™ does not, but the traffic runs both ways: PSPICE™ has some primitive types that are different and uses a different syntax for some of the newer additions to both products. A good deal of that difference is handled automatically, as described below, and what remains is the dot cards and device letters listed in the next section.
What Is and Is Not Accepted
If a downloaded model will not link, the first thing to check is that it uses only the constructs listed here. Anything else in the file is either ignored or rejected, and the model will not build.
Dot cards
The following dot cards are recognised:
.MODEL .SUBCKT .ENDS .END .INCLUDE .OPTIONS .OPTION .OPT .IC .NODESET .TEMP .OP .AC .DC .TRAN .TF .PZ .NOISE .DISTO .FOUR .FOURIER .SENS .SENS2 .PRINT .PLOT .WIDTH .PROBE
The following are not recognised and must be removed or rewritten before the model will link:
.LIB .PARAM .FUNC .STEP .SAVE .INC .GLOBAL .MC
.LIB and .PARAM are the two you are most likely to meet, since both are near universal in modern manufacturer downloads. A .LIB reference is usually replaced by pasting the referenced text into the same file, or by pointing the SPICEFILE property at it directly. A .PARAM declaration has to be resolved by hand, by substituting the parameter values into the expressions that use them. .FUNC and .STEP are handled the same way.
Note that the include directive must be spelled out in full as .INCLUDE. The common abbreviation .INC is not recognised. An .INCLUDE card is processed recursively, and the file it names is looked for on the same search path as the model file itself.
Device letters
Every other line in the model must begin with one of the following letters, with a comment line beginning with an asterisk and a continuation line beginning with a plus sign.
| Card | Device |
| R | Resistor |
| C | Capacitor |
| L | Inductor |
| K | Mutual inductance between two named inductors |
| D | Diode |
| Q | Bipolar junction transistor |
| J | Junction field effect transistor |
| Z | MESFET |
| M | MOSFET |
| V | Independent voltage source |
| I | Independent current source |
| E | Voltage controlled voltage source |
| F | Current controlled current source |
| G | Voltage controlled current source |
| H | Current controlled voltage source |
| B | Arbitrary (behavioural) source, defined by an expression |
| S | Voltage controlled switch |
| W | Current controlled switch |
| T | Lossless transmission line |
| O | Lossy transmission line |
| U | Uniformly distributed RC line |
| X | Call to a subcircuit defined by a .SUBCKT card |
No other device letter is accepted. In particular there is no A card, so a model that relies on XSPICE code models cannot be used.
Automatic Translation of PSPICE and SPICE 2 Sources
Controlled sources are the part of the language where SPICE 2, PSPICE™ and SPICE3F5 diverge most, so every E, F, G and H card in an incoming model is examined and rewritten where necessary. You do not have to do anything to enable this and you do not have to edit the model.
- A SPICE 2 or PSPICE™ polynomial source, written as POLY(n) followed by its coefficients, is converted into an equivalent SPICE3F5 B card whose expression is the polynomial written out in full.
- A PSPICE™ arbitrary source, written as VALUE={expression}, is converted into a B card carrying the same expression.
- Within such an expression, LOG and LOG10 are corrected. PSPICE™ uses LOG for the natural logarithm and LOG10 for base 10, which is the opposite way round from SPICE3F5, so they are remapped to LN and LOG respectively.
Every card that is rewritten is reported in the simulation log as "Translated:" followed by the original card and its replacement, provided the SPICE model linkage diagnostic is enabled. If you are unsure what the simulator has made of a source in a downloaded model, that is the quickest way to find out.
Third Party Models and Liability
We have gathered together many thousands of manufacturers' models and created corresponding schematic library parts for them, and these are supplied with the product.
You must, of course, appreciate that we can accept no responsibility for the accuracy or even functionality of these models, and that both ourselves and the manufacturers concerned disclaim any liability for losses of any kind whatsoever arising out of their use. In any case, there is never any guarantee that a circuit simulation will exactly reflect the performance of the real hardware and it is always advisable to build and test a physical prototype before entering into large scale production.
See Also: