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);