eecircuit-engine 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -8
- package/dist/eecircuit-engine.mjs +163 -28
- package/dist/eecircuit-engine.umd.js +128 -6
- package/dist/main.d.ts +23 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,17 +1,59 @@
|
|
|
1
1
|
# EEcircuit-engine
|
|
2
|
-
Simulation engine for EEcircuit
|
|
3
2
|
|
|
3
|
+
Simulation engine for [EEcircuit](https://github.com/eelab-dev/EEcircuit)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
import { ResultType, Simulation } from "eecircuit-engine";
|
|
5
|
+
## installation
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install eecircuit-engine
|
|
9
|
+
```
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
## Usage
|
|
11
12
|
|
|
13
|
+
import the `Simulation` class and create a new instance of it.
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import { Simulation } from "eecircuit-engine";
|
|
17
|
+
|
|
18
|
+
const sim = new Simulation();
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
start the simulation by calling the `start` method. This will initialize the simulation engine, but it does not run any simulation yet.
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
12
24
|
await sim.start();
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Set your netlist. The netlist is same as ngspice netlist format.
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
const netlist = `
|
|
31
|
+
Basic RLC circuit
|
|
32
|
+
.include modelcard.CMOS90
|
|
33
|
+
|
|
34
|
+
r vdd 2 100.0
|
|
35
|
+
l vdd 2 1
|
|
36
|
+
c vdd 2 0.01
|
|
37
|
+
m1 2 1 0 0 N90 W=100.0u L=0.09u
|
|
38
|
+
vdd vdd 0 1.8
|
|
39
|
+
|
|
40
|
+
vin 1 0 0 pulse (0 1.8 0 0.1 0.1 15 30)
|
|
41
|
+
.tran 0.1 5
|
|
42
|
+
|
|
43
|
+
.end
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
sim.setNetList(netlist);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Run the simulation by calling the `runSim` method. This will run the simulation and return the result.
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
const result = await sim.runSim();
|
|
53
|
+
```
|
|
13
54
|
|
|
14
|
-
|
|
55
|
+
You can now access the result of the simulation.
|
|
15
56
|
|
|
16
|
-
|
|
17
|
-
|
|
57
|
+
```javascript
|
|
58
|
+
console.log(result);
|
|
59
|
+
```
|
|
@@ -2916,6 +2916,128 @@ const BC = `* NMOS modelcard
|
|
|
2916
2916
|
|
|
2917
2917
|
***************************************************************************************************
|
|
2918
2918
|
|
|
2919
|
+
|
|
2920
|
+
* Predictive Technology Model Beta Version
|
|
2921
|
+
* 180nm NMOS SPICE Parametersv (normal one)
|
|
2922
|
+
*
|
|
2923
|
+
|
|
2924
|
+
.model PTM180N NMOS
|
|
2925
|
+
+Level = 49
|
|
2926
|
+
|
|
2927
|
+
+Lint = 4.e-08 Tox = 4.e-09
|
|
2928
|
+
+Vth0 = 0.3999 Rdsw = 250
|
|
2929
|
+
|
|
2930
|
+
+lmin=1.8e-7 lmax=1.8e-7 wmin=1.8e-7 wmax=1.0e-4 Tref=27.0 version =3.1
|
|
2931
|
+
+Xj= 6.0000000E-08 Nch= 5.9500000E+17
|
|
2932
|
+
+lln= 1.0000000 lwn= 1.0000000 wln= 0.00
|
|
2933
|
+
+wwn= 0.00 ll= 0.00
|
|
2934
|
+
+lw= 0.00 lwl= 0.00 wint= 0.00
|
|
2935
|
+
+wl= 0.00 ww= 0.00 wwl= 0.00
|
|
2936
|
+
+Mobmod= 1 binunit= 2 xl= 0
|
|
2937
|
+
+xw= 0 binflag= 0
|
|
2938
|
+
+Dwg= 0.00 Dwb= 0.00
|
|
2939
|
+
|
|
2940
|
+
+K1= 0.5613000 K2= 1.0000000E-02
|
|
2941
|
+
+K3= 0.00 Dvt0= 8.0000000 Dvt1= 0.7500000
|
|
2942
|
+
+Dvt2= 8.0000000E-03 Dvt0w= 0.00 Dvt1w= 0.00
|
|
2943
|
+
+Dvt2w= 0.00 Nlx= 1.6500000E-07 W0= 0.00
|
|
2944
|
+
+K3b= 0.00 Ngate= 5.0000000E+20
|
|
2945
|
+
|
|
2946
|
+
+Vsat= 1.3800000E+05 Ua= -7.0000000E-10 Ub= 3.5000000E-18
|
|
2947
|
+
+Uc= -5.2500000E-11 Prwb= 0.00
|
|
2948
|
+
+Prwg= 0.00 Wr= 1.0000000 U0= 3.5000000E-02
|
|
2949
|
+
+A0= 1.1000000 Keta= 4.0000000E-02 A1= 0.00
|
|
2950
|
+
+A2= 1.0000000 Ags= -1.0000000E-02 B0= 0.00
|
|
2951
|
+
+B1= 0.00
|
|
2952
|
+
|
|
2953
|
+
+Voff= -0.12350000 NFactor= 0.9000000 Cit= 0.00
|
|
2954
|
+
+Cdsc= 0.00 Cdscb= 0.00 Cdscd= 0.00
|
|
2955
|
+
+Eta0= 0.2200000 Etab= 0.00 Dsub= 0.8000000
|
|
2956
|
+
|
|
2957
|
+
+Pclm= 5.0000000E-02 Pdiblc1= 1.2000000E-02 Pdiblc2= 7.5000000E-03
|
|
2958
|
+
+Pdiblcb= -1.3500000E-02 Drout= 1.7999999E-02 Pscbe1= 8.6600000E+08
|
|
2959
|
+
+Pscbe2= 1.0000000E-20 Pvag= -0.2800000 Delta= 1.0000000E-02
|
|
2960
|
+
+Alpha0= 0.00 Beta0= 30.0000000
|
|
2961
|
+
|
|
2962
|
+
+kt1= -0.3700000 kt2= -4.0000000E-02 At= 5.5000000E+04
|
|
2963
|
+
+Ute= -1.4800000 Ua1= 9.5829000E-10 Ub1= -3.3473000E-19
|
|
2964
|
+
+Uc1= 0.00 Kt1l= 4.0000000E-09 Prt= 0.00
|
|
2965
|
+
|
|
2966
|
+
+Cj= 0.00365 Mj= 0.54 Pb= 0.982
|
|
2967
|
+
+Cjsw= 7.9E-10 Mjsw= 0.31 Php= 0.841
|
|
2968
|
+
+Cta= 0 Ctp= 0 Pta= 0
|
|
2969
|
+
+Ptp= 0 JS=1.50E-08 JSW=2.50E-13
|
|
2970
|
+
+N=1.0 Xti=3.0 Cgdo=2.786E-10
|
|
2971
|
+
+Cgso=2.786E-10 Cgbo=0.0E+00 Capmod= 2
|
|
2972
|
+
+NQSMOD= 0 Elm= 5 Xpart= 1
|
|
2973
|
+
+Cgsl= 1.6E-10 Cgdl= 1.6E-10 Ckappa= 2.886
|
|
2974
|
+
+Cf= 1.069e-10 Clc= 0.0000001 Cle= 0.6
|
|
2975
|
+
+Dlc= 4E-08 Dwc= 0 Vfbcv= -1
|
|
2976
|
+
|
|
2977
|
+
|
|
2978
|
+
*********************************************************************************************
|
|
2979
|
+
|
|
2980
|
+
*
|
|
2981
|
+
* Predictive Technology Model Beta Version
|
|
2982
|
+
* 180nm PMOS SPICE Parametersv (normal one)
|
|
2983
|
+
*
|
|
2984
|
+
|
|
2985
|
+
.model PTM180P PMOS
|
|
2986
|
+
+Level = 49
|
|
2987
|
+
|
|
2988
|
+
+Lint = 3.e-08 Tox = 4.2e-09
|
|
2989
|
+
+Vth0 = -0.42 Rdsw = 450
|
|
2990
|
+
|
|
2991
|
+
+lmin=1.8e-7 lmax=1.8e-7 wmin=1.8e-7 wmax=1.0e-4 Tref=27.0 version =3.1
|
|
2992
|
+
+Xj= 7.0000000E-08 Nch= 5.9200000E+17
|
|
2993
|
+
+lln= 1.0000000 lwn= 1.0000000 wln= 0.00
|
|
2994
|
+
+wwn= 0.00 ll= 0.00
|
|
2995
|
+
+lw= 0.00 lwl= 0.00 wint= 0.00
|
|
2996
|
+
+wl= 0.00 ww= 0.00 wwl= 0.00
|
|
2997
|
+
+Mobmod= 1 binunit= 2 xl= 0.00
|
|
2998
|
+
+xw= 0.00
|
|
2999
|
+
+binflag= 0 Dwg= 0.00 Dwb= 0.00
|
|
3000
|
+
|
|
3001
|
+
+ACM= 0 ldif=0.00 hdif=0.00
|
|
3002
|
+
+rsh= 0 rd= 0 rs= 0
|
|
3003
|
+
+rsc= 0 rdc= 0
|
|
3004
|
+
|
|
3005
|
+
+K1= 0.5560000 K2= 0.00
|
|
3006
|
+
+K3= 0.00 Dvt0= 11.2000000 Dvt1= 0.7200000
|
|
3007
|
+
+Dvt2= -1.0000000E-02 Dvt0w= 0.00 Dvt1w= 0.00
|
|
3008
|
+
+Dvt2w= 0.00 Nlx= 9.5000000E-08 W0= 0.00
|
|
3009
|
+
+K3b= 0.00 Ngate= 5.0000000E+20
|
|
3010
|
+
|
|
3011
|
+
+Vsat= 1.0500000E+05 Ua= -1.2000000E-10 Ub= 1.0000000E-18
|
|
3012
|
+
+Uc= -2.9999999E-11 Prwb= 0.00
|
|
3013
|
+
+Prwg= 0.00 Wr= 1.0000000 U0= 8.0000000E-03
|
|
3014
|
+
+A0= 2.1199999 Keta= 2.9999999E-02 A1= 0.00
|
|
3015
|
+
+A2= 0.4000000 Ags= -0.1000000 B0= 0.00
|
|
3016
|
+
+B1= 0.00
|
|
3017
|
+
|
|
3018
|
+
+Voff= -6.40000000E-02 NFactor= 1.4000000 Cit= 0.00
|
|
3019
|
+
+Cdsc= 0.00 Cdscb= 0.00 Cdscd= 0.00
|
|
3020
|
+
+Eta0= 8.5000000 Etab= 0.00 Dsub= 2.8000000
|
|
3021
|
+
|
|
3022
|
+
+Pclm= 2.0000000 Pdiblc1= 0.1200000 Pdiblc2= 8.0000000E-05
|
|
3023
|
+
+Pdiblcb= 0.1450000 Drout= 5.0000000E-02 Pscbe1= 1.0000000E-20
|
|
3024
|
+
+Pscbe2= 1.0000000E-20 Pvag= -6.0000000E-02 Delta= 1.0000000E-02
|
|
3025
|
+
+Alpha0= 0.00 Beta0= 30.0000000
|
|
3026
|
+
|
|
3027
|
+
+kt1= -0.3700000 kt2= -4.0000000E-02 At= 5.5000000E+04
|
|
3028
|
+
+Ute= -1.4800000 Ua1= 9.5829000E-10 Ub1= -3.3473000E-19
|
|
3029
|
+
+Uc1= 0.00 Kt1l= 4.0000000E-09 Prt= 0.00
|
|
3030
|
+
|
|
3031
|
+
+Cj= 0.00138 Mj= 1.05 Pb= 1.24
|
|
3032
|
+
+Cjsw= 1.44E-09 Mjsw= 0.43 Php= 0.841
|
|
3033
|
+
+Cta= 0.00093 Ctp= 0 Pta= 0.00153
|
|
3034
|
+
+Ptp= 0 JS=1.50E-08 JSW=2.50E-13
|
|
3035
|
+
+N=1.0 Xti=3.0 Cgdo=2.786E-10
|
|
3036
|
+
+Cgso=2.786E-10 Cgbo=0.0E+00 Capmod= 2
|
|
3037
|
+
+NQSMOD= 0 Elm= 5 Xpart= 1
|
|
3038
|
+
+Cgsl= 1.6E-10 Cgdl= 1.6E-10 Ckappa= 2.886
|
|
3039
|
+
+Cf= 1.058e-10 Clc= 0.0000001 Cle= 0.6
|
|
3040
|
+
+Dlc= 3E-08 Dwc= 0 Vfbcv= -1
|
|
2919
3041
|
`, oC = `
|
|
2920
3042
|
* SKY130 Spice File.
|
|
2921
3043
|
*.option scale=1.0u
|
|
@@ -97199,7 +97321,7 @@ function X(Y, ...R) {
|
|
|
97199
97321
|
class UC {
|
|
97200
97322
|
constructor() {
|
|
97201
97323
|
S(this, "pass", !1);
|
|
97202
|
-
//
|
|
97324
|
+
// private commandList = [" ", "source test.cir", "run", "set filetype=ascii", "write out.raw"];
|
|
97203
97325
|
S(this, "commandList", [" ", "source test.cir", "run", "write out.raw"]);
|
|
97204
97326
|
S(this, "cmd", 0);
|
|
97205
97327
|
S(this, "dataRaw", new Uint8Array());
|
|
@@ -97210,26 +97332,43 @@ class UC {
|
|
|
97210
97332
|
S(this, "error", []);
|
|
97211
97333
|
S(this, "initialized", !1);
|
|
97212
97334
|
S(this, "netList", "");
|
|
97213
|
-
|
|
97214
|
-
|
|
97215
|
-
S(this, "
|
|
97216
|
-
});
|
|
97217
|
-
S(this, "resolveInit", () => {
|
|
97218
|
-
});
|
|
97335
|
+
// Promise resolvers for initialization and simulation run.
|
|
97336
|
+
S(this, "initPromiseResolve", null);
|
|
97337
|
+
S(this, "runPromiseResolve", null);
|
|
97219
97338
|
S(this, "getInput", () => {
|
|
97220
97339
|
let R = " ";
|
|
97221
97340
|
return this.cmd < this.commandList.length ? (R = this.commandList[this.cmd], this.cmd++) : this.cmd = 0, this.log_debug(`cmd -> ${R}`), R;
|
|
97222
97341
|
});
|
|
97223
|
-
|
|
97224
|
-
|
|
97225
|
-
|
|
97226
|
-
|
|
97227
|
-
S(this, "
|
|
97228
|
-
|
|
97342
|
+
/**
|
|
97343
|
+
* Public start method.
|
|
97344
|
+
* Returns a promise that resolves when the simulation module is initialized.
|
|
97345
|
+
*/
|
|
97346
|
+
S(this, "start", () => {
|
|
97347
|
+
const R = new Promise((a) => {
|
|
97348
|
+
this.initPromiseResolve = a;
|
|
97349
|
+
});
|
|
97350
|
+
return this.startInternal(), R;
|
|
97351
|
+
});
|
|
97352
|
+
/**
|
|
97353
|
+
* Triggers a simulation run and returns a promise that resolves with the results.
|
|
97354
|
+
*/
|
|
97355
|
+
S(this, "runSim", () => (this.initialized && (this.info = "", this.error = [], this.results = {}, this.log_debug("Triggering simulation run..."), this.continueRun()), new Promise((R) => {
|
|
97356
|
+
this.runPromiseResolve = R;
|
|
97229
97357
|
})));
|
|
97230
|
-
|
|
97231
|
-
|
|
97358
|
+
/**
|
|
97359
|
+
* Waits for a new simulation trigger.
|
|
97360
|
+
*/
|
|
97361
|
+
S(this, "waitForNextRun", () => new Promise((R) => {
|
|
97362
|
+
this.runPromiseResolve = () => {
|
|
97363
|
+
R();
|
|
97364
|
+
};
|
|
97232
97365
|
}));
|
|
97366
|
+
/**
|
|
97367
|
+
* Resolves the waiting promise to continue the simulation loop.
|
|
97368
|
+
*/
|
|
97369
|
+
S(this, "continueRun", () => {
|
|
97370
|
+
this.runPromiseResolve && (this.runPromiseResolve(this.results), this.runPromiseResolve = null);
|
|
97371
|
+
});
|
|
97233
97372
|
S(this, "outputEvent", (R) => {
|
|
97234
97373
|
});
|
|
97235
97374
|
S(this, "setNetList", (R) => {
|
|
@@ -97238,7 +97377,6 @@ class UC {
|
|
|
97238
97377
|
S(this, "setOutputEvent", (R) => {
|
|
97239
97378
|
this.outputEvent = R;
|
|
97240
97379
|
});
|
|
97241
|
-
S(this, "getResult", () => this.results);
|
|
97242
97380
|
S(this, "getInfo", () => this.info);
|
|
97243
97381
|
S(this, "getInitInfo", () => this.initInfo);
|
|
97244
97382
|
S(this, "getError", () => this.error);
|
|
@@ -97246,26 +97384,23 @@ class UC {
|
|
|
97246
97384
|
S(this, "log_debug", (R, ...a) => {
|
|
97247
97385
|
});
|
|
97248
97386
|
}
|
|
97249
|
-
|
|
97387
|
+
/**
|
|
97388
|
+
* Internal startup method that sets up the Module and simulation loop.
|
|
97389
|
+
*/
|
|
97390
|
+
async startInternal() {
|
|
97250
97391
|
var a, i, H, J, p, d, b, t, P;
|
|
97251
97392
|
const R = await kC({
|
|
97252
|
-
//arguments: ["test.cir"],
|
|
97253
97393
|
noInitialRun: !0,
|
|
97254
97394
|
print: (_) => {
|
|
97255
97395
|
this.log_debug(_), this.info += _ + `
|
|
97256
97396
|
`;
|
|
97257
97397
|
},
|
|
97258
|
-
// https://sourceforge.net/p/ngspice/discussion/127605/thread/120f3462f9/
|
|
97259
97398
|
printErr: (_) => {
|
|
97260
97399
|
this.info += _ + `
|
|
97261
97400
|
|
|
97262
|
-
`, _
|
|
97401
|
+
`, _ !== "Warning: can't find the initialization file spinit." && _ !== "Using SPARSE 1.3 as Direct Linear Solver" ? (console.error(_), this.error.push(_)) : this.log_debug(_);
|
|
97263
97402
|
},
|
|
97264
|
-
preRun: [
|
|
97265
|
-
() => {
|
|
97266
|
-
this.log_debug("from prerun");
|
|
97267
|
-
}
|
|
97268
|
-
],
|
|
97403
|
+
preRun: [() => this.log_debug("from prerun")],
|
|
97269
97404
|
setGetInput: this.getInput,
|
|
97270
97405
|
setHandleThings: () => {
|
|
97271
97406
|
},
|
|
@@ -97277,15 +97412,15 @@ class UC {
|
|
|
97277
97412
|
var _;
|
|
97278
97413
|
this.log_debug("handle other things!!!!!"), (_ = R.Asyncify) == null || _.handleAsync(async () => {
|
|
97279
97414
|
var DA, f;
|
|
97280
|
-
if (this.
|
|
97415
|
+
if (this.cmd === 0) {
|
|
97281
97416
|
try {
|
|
97282
|
-
this.dataRaw = ((DA = R.FS) == null ? void 0 : DA.readFile("out.raw")) ?? new Uint8Array(), this.results = SC(this.dataRaw), this.outputEvent(this.output), this.
|
|
97417
|
+
this.dataRaw = ((DA = R.FS) == null ? void 0 : DA.readFile("out.raw")) ?? new Uint8Array(), this.results = SC(this.dataRaw), this.outputEvent(this.output), this.runPromiseResolve && (this.runPromiseResolve(this.results), this.runPromiseResolve = null);
|
|
97283
97418
|
} catch (UA) {
|
|
97284
97419
|
this.log_debug(UA);
|
|
97285
97420
|
}
|
|
97286
97421
|
this.log_debug("output completed");
|
|
97287
97422
|
}
|
|
97288
|
-
this.initialized || (this.
|
|
97423
|
+
this.initialized || (this.initPromiseResolve && (this.initPromiseResolve(), this.initPromiseResolve = null), this.log_debug("initialized"), this.initialized = !0, this.initInfo = this.info), this.cmd === 0 && (this.log_debug("waiting for next simulation trigger..."), await this.waitForNextRun()), this.log_debug("Simulation loop finished for one run cycle"), (f = R.FS) == null || f.writeFile("/test.cir", this.netList), this.pass = !1;
|
|
97289
97424
|
});
|
|
97290
97425
|
}), R.setGetInput(this.getInput), R.runThings();
|
|
97291
97426
|
}
|