Package Spice3 is a free Modelica package
This is a short User's Guide for the overall library.
Extends from Modelica.Icons.Information (Icon for general information packages).Name | Description |
---|---|
Overview | Overview |
Useofsemiconductors | Use of Semiconductors |
Spicenetlist | SPICE3 netlists |
NamingPrinciple | Naming principle |
ParameterHandling | Parameter handling |
Literature | Literature |
ReleaseNotes | Release notes |
Contact | Contact |
The Spice3 library is a Modelica library that contains some models of the Berkeley SPICE3 analog simulator.
General information about the analog simulator SPICE3
SPICE (Simulation Program with Integrated Circuit Emphasis) is a simulator for analog electrical circuits. It was developed as one of the first analog simulators in the university of Berkeley. SPICE netlists, which contain the circuit that shall be simulated, are a de-facto-standard up to now. For nearly every electrical circuit a SPICE netlist exists. Today the current version of SPICE is SPICE3e/SPICE3f. SPICE contains basic elements (resistor, inductor, capacitor), sources and semiconductor devices (diode, bipolar transistors, junction field effect transistors, MOS-field effect transistors) as well as models of lines. Out of this offered pool of elements, the circuits that shall be simulated are build as SPICE netlists.
The Spice3-library for Modelica
The Spice3 library was extracted from original SPICE3 C++ code. To be sure the Modelica models are correct the simulation results were compared to SPICE3. This way was chosen since SPICE3 is the only open source Spice simulator.
The Spice3-library was built in accordance to the model structure in SPICE. It contains the following packages:
Since the semiconductor models, especially MOS and BJT, are very complex models, many functions, data and parameters were needed for their description. Therefore a special Package called Internal was created that contains all the functions and records with data and parameters that are needed for the semiconductor models. It is not necessary that a user of the library works inside this package, so it is not for user access. The package Additionals is also a special one. It is not part of the original SPICE3. Nevertheless it contains useful models or features like the polynomial sources of SPICE2 that are often asked for.
There are many commercial SPICE simulators (PSPICE, NgSPICE, HSPICE, ...) which are derived from the Berkeley SPICE or are in some relation to it. Netlists of such SPICE derivatives can differ from Berkeley SPICE3 netlists. This has to be taken into account if netlists (their parameter names) are used with this package.
Extends from Modelica.Icons.Information (Icon for general information packages).Within the semiconductor devices SPICE3 differentiates between technology parameters and device parameters. Device parameters can be chosen for every single model instance, e.g., the channel length of a transistor. Technology parameters which are specified in a model card (.model) are adjustable for more than one element simultaneously, e.g. the type of transistors. As usually done in Modelica the parameters of the modelcard can be set in a parameter list.
To parametrize more than one model two ways are possible:
Since SPICE3 netlists are available for nearly every electrical circuit a desirable feature would be to translate SPICE3 netlists to Modelica. With the help of the example of an inverter circuits a possible way of the translation will be explained.
inverter Mp1 11 1 13 11 MPmos Mp2 11 13 2 11 MPmos Mn1 13 1 0 0 MNmos Mn2 2 13 0 0 MNmos Vgate 1 0 PULSE(0 5 2s 1s) Vdrain 11 0 PULSE(0 5 0s 1s) .model MPmos PMOS (gamma=0.37) .model MNmos NMOS (gamma=0.37 lambda=0.02) .tran 0.01 5 .end |
model inverter Spice3.Basic.Ground g; Spice3…M Mp1(mtype=true, M(GAMMA=0.37)); Spice3…M Mp2(mtype=true, M(GAMMA=0.37)); Spice3…M Mn1(M(LAMBDA=0.02, GAMMA=0.37)); Spice3…M Mn2(p(LAMBDA=0.02, GAMMA=0.37)); Spice3…V_pulse vdrain(V1=0, V2=5, TD=0, TR=1); Spice3…V_pulse vdrain(V1=0, V2=5, TD=0, TR=1); Spice3.Interfaces.Pin p_in, p_out; protected Spice3.Interfaces.Pin n0, n1, n2, n11, n13; equation connect(p_in, n1); connect(p_out, n2); connect(g.p, n0); connect(vdrain.n,n0); connect(vdrain.p,n11); connect(Mp1.B,n11); connect(Mp1.D, n11); connect(Mp1.G, n1); connect(Mp1.S, n13); connect(Mp2.B,n11); connect(Mp2.D, n11); connect(Mp2.G, n13); connect(Mp2.S, n2); connect(Mn1.B,n0); connect(Mn1.D, n13); connect(Mn1.G, n1); connect(Mn1.S, n0); connect(Mn2.B,n0); connect(Mn2.D, n2); connect(Mn2.G, n13); connect(Mn2.S, n0); end inverter; |
Given is a SPICE3 netlist that contains two inverter circuits. This netlist should be translated to Modelica in which the input voltage of the first inverter (node number 1) and the output voltage of the second inverter (node number 2) will later be connected with the surrounding circuit.
The following steps are necessary:
Spice3.Basic.Ground
).Spice3…V_pulse vdrain(V1=0, V2=5, TD=0, TR=1);
protected Spice3.Interfaces.Pin n2;in Modelica. The code letter (here
n
) is needed because a single number is no name in Modelica.connect(Mp1.D, n11)
.Spice3.Interfaces.Pin p_in, p_out; connect(p_in, n1); connect(p_out, n2);
In SPICE3 we have a predefined model pool. Each model device has got a code letter (e.g., resistor - R). In analogy to the SPICE3 models the models of the Spice3 library also got the according code letter in their names. The following examples shows the relationship:
A typical SPICE3 line could be:
C1 3 2 1pF
The first letter is the code letter (here C). It specifies the type of the model component (here capacitance). To see the analogy to the SPICE3 models in the Spice3 library the transformed capacitance has got the name C_Capacitance. According to that naming rule the components of the Spice3 library have the following names (the first letter is the code letter that has to be used in SPICE3):
In SPICE3 it is important to know whether a parameter was set by the user or not because the calculation of some values depends on that information and can be different. Since in Modelica there is no possibility to check that, a circumvention was chosen. The relevant parameters get an unrealistic value (-1e40) as their default value. Within a function it is checked if the parameter has still got this value (the parameter was not set by the user) of if it has a new value (parameter was set by the user).
Extends from Modelica.Icons.Information (Icon for general information packages).[Böhme2009] |
S. Böhme, K. Majetta, C. Clauss, P. Schneider, "Spice3 Modelica Library," 7th Modelica Conference, Como, Italy (2009) |
|
[Antognetti1988] |
P. Antognetti, G. Massobrio, Semiconductor Device Modeling with SPICE., McGraw-Hill Book Company, USA, 1988 |
|
[Connelly1992] |
A. Connelly, A, P. Choi, Macromodeling with SPICE., Prentice-Hall, New Jersey, USA (1992) |
|
[Johnson1991] |
B. Johnson, T. Quarles, A.R. Newton, D. O. Pederson, A. Sangiovanni-Vincentelli, SPICE3 Version 3f User's Manual., University of Berkeley, Department of Electrical Engineering and Computer Sciences, USA (1991): SPICE3 user's manual (© Regents of the University of California) |
|
[Kielkowski1994] |
R. Kielkowski, Inside SPICE - Overcoming the obstacles of circuit simulation., McGraw-Hill, USA (1994) |
This section summarizes the changes that have been performed on the Spice3 library.