circuit-json-to-spice 0.0.1
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/LICENSE +21 -0
- package/README.md +7 -0
- package/biome.json +49 -0
- package/bun.lockb +0 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/docs/CIRCUIT_JSON_PCB_OVERVIEW.md +340 -0
- package/docs/CIRCUIT_JSON_SOURCE_COMPONENT_OVERVIEW.md +151 -0
- package/docs/SPICE_SUMMARY.txt +248 -0
- package/lib/index.ts +1 -0
- package/lib/spice-classes/SpiceComponent.ts +0 -0
- package/lib/spice-classes/SpiceModel.ts +0 -0
- package/lib/spice-classes/SpiceNetlist.ts +9 -0
- package/lib/spice-classes/SpiceNode.ts +1 -0
- package/lib/spice-classes/SpiceSubcircuit.ts +0 -0
- package/lib/spice-commands/BJTCommand.ts +34 -0
- package/lib/spice-commands/BaseSpiceCommand.ts +6 -0
- package/lib/spice-commands/CapacitorCommand.ts +41 -0
- package/lib/spice-commands/CurrentSourceCommand.ts +35 -0
- package/lib/spice-commands/DiodeCommand.ts +27 -0
- package/lib/spice-commands/InductorCommand.ts +33 -0
- package/lib/spice-commands/InductorCouplingCommand.ts +21 -0
- package/lib/spice-commands/JFETCommand.ts +28 -0
- package/lib/spice-commands/MOSFETCommand.ts +67 -0
- package/lib/spice-commands/ResistorCommand.ts +28 -0
- package/lib/spice-commands/SubcircuitCallCommand.ts +21 -0
- package/lib/spice-commands/TransmissionLineCommand.ts +46 -0
- package/lib/spice-commands/VoltageControlledSwitchCommand.ts +31 -0
- package/lib/spice-commands/VoltageSourceCommand.ts +35 -0
- package/lib/spice-commands/index.ts +14 -0
- package/lib/spice-utils/convertSpiceNetlistToString.ts +3 -0
- package/package.json +18 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
> From http://www.ecircuitcenter.com/SPICEsummary.htm
|
|
2
|
+
|
|
3
|
+
BRIEF SPICE SUMMARY
|
|
4
|
+
Here's a brief reference of the SPICE devices and statements. Parameters enclosed by braces { } are required, while, those in brackets [ ] are optional. Parameters followed by an asterisk { }\* should be repeated as necessary. Each SPICE vendor may have other parameters or commands unique to their version of SPICE. (For more information see Books on SPICE)
|
|
5
|
+
|
|
6
|
+
DEVICES
|
|
7
|
+
|
|
8
|
+
C device - Capacitor.
|
|
9
|
+
C{name} {+node} {-node} [{model}] {value} [IC={initial}]
|
|
10
|
+
Examples:
|
|
11
|
+
CLOAD 15 0 20pF
|
|
12
|
+
CFDBK 3 33 CMOD 10pF IC=1.5v
|
|
13
|
+
|
|
14
|
+
D device - Diode.
|
|
15
|
+
D{name} {+node} {-node} {model} [area]
|
|
16
|
+
Examples:
|
|
17
|
+
DCLAMP 14 0 DMOD
|
|
18
|
+
|
|
19
|
+
I device - Current Source.
|
|
20
|
+
I{name} {+node} {-node} [[DC] {value}] [AC {mag} [{phase}]]
|
|
21
|
+
Examples:
|
|
22
|
+
IBIAS 13 0 2.3mA
|
|
23
|
+
IAC 2 3 AC .001
|
|
24
|
+
IPULSE 1 0 PULSE(-1mA 1mA 2ns 2ns 2ns 50ns 100ns)
|
|
25
|
+
I3 26 77 AC 1 SIN(.002 .002 1.5MEG)
|
|
26
|
+
See Input Sources for PULSE, SIN and more.
|
|
27
|
+
Top ↑
|
|
28
|
+
J device - Junction FET.
|
|
29
|
+
J{name} {d} {g} {s} {model} [{area]}
|
|
30
|
+
Examples:
|
|
31
|
+
JIN 100 1 0 JFAST
|
|
32
|
+
|
|
33
|
+
K device - Inductor Coupling.
|
|
34
|
+
K{name} L{name} { L{name} }\* {coupling}
|
|
35
|
+
Examples:
|
|
36
|
+
KTUNED L3OUT L4IN .8
|
|
37
|
+
KXFR1 LPRIM LSEC .99
|
|
38
|
+
|
|
39
|
+
L device - Inductor.
|
|
40
|
+
L{name} {+node} {-node} [model] {value} [IC={initial}]
|
|
41
|
+
Examples:
|
|
42
|
+
LLOAD 15 0 20mH
|
|
43
|
+
L2 1 2 .2e-6
|
|
44
|
+
LSENSE 5 12 2uH IC=2mA
|
|
45
|
+
|
|
46
|
+
M device - MOSFET.
|
|
47
|
+
M{name} {d} {g} {s} {sub} {mdl} [L={value}] [W={value}] + [AD={value}] [AS={value}] + [PD={value}] [PS={value}] + [NRD={value}] [NRS={value}]
|
|
48
|
+
|
|
49
|
+
Examples:
|
|
50
|
+
M1 14 2 13 0 PNOM L=25u W=12u
|
|
51
|
+
M13 15 3 0 0 PSTRONG
|
|
52
|
+
|
|
53
|
+
Q device - Bipolar Transistor.
|
|
54
|
+
Q{name} {c} {b} {e} [{subs}] {model} [{area}]
|
|
55
|
+
Examples:
|
|
56
|
+
Q1 14 2 13 PNPNOM
|
|
57
|
+
Q13 15 3 0 1 NPNSTRONG 1.5
|
|
58
|
+
|
|
59
|
+
R device - Resistor.
|
|
60
|
+
R{name} {+node} {-node} [{model}] {value}
|
|
61
|
+
Examples:
|
|
62
|
+
RLOAD 15 0 2k
|
|
63
|
+
|
|
64
|
+
S device - Voltage-Controlled Switch.
|
|
65
|
+
S{name} {+node} {-node} {+control} {-control} {model}
|
|
66
|
+
Examples:
|
|
67
|
+
S12 13 17 2 0 SMOD
|
|
68
|
+
|
|
69
|
+
T device - Transmission Line.
|
|
70
|
+
T{name} {A+} {A-} {B+} {B-} Z0={value}
|
|
71
|
+
[TD={val} | F={val}[NL={val}]]
|
|
72
|
+
Examples:
|
|
73
|
+
T1 1 2 3 4 Z0=220 TD=115ns
|
|
74
|
+
T2 1 2 3 4 Z0=50 F=5MEG NL=0.5
|
|
75
|
+
|
|
76
|
+
V device - Voltage Source.
|
|
77
|
+
V{name} {+node} {-node} [[DC] {value}] [AC {mag} [{phase}]]
|
|
78
|
+
Examples:
|
|
79
|
+
VBIAS 13 0 2.3mV
|
|
80
|
+
VAC 2 3 AC .001
|
|
81
|
+
VPULSE 1 0 PULSE(-1mV 1mV 2ns 2ns 2ns 50ns 100ns)
|
|
82
|
+
V3 26 77 AC 1 SIN(.002 .002 1.5MEG)
|
|
83
|
+
See Input Sources for PULSE, SIN and more.
|
|
84
|
+
|
|
85
|
+
X device - Subcircuit Call.
|
|
86
|
+
X{name} [{node}]\* {subcircuit name}
|
|
87
|
+
Examples:
|
|
88
|
+
X12 100 101 200 201 DIFFAMP
|
|
89
|
+
Top ↑
|
|
90
|
+
|
|
91
|
+
CONTROLLED SOURCES
|
|
92
|
+
E device - Voltage Controlled Voltage Source VCVS.
|
|
93
|
+
E{name} {+node} {-node} {+cntrl} {-cntrl} {gain}
|
|
94
|
+
E{name} {+node} {-node} POLY({value}) {{+cntrl} {-cntrl}}_ {{coeff}}_
|
|
95
|
+
Examples:
|
|
96
|
+
EBUFF 1 2 10 11 1.0
|
|
97
|
+
EAMP 13 0 POLY(1) 26 0 500
|
|
98
|
+
|
|
99
|
+
F device - Current Controlled Current Source CCCS.
|
|
100
|
+
F{name} {+node} {-node} {vsource name} {gain}
|
|
101
|
+
Examples:
|
|
102
|
+
FSENSE 1 2 VSENSE 10.0
|
|
103
|
+
|
|
104
|
+
G device - Voltage Controlled Current Source VCCS.
|
|
105
|
+
G{name} {+node} {-node} {+control} {-control} {gain}
|
|
106
|
+
Examples:
|
|
107
|
+
GBUFF 1 2 10 11 1.0
|
|
108
|
+
H device - Current Controlled Voltage Source CCVS.
|
|
109
|
+
H{name} {+node} {-node} {vsource name} {gain}
|
|
110
|
+
H{name} {+node} {-node} POLY({value}) { {vsource name} }_ {{coeff}}_
|
|
111
|
+
Examples:
|
|
112
|
+
HSENSE 1 2 VSENSE 10.0
|
|
113
|
+
HAMP 13 0 POLY(1) VIN 500
|
|
114
|
+
Top ↑
|
|
115
|
+
|
|
116
|
+
INPUT SOURCES
|
|
117
|
+
|
|
118
|
+
EXPONENTIAL
|
|
119
|
+
EXP( {v1} {v2} {trise_delay} {tau_rise} {tfall_delay} {tau_fall) )
|
|
120
|
+
PULSE
|
|
121
|
+
PULSE( {v1} {v2} {tdelay} {trise} {tfall} {width} {period} )
|
|
122
|
+
PIECE WISE LINEAR
|
|
123
|
+
PWL( {time1} {v1} {time2} {v2} ... {time3} {v3} )
|
|
124
|
+
SINGLE FREQUENCY FM
|
|
125
|
+
SFFM( {voffset} {vpeak} {fcarrier} {mod_index} {fsignal} )
|
|
126
|
+
SINE WAVE
|
|
127
|
+
SIN( {voffset} {vpeak} {freq} {tdelay} {damp_factor} {phase} )
|
|
128
|
+
Top ↑
|
|
129
|
+
|
|
130
|
+
ANALOG BEHAVIORAL MODELING
|
|
131
|
+
VALUE
|
|
132
|
+
E|G{name} {+node} {-node} VALUE {expression}
|
|
133
|
+
Examples:
|
|
134
|
+
GMULT 1 0 VALUE = { V(3)*V(5,6)*100 }
|
|
135
|
+
ERES 1 3 VALUE = { I(VSENSE)\*10K }
|
|
136
|
+
|
|
137
|
+
TABLE
|
|
138
|
+
E|G{name} {+node} {-node} TABLE {expression} = (invalue, outvalue)_
|
|
139
|
+
Examples:
|
|
140
|
+
ECOMP 3 0 TABLE {V(1,2)} = (-1MV 0V) (1MV, 10V)
|
|
141
|
+
LAPLACE
|
|
142
|
+
E|G{name} {+node} {-node} LAPLACE {expression} {s expression}
|
|
143
|
+
Examples:
|
|
144
|
+
ELOPASS 4 0 LAPLACE {V(1)} {10 / (s/6800 + 1)}
|
|
145
|
+
FREQ
|
|
146
|
+
E|G{name} {+node} {-node} FREQ {expression} (freq, gain, phase)_
|
|
147
|
+
Examples:
|
|
148
|
+
EAMP 5 0 FREQ {V(1)} (1KZ, 10DB, 0DEG) (10KHZ, 0DB, -90DEG)
|
|
149
|
+
|
|
150
|
+
STATEMENTS
|
|
151
|
+
|
|
152
|
+
.AC - AC Analysis.
|
|
153
|
+
.AC [LIN][OCT][DEC] {points} {start} {end}
|
|
154
|
+
Examples:
|
|
155
|
+
.AC LIN 101 10Hz 200Hz
|
|
156
|
+
.AC DEC 20 1MEG 100MEG
|
|
157
|
+
|
|
158
|
+
.DC - DC Analysis.
|
|
159
|
+
.DC [LIN] {varname} {start} {end} {incr}
|
|
160
|
+
.DC [OCT][DEC] {varname} {start} {end} {points}
|
|
161
|
+
Examples:
|
|
162
|
+
.DC VIN -.25 .25 .05
|
|
163
|
+
.DC LIN I2 5mA -2mA 0.1mA VCE 10V 15V 1V
|
|
164
|
+
|
|
165
|
+
.FOUR - Fourier Analysis.
|
|
166
|
+
.FOUR {freq} {output var}\*
|
|
167
|
+
Examples:
|
|
168
|
+
.FOUR 10KHz v(5) v(6,7)
|
|
169
|
+
|
|
170
|
+
.IC - Initial Transient Conditions.
|
|
171
|
+
.IC { {vnode} = {value} }\*
|
|
172
|
+
Examples:
|
|
173
|
+
.IC V(2)=3.4 V(102)=0
|
|
174
|
+
|
|
175
|
+
.MODEL – Device Model.
|
|
176
|
+
.MODEL {name} {type}
|
|
177
|
+
Typename Devname Devtype
|
|
178
|
+
CAP Cxxx capacitor
|
|
179
|
+
IND Lxxx inductor
|
|
180
|
+
RES Rxxx resistor
|
|
181
|
+
D Dxxx diode
|
|
182
|
+
NPN Qxxx NPN bipolar
|
|
183
|
+
PNP Qxxx PNP bipolar
|
|
184
|
+
NJF Jxxx N-channel JFET
|
|
185
|
+
PJF Jxxx P-channel JFET
|
|
186
|
+
NMOS Mxxx N-channel MOSFET
|
|
187
|
+
PMOS Mxxx P-channel MOSFET
|
|
188
|
+
VSWITCH Sxxx voltage controlled switch
|
|
189
|
+
|
|
190
|
+
Examples:
|
|
191
|
+
.MODEL RMAX RES (R=1.5 TC=.02 TC2=.005)
|
|
192
|
+
.MODEL QDRIV NPN (IS=1e-7 BF=30)
|
|
193
|
+
|
|
194
|
+
Top ↑
|
|
195
|
+
.NODESET – Initial bias point guess.
|
|
196
|
+
.NODESET { {node}={value} }\*
|
|
197
|
+
Examples:
|
|
198
|
+
.NODESET V(2)=3.4 V(3)=-1V
|
|
199
|
+
|
|
200
|
+
.NOISE - Noise Analysis.
|
|
201
|
+
.NOISE {output variable} {name} [{print interval}]
|
|
202
|
+
Examples:
|
|
203
|
+
.NOISE V(5) VIN
|
|
204
|
+
|
|
205
|
+
.PLOT – Plot Output.
|
|
206
|
+
.PLOT [DC][AC][NOISE][TRAN] [ [{output variable}*]
|
|
207
|
+
Examples:
|
|
208
|
+
.PLOT DC V(3) V(2,3) V(R1) I(VIN)
|
|
209
|
+
.PLOT AC VM(2) VP(2) VG(2)
|
|
210
|
+
|
|
211
|
+
.PRINT – Print Output.
|
|
212
|
+
.PRINT [DC][AC][NOISE][TRAN] [{output variable}*]
|
|
213
|
+
Examples:
|
|
214
|
+
.PRINT DC V(3) V(2,3) V(R1) IB(Q13)
|
|
215
|
+
.PRINT AC VM(2) VP(2) VG(5) II(7)
|
|
216
|
+
Top ↑
|
|
217
|
+
.PROBE – Save simulation output PSPICE COMMAND.
|
|
218
|
+
.PROBE [output variable]\*
|
|
219
|
+
Examples:
|
|
220
|
+
.PROBE
|
|
221
|
+
.PROBE V(3) VM(2) I(VIN)
|
|
222
|
+
|
|
223
|
+
.SENS - Sensitivity Analysis.
|
|
224
|
+
.SENS {output variable}\*
|
|
225
|
+
Examples:
|
|
226
|
+
.SENS V(9) V(4,3) I(VCC)
|
|
227
|
+
|
|
228
|
+
.SUBCKT - Subcircuit Definition.
|
|
229
|
+
.SUBCKT {name} [{node}*]
|
|
230
|
+
Examples:
|
|
231
|
+
.SUBCKT OPAMP 1 2 101 102
|
|
232
|
+
|
|
233
|
+
.TEMP – Temperature Analysis.
|
|
234
|
+
.TEMP {value}\*
|
|
235
|
+
Examples:
|
|
236
|
+
.TEMP 0 27 125
|
|
237
|
+
|
|
238
|
+
.TF – DC Transfer Function.
|
|
239
|
+
.TF {output variable} {input source name}
|
|
240
|
+
Examples:
|
|
241
|
+
.TF V(5) VIN
|
|
242
|
+
|
|
243
|
+
.TRAN - Transient Analysis.
|
|
244
|
+
.TRAN {print step value} {final time} [{no print time}
|
|
245
|
+
[{step ceiling value}]] [UIC]
|
|
246
|
+
Examples:
|
|
247
|
+
.TRAN 5NS 100NS
|
|
248
|
+
Top ↑
|
package/lib/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log("Hello via Bun!");
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class SpiceNode {}
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface BJTCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
collector: string
|
|
6
|
+
base: string
|
|
7
|
+
emitter: string
|
|
8
|
+
substrate?: string
|
|
9
|
+
model: string
|
|
10
|
+
area?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class BJTCommand implements BaseSpiceCommand {
|
|
14
|
+
commandName = "bjt" as const
|
|
15
|
+
props: BJTCommandProps
|
|
16
|
+
|
|
17
|
+
constructor(props: BJTCommandProps) {
|
|
18
|
+
this.props = props
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
toSpiceString(): string {
|
|
22
|
+
const { name, collector, base, emitter, substrate, model, area } =
|
|
23
|
+
this.props
|
|
24
|
+
let spiceString = `Q${name} ${collector} ${base} ${emitter}`
|
|
25
|
+
if (substrate) {
|
|
26
|
+
spiceString += ` ${substrate}`
|
|
27
|
+
}
|
|
28
|
+
spiceString += ` ${model}`
|
|
29
|
+
if (area) {
|
|
30
|
+
spiceString += ` ${area}`
|
|
31
|
+
}
|
|
32
|
+
return spiceString
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface CapacitorCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
positiveNode: string
|
|
6
|
+
negativeNode: string
|
|
7
|
+
modelName?: string
|
|
8
|
+
value: string
|
|
9
|
+
initialCondition?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class CapacitorCommand implements BaseSpiceCommand {
|
|
13
|
+
commandName = "capacitor" as const
|
|
14
|
+
|
|
15
|
+
props: CapacitorCommandProps
|
|
16
|
+
|
|
17
|
+
constructor(props: CapacitorCommandProps) {
|
|
18
|
+
this.props = props
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
toSpiceString(): string {
|
|
22
|
+
const {
|
|
23
|
+
name,
|
|
24
|
+
positiveNode,
|
|
25
|
+
negativeNode,
|
|
26
|
+
modelName,
|
|
27
|
+
value,
|
|
28
|
+
initialCondition,
|
|
29
|
+
} = this.props
|
|
30
|
+
|
|
31
|
+
let spiceString = `C${name} ${positiveNode} ${negativeNode}`
|
|
32
|
+
if (modelName) {
|
|
33
|
+
spiceString += ` ${modelName}`
|
|
34
|
+
}
|
|
35
|
+
spiceString += ` ${value}`
|
|
36
|
+
if (initialCondition) {
|
|
37
|
+
spiceString += ` IC=${initialCondition}`
|
|
38
|
+
}
|
|
39
|
+
return spiceString
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface CurrentSourceCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
positiveNode: string
|
|
6
|
+
negativeNode: string
|
|
7
|
+
value?: string
|
|
8
|
+
acMagnitude?: string
|
|
9
|
+
acPhase?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class CurrentSourceCommand implements BaseSpiceCommand {
|
|
13
|
+
commandName = "current_source" as const
|
|
14
|
+
props: CurrentSourceCommandProps
|
|
15
|
+
|
|
16
|
+
constructor(props: CurrentSourceCommandProps) {
|
|
17
|
+
this.props = props
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
toSpiceString(): string {
|
|
21
|
+
const { name, positiveNode, negativeNode, value, acMagnitude, acPhase } =
|
|
22
|
+
this.props
|
|
23
|
+
let spiceString = `I${name} ${positiveNode} ${negativeNode}`
|
|
24
|
+
if (value) {
|
|
25
|
+
spiceString += ` ${value}`
|
|
26
|
+
}
|
|
27
|
+
if (acMagnitude) {
|
|
28
|
+
spiceString += ` AC ${acMagnitude}`
|
|
29
|
+
if (acPhase) {
|
|
30
|
+
spiceString += ` ${acPhase}`
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return spiceString
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface DiodeCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
positiveNode: string
|
|
6
|
+
negativeNode: string
|
|
7
|
+
model: string
|
|
8
|
+
area?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class DiodeCommand implements BaseSpiceCommand {
|
|
12
|
+
commandName = "diode" as const
|
|
13
|
+
props: DiodeCommandProps
|
|
14
|
+
|
|
15
|
+
constructor(props: DiodeCommandProps) {
|
|
16
|
+
this.props = props
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
toSpiceString(): string {
|
|
20
|
+
const { name, positiveNode, negativeNode, model, area } = this.props
|
|
21
|
+
let spiceString = `D${name} ${positiveNode} ${negativeNode} ${model}`
|
|
22
|
+
if (area) {
|
|
23
|
+
spiceString += ` ${area}`
|
|
24
|
+
}
|
|
25
|
+
return spiceString
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface InductorCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
positiveNode: string
|
|
6
|
+
negativeNode: string
|
|
7
|
+
model?: string
|
|
8
|
+
value: string
|
|
9
|
+
initialCondition?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class InductorCommand implements BaseSpiceCommand {
|
|
13
|
+
commandName = "inductor" as const
|
|
14
|
+
props: InductorCommandProps
|
|
15
|
+
|
|
16
|
+
constructor(props: InductorCommandProps) {
|
|
17
|
+
this.props = props
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
toSpiceString(): string {
|
|
21
|
+
const { name, positiveNode, negativeNode, model, value, initialCondition } =
|
|
22
|
+
this.props
|
|
23
|
+
let spiceString = `L${name} ${positiveNode} ${negativeNode}`
|
|
24
|
+
if (model) {
|
|
25
|
+
spiceString += ` ${model}`
|
|
26
|
+
}
|
|
27
|
+
spiceString += ` ${value}`
|
|
28
|
+
if (initialCondition) {
|
|
29
|
+
spiceString += ` IC=${initialCondition}`
|
|
30
|
+
}
|
|
31
|
+
return spiceString
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface InductorCouplingCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
inductors: string[]
|
|
6
|
+
coupling: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class InductorCouplingCommand implements BaseSpiceCommand {
|
|
10
|
+
commandName = "inductor_coupling" as const
|
|
11
|
+
props: InductorCouplingCommandProps
|
|
12
|
+
|
|
13
|
+
constructor(props: InductorCouplingCommandProps) {
|
|
14
|
+
this.props = props
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
toSpiceString(): string {
|
|
18
|
+
const { name, inductors, coupling } = this.props
|
|
19
|
+
return `K${name} ${inductors.join(" ")} ${coupling}`
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface JFETCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
drain: string
|
|
6
|
+
gate: string
|
|
7
|
+
source: string
|
|
8
|
+
model: string
|
|
9
|
+
area?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class JFETCommand implements BaseSpiceCommand {
|
|
13
|
+
commandName = "jfet" as const
|
|
14
|
+
props: JFETCommandProps
|
|
15
|
+
|
|
16
|
+
constructor(props: JFETCommandProps) {
|
|
17
|
+
this.props = props
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
toSpiceString(): string {
|
|
21
|
+
const { name, drain, gate, source, model, area } = this.props
|
|
22
|
+
let spiceString = `J${name} ${drain} ${gate} ${source} ${model}`
|
|
23
|
+
if (area) {
|
|
24
|
+
spiceString += ` ${area}`
|
|
25
|
+
}
|
|
26
|
+
return spiceString
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface MOSFETCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
drain: string
|
|
6
|
+
gate: string
|
|
7
|
+
source: string
|
|
8
|
+
substrate: string
|
|
9
|
+
model: string
|
|
10
|
+
length?: string
|
|
11
|
+
width?: string
|
|
12
|
+
drainArea?: string
|
|
13
|
+
sourceArea?: string
|
|
14
|
+
drainPerimeter?: string
|
|
15
|
+
sourcePerimeter?: string
|
|
16
|
+
drainResistance?: string
|
|
17
|
+
sourceResistance?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class MOSFETCommand implements BaseSpiceCommand {
|
|
21
|
+
commandName = "mosfet" as const
|
|
22
|
+
props: MOSFETCommandProps
|
|
23
|
+
|
|
24
|
+
constructor(props: MOSFETCommandProps) {
|
|
25
|
+
this.props = props
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
toSpiceString(): string {
|
|
29
|
+
const {
|
|
30
|
+
name,
|
|
31
|
+
drain,
|
|
32
|
+
gate,
|
|
33
|
+
source,
|
|
34
|
+
substrate,
|
|
35
|
+
model,
|
|
36
|
+
length,
|
|
37
|
+
width,
|
|
38
|
+
drainArea,
|
|
39
|
+
sourceArea,
|
|
40
|
+
drainPerimeter,
|
|
41
|
+
sourcePerimeter,
|
|
42
|
+
drainResistance,
|
|
43
|
+
sourceResistance,
|
|
44
|
+
} = this.props
|
|
45
|
+
|
|
46
|
+
let spiceString = `M${name} ${drain} ${gate} ${source} ${substrate} ${model}`
|
|
47
|
+
|
|
48
|
+
const params: Record<string, string | undefined> = {
|
|
49
|
+
L: length,
|
|
50
|
+
W: width,
|
|
51
|
+
AD: drainArea,
|
|
52
|
+
AS: sourceArea,
|
|
53
|
+
PD: drainPerimeter,
|
|
54
|
+
PS: sourcePerimeter,
|
|
55
|
+
NRD: drainResistance,
|
|
56
|
+
NRS: sourceResistance,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
60
|
+
if (value) {
|
|
61
|
+
spiceString += ` ${key}=${value}`
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
return spiceString
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface ResistorCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
positiveNode: string
|
|
6
|
+
negativeNode: string
|
|
7
|
+
model?: string
|
|
8
|
+
value: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class ResistorCommand implements BaseSpiceCommand {
|
|
12
|
+
commandName = "resistor" as const
|
|
13
|
+
props: ResistorCommandProps
|
|
14
|
+
|
|
15
|
+
constructor(props: ResistorCommandProps) {
|
|
16
|
+
this.props = props
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
toSpiceString(): string {
|
|
20
|
+
const { name, positiveNode, negativeNode, model, value } = this.props
|
|
21
|
+
let spiceString = `R${name} ${positiveNode} ${negativeNode}`
|
|
22
|
+
if (model) {
|
|
23
|
+
spiceString += ` ${model}`
|
|
24
|
+
}
|
|
25
|
+
spiceString += ` ${value}`
|
|
26
|
+
return spiceString
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface SubcircuitCallCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
nodes: string[]
|
|
6
|
+
subcircuitName: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class SubcircuitCallCommand implements BaseSpiceCommand {
|
|
10
|
+
commandName = "subcircuit_call" as const
|
|
11
|
+
props: SubcircuitCallCommandProps
|
|
12
|
+
|
|
13
|
+
constructor(props: SubcircuitCallCommandProps) {
|
|
14
|
+
this.props = props
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
toSpiceString(): string {
|
|
18
|
+
const { name, nodes, subcircuitName } = this.props
|
|
19
|
+
return `X${name} ${nodes.join(" ")} ${subcircuitName}`
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface TransmissionLineCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
aPositive: string
|
|
6
|
+
aNegative: string
|
|
7
|
+
bPositive: string
|
|
8
|
+
bNegative: string
|
|
9
|
+
impedance: string
|
|
10
|
+
delay?: string
|
|
11
|
+
frequency?: string
|
|
12
|
+
normalizedLength?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class TransmissionLineCommand implements BaseSpiceCommand {
|
|
16
|
+
commandName = "transmission_line" as const
|
|
17
|
+
props: TransmissionLineCommandProps
|
|
18
|
+
|
|
19
|
+
constructor(props: TransmissionLineCommandProps) {
|
|
20
|
+
this.props = props
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
toSpiceString(): string {
|
|
24
|
+
const {
|
|
25
|
+
name,
|
|
26
|
+
aPositive,
|
|
27
|
+
aNegative,
|
|
28
|
+
bPositive,
|
|
29
|
+
bNegative,
|
|
30
|
+
impedance,
|
|
31
|
+
delay,
|
|
32
|
+
frequency,
|
|
33
|
+
normalizedLength,
|
|
34
|
+
} = this.props
|
|
35
|
+
let spiceString = `T${name} ${aPositive} ${aNegative} ${bPositive} ${bNegative} Z0=${impedance}`
|
|
36
|
+
if (delay) {
|
|
37
|
+
spiceString += ` TD=${delay}`
|
|
38
|
+
} else if (frequency) {
|
|
39
|
+
spiceString += ` F=${frequency}`
|
|
40
|
+
if (normalizedLength) {
|
|
41
|
+
spiceString += ` NL=${normalizedLength}`
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return spiceString
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BaseSpiceCommand } from "./BaseSpiceCommand"
|
|
2
|
+
|
|
3
|
+
export interface VoltageControlledSwitchCommandProps {
|
|
4
|
+
name: string
|
|
5
|
+
positiveNode: string
|
|
6
|
+
negativeNode: string
|
|
7
|
+
positiveControl: string
|
|
8
|
+
negativeControl: string
|
|
9
|
+
model: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class VoltageControlledSwitchCommand implements BaseSpiceCommand {
|
|
13
|
+
commandName = "voltage_controlled_switch" as const
|
|
14
|
+
props: VoltageControlledSwitchCommandProps
|
|
15
|
+
|
|
16
|
+
constructor(props: VoltageControlledSwitchCommandProps) {
|
|
17
|
+
this.props = props
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
toSpiceString(): string {
|
|
21
|
+
const {
|
|
22
|
+
name,
|
|
23
|
+
positiveNode,
|
|
24
|
+
negativeNode,
|
|
25
|
+
positiveControl,
|
|
26
|
+
negativeControl,
|
|
27
|
+
model,
|
|
28
|
+
} = this.props
|
|
29
|
+
return `S${name} ${positiveNode} ${negativeNode} ${positiveControl} ${negativeControl} ${model}`
|
|
30
|
+
}
|
|
31
|
+
}
|