Skip to content

Commit fad46f6

Browse files
committed
add docstrings and PNP
1 parent 14f5c75 commit fad46f6

File tree

1 file changed

+248
-41
lines changed

1 file changed

+248
-41
lines changed
Lines changed: 248 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,46 @@
11
"""
2-
NPN(;name, B_F, B_R, Is, V_T, V_A, Phi_C, Phi_E, Z_C, Z_E, Tau_f, Tau_r, C_jC0, C_jE0, C_CS, gamma_C, gamma_E, NF, NR)
2+
NPN(;name, B_F, B_R, Is, V_T, V_A, phi_C, phi_E, Z_C, Z_E, Tau_f, Tau_r, C_jC0, C_jE0, C_CS, gamma_C, gamma_E, NF, NR)
33
4-
Creates an NPN Bipolar Junction Transistor following a modified Ebers-Moll model.
4+
Creates an NPN Bipolar Junction Transistor following a modified Ebers-Moll model. Includes an optional substrate pin and optional
5+
Early voltage effect.
6+
7+
# Structural Parameters
8+
- `use_substrate`: If `true`, a substrate pin connector is available. If `false` it is
9+
assumed the substrate is connected to the collector pin.
10+
11+
- `use_Early`: If `true`, the Early effect is modeled, which takes in to account the effect
12+
collector-base voltage variations have on the collector-base depletion region. In many cases this
13+
effectively means that the collector current has a dependency on the collector-emitter voltage.
14+
15+
- `use_advanced_continuation`: When false, the `C_jC` and `C_jE` non-linear capacitance curves use
16+
a simplified linear continuation starting when `V_BC` and `V_BE` are 0, respectively. If `true`, the `Z_C` and `Z_E` parameters
17+
are used to start the linear continuation at `Phi_C - Z_C` and `Phi_E - Z_E`.
18+
19+
# Connectors
20+
- `b` Base Pin
21+
- `c` Collector Pin
22+
- `e` Emitter Pin
23+
- `s` Substrate Pin, only available when `use_substrate = true`
24+
25+
# Parameters
26+
- `B_F`: Forward beta
27+
- `B_R`: Reverse beta
28+
- `Is`: Saturation current
29+
- `V_T`: Thermal voltage at 300K
30+
- `V_A`: Inverse Early voltage
31+
- `phi_C`: Collector junction exponent
32+
- `phi_E`: Emitter junction exponent
33+
- `Z_C`: Collector junction offset
34+
- `Z_E`: Emitter junction offset
35+
- `Tau_f`: Forward transit time
36+
- `Tau_r`: Reverse transit time
37+
- `C_jC0`: Collector junction capacitance coefficient
38+
- `C_jE0`: Emitter junction capacitance coefficient
39+
- `C_CS`: Collector-substrate capacitance
40+
- `gamma_C`: Collector junction exponent
41+
- `gamma_E`: Emitter junction exponent
42+
- `NF`: Forward emission coefficient
43+
- `NR`: Reverse emission coefficient
544
"""
645

746

@@ -30,46 +69,46 @@ Creates an NPN Bipolar Junction Transistor following a modified Ebers-Moll model
3069
end
3170

3271
@components begin
33-
b = Pin()
34-
e = Pin()
35-
c = Pin()
72+
b = Pin(), [description = "Base pin"]
73+
e = Pin(), [description = "Emitter pin"]
74+
c = Pin(), [description = "Collector pin"]
3675

3776
if use_substrate
38-
s = Pin()
77+
s = Pin(), [description = "Substrate pin"]
3978
end
4079
end
4180

4281
@parameters begin
43-
B_F = 50.0
44-
B_R = 0.1
45-
Is = 1e-16
46-
V_T = 0.02
82+
B_F = 50.0, [description = "Forward beta"]
83+
B_R = 0.1, [description = "Reverse beta"]
84+
Is = 1e-16, [description = "Saturation current"]
85+
V_T = 0.026, [description = "Thermal voltage at 300K"]
4786

4887
if use_Early
49-
V_A = 0.02
88+
V_A = 0.02, [description = "Inverse Early voltage"]
5089
end
5190

52-
Phi_C = 0.8
53-
Phi_E = 0.6
91+
phi_C = 0.8, [description = "Collector junction scaling factor"]
92+
phi_E = 0.6, [description = "Emitter junction scaling factor"]
5493

5594
if use_advanced_continuation
56-
Z_C = 0.1
57-
Z_E = 0.1
95+
Z_C = 0.1, [description = "Collector junction offset"]
96+
Z_E = 0.1, [description = "Emitter junction offset"]
5897
end
5998

60-
Tau_f = 0.12e-9
61-
Tau_r = 5e-9
99+
Tau_f = 0.12e-9, [description = "Forward transit time"]
100+
Tau_r = 5e-9, [description = "Reverse transit time"]
62101

63-
C_jC0 = 0.5e-12
64-
C_jE0 = 0.4e-12
102+
C_jC0 = 0.5e-12, [description = "Collector-junction capacitance coefficient"]
103+
C_jE0 = 0.4e-12, [description = "Emitter-junction capacitance coefficient"]
65104

66-
C_CS = 1e-12
105+
C_CS = 1e-12, [description = "Collector-substrate capacitance"]
67106

68-
gamma_C = 0.5
69-
gamma_E = 1.0 / 3.0
107+
gamma_C = 0.5, [description = "Collector junction exponent"]
108+
gamma_E = 1.0 / 3.0, [description = "Emitter junction exponent"]
70109

71-
NF = 1.0
72-
NR = 1.0
110+
NF = 1.0, [description = "Forward ideality exponent"]
111+
NR = 1.0, [description = "Reverse ideality exponent"]
73112
end
74113

75114
@equations begin
@@ -80,29 +119,29 @@ Creates an NPN Bipolar Junction Transistor following a modified Ebers-Moll model
80119
IEC ~ Is * (exp(V_BC / V_T) - 1)
81120

82121
if !use_advanced_continuation
83-
C_jC ~ ifelse(V_BC / Phi_C > 0.0, 1 + gamma_C * V_BC / Phi_C,
84-
(C_jC0) / (1 - V_BC / Phi_C)^gamma_C)
85-
C_jE ~ ifelse(V_BE / Phi_E > 0.0, 1 + gamma_E * V_BE / Phi_E,
86-
(C_jE0) / (1 - V_BE / Phi_E)^gamma_E)
122+
C_jC ~ ifelse(V_BC / phi_C > 0.0, 1 + gamma_C * V_BC / phi_C,
123+
(C_jC0) / (1 - V_BC / phi_C)^gamma_C)
124+
C_jE ~ ifelse(V_BE / phi_E > 0.0, 1 + gamma_E * V_BE / phi_E,
125+
(C_jE0) / (1 - V_BE / phi_E)^gamma_E)
87126
end
88127

89128
if use_advanced_continuation
90-
C_jC ~ if V_BC > Phi_C - Z_C
91-
((C_jC0 * gamma_C * (1 - ((Phi_C - Z_C) / Phi_C))^(-gamma_C - 1)) / Phi_C) *
129+
C_jC ~ if V_BC > phi_C - Z_C
130+
((C_jC0 * gamma_C * (1 - ((phi_C - Z_C) / phi_C))^(-gamma_C - 1)) / phi_C) *
92131
V_BC -
93-
((C_jC0 * gamma_C * (1 - ((Phi_C - Z_C) / Phi_C))^(-gamma_C - 1)) / Phi_C) *
94-
(Phi_C - Z_C) + (C_jC0) / (1 - (Phi_C - Z_C) / Phi_C)^gamma_C
132+
((C_jC0 * gamma_C * (1 - ((phi_C - Z_C) / phi_C))^(-gamma_C - 1)) / phi_C) *
133+
(phi_C - Z_C) + (C_jC0) / (1 - (phi_C - Z_C) / phi_C)^gamma_C
95134
else
96-
(C_jC0) / (1 - V_BC / Phi_C)^gamma_C
135+
(C_jC0) / (1 - V_BC / phi_C)^gamma_C
97136
end
98137

99-
C_jE ~ if V_BE > Phi_E - Z_E
100-
((C_jE0 * gamma_E * (1 - ((Phi_E - Z_E) / Phi_E))^(-gamma_E - 1)) / Phi_E) *
138+
C_jE ~ if V_BE > phi_E - Z_E
139+
((C_jE0 * gamma_E * (1 - ((phi_E - Z_E) / phi_E))^(-gamma_E - 1)) / phi_E) *
101140
V_BE -
102-
((C_jE0 * gamma_E * (1 - ((Phi_E - Z_E) / Phi_E))^(-gamma_E - 1)) / Phi_E) *
103-
(Phi_E - Z_E) + (C_jE0) / (1 - (Phi_E - Z_E) / Phi_E)^gamma_E
141+
((C_jE0 * gamma_E * (1 - ((phi_E - Z_E) / phi_E))^(-gamma_E - 1)) / phi_E) *
142+
(phi_E - Z_E) + (C_jE0) / (1 - (phi_E - Z_E) / phi_E)^gamma_E
104143
else
105-
(C_jE0) / (1 - V_BE / Phi_E)^gamma_E
144+
(C_jE0) / (1 - V_BE / phi_E)^gamma_E
106145
end
107146
end
108147

@@ -121,9 +160,177 @@ Creates an NPN Bipolar Junction Transistor following a modified Ebers-Moll model
121160

122161
I_sub ~ ifelse(use_substrate, -C_CS * D(V_CS), -C_CS * D(V_sub))
123162

124-
C.i ~ (ICC - IEC) * ifelse(use_Early, (1 - V_BC * V_A), 1.0) - IEC / B_R -
163+
c.i ~ (ICC - IEC) * ifelse(use_Early, (1 - V_BC * V_A), 1.0) - IEC / B_R -
125164
(C_jC + C_DC) * D(V_BC) - I_sub
126-
B.i ~ IEC / B_R + ICC / B_F + (C_jC + C_DC) * D(V_BC) + (C_jE + C_DE) * D(V_BE)
127-
E.i ~ -C.i - B.i - I_sub
165+
b.i ~ IEC / B_R + ICC / B_F + (C_jC + C_DC) * D(V_BC) + (C_jE + C_DE) * D(V_BE)
166+
e.i ~ -c.i - b.i - I_sub
167+
end
168+
end
169+
170+
171+
"""
172+
PNP(;name, B_F, B_R, Is, V_T, V_A, phi_C, phi_E, Z_C, Z_E, Tau_f, Tau_r, C_jC0, C_jE0, C_CS, gamma_C, gamma_E, NF, NR)
173+
174+
Creates a PNP Bipolar Junction Transistor following a modified Ebers-Moll model. Includes an optional substrate pin and optional
175+
Early voltage effect.
176+
177+
# Structural Parameters
178+
- `use_substrate`: If `true`, a substrate pin connector is available. If `false` it is
179+
assumed the substrate is connected to the collector pin.
180+
181+
- `use_Early`: If `true`, the Early effect is modeled, which takes in to account the effect
182+
collector-base voltage variations have on the collector-base depletion region. In many cases this
183+
effectively means that the collector current has a dependency on the collector-emitter voltage.
184+
185+
- `use_advanced_continuation`: When false, the `C_jC` and `C_jE` non-linear capacitance curves use
186+
a simplified linear continuation starting when `V_CB` and `V_EB` are 0, respectively. If `true`, the `Z_C` and `Z_E` parameters
187+
are used to start the linear continuation at `Phi_C - Z_C` and `Phi_E - Z_E`.
188+
189+
# Connectors
190+
- `b` Base Pin
191+
- `c` Collector Pin
192+
- `e` Emitter Pin
193+
- `s` Substrate Pin, only available when `use_substrate = true`
194+
195+
# Parameters
196+
- `B_F`: Forward beta
197+
- `B_R`: Reverse beta
198+
- `Is`: Saturation current
199+
- `V_T`: Thermal voltage at 300K
200+
- `V_A`: Inverse Early voltage
201+
- `phi_C`: Collector junction exponent
202+
- `phi_E`: Emitter junction exponent
203+
- `Z_C`: Collector junction offset
204+
- `Z_E`: Emitter junction offset
205+
- `Tau_f`: Forward transit time
206+
- `Tau_r`: Reverse transit time
207+
- `C_jC0`: Collector junction capacitance coefficient
208+
- `C_jE0`: Emitter junction capacitance coefficient
209+
- `C_CS`: Collector-substrate capacitance
210+
- `gamma_C`: Collector junction exponent
211+
- `gamma_E`: Emitter junction exponent
212+
- `NF`: Forward emission coefficient
213+
- `NR`: Reverse emission coefficient
214+
"""
215+
216+
@mtkmodel PNP begin
217+
@variables begin
218+
V_EB(t)
219+
V_CB(t)
220+
ICC(t)
221+
IEC(t)
222+
223+
C_jC(t)
224+
C_jE(t)
225+
C_DC(t)
226+
C_DE(t)
227+
228+
I_sub(t)
229+
V_sub(t)
230+
V_CS(t)
231+
end
232+
233+
@structural_parameters begin
234+
use_substrate = false
235+
use_Early = true
236+
use_advanced_continuation = false
237+
end
238+
239+
@components begin
240+
b = Pin()
241+
e = Pin()
242+
c = Pin()
243+
244+
if use_substrate
245+
s = Pin()
246+
end
247+
end
248+
249+
@parameters begin
250+
B_F = 50.0, [description = "Forward beta"]
251+
B_R = 0.1, [description = "Reverse beta"]
252+
Is = 1e-16, [description = "Saturation current"]
253+
V_T = 0.026, [description = "Thermal voltage at 300K"]
254+
255+
if use_Early
256+
V_A = 0.02, [description = "Inverse Early voltage"]
257+
end
258+
259+
phi_C = 0.8, [description = "Collector junction scaling factor"]
260+
phi_E = 0.6, [description = "Emitter junction scaling factor"]
261+
262+
if use_advanced_continuation
263+
Z_C = 0.1, [description = "Collector junction offset"]
264+
Z_E = 0.1, [description = "Emitter junction offset"]
265+
end
266+
267+
Tau_f = 0.12e-9, [description = "Forward transit time"]
268+
Tau_r = 5e-9, [description = "Reverse transit time"]
269+
270+
C_jC0 = 0.5e-12, [description = "Collector-junction capacitance coefficient"]
271+
C_jE0 = 0.4e-12, [description = "Emitter-junction capacitance coefficient"]
272+
273+
C_CS = 1e-12, [description = "Collector-substrate capacitance"]
274+
275+
gamma_C = 0.5, [description = "Collector junction exponent"]
276+
gamma_E = 1.0 / 3.0, [description = "Emitter junction exponent"]
277+
278+
NF = 1.0, [description = "Forward ideality exponent"]
279+
NR = 1.0, [description = "Reverse ideality exponent"]
280+
end
281+
282+
@equations begin
283+
V_EB ~ e.v - b.v
284+
V_CB ~ c.v - b.v
285+
286+
ICC ~ Is * (exp(V_EB / V_T) - 1)
287+
IEC ~ Is * (exp(V_CB / V_T) - 1)
288+
289+
if !use_advanced_continuation
290+
C_jC ~ ifelse(V_CB / phi_C > 0.0, 1 + gamma_C * V_CB / phi_C,
291+
(C_jC0) / (1 - V_CB / phi_C)^gamma_C)
292+
C_jE ~ ifelse(V_EB / phi_E > 0.0, 1 + gamma_E * V_EB / phi_E,
293+
(C_jE0) / (1 - V_EB / phi_E)^gamma_E)
294+
end
295+
296+
if use_advanced_continuation
297+
C_jC ~ if V_CB > phi_C - Z_C
298+
((C_jC0 * gamma_C * (1 - ((phi_C - Z_C) / phi_C))^(-gamma_C - 1)) / phi_C) *
299+
V_CB -
300+
((C_jC0 * gamma_C * (1 - ((phi_C - Z_C) / phi_C))^(-gamma_C - 1)) / phi_C) *
301+
(phi_C - Z_C) + (C_jC0) / (1 - (phi_C - Z_C) / phi_C)^gamma_C
302+
else
303+
(C_jC0) / (1 - V_CB / phi_C)^gamma_C
304+
end
305+
306+
C_jE ~ if V_EB > phi_E - Z_E
307+
((C_jE0 * gamma_E * (1 - ((phi_E - Z_E) / phi_E))^(-gamma_E - 1)) / phi_E) *
308+
V_BE -
309+
((C_jE0 * gamma_E * (1 - ((phi_E - Z_E) / phi_E))^(-gamma_E - 1)) / phi_E) *
310+
(phi_E - Z_E) + (C_jE0) / (1 - (phi_E - Z_E) / phi_E)^gamma_E
311+
else
312+
(C_jE0) / (1 - V_BE / phi_E)^gamma_E
313+
end
314+
end
315+
316+
C_DE ~ Tau_f * (Is / (NF * V_T)) * exp(V_EB / (NF * V_T))
317+
C_DC ~ Tau_r * (Is / (NR * V_T)) * exp(V_CB / (NR * V_T))
318+
319+
if use_substrate
320+
s.i ~ I_sub
321+
s.v ~ V_sub
322+
V_CS ~ c.v - V_sub
323+
end
324+
325+
if !use_substrate
326+
V_sub ~ c.v
327+
end
328+
329+
I_sub ~ ifelse(use_substrate, -C_CS * D(V_CS), -C_CS * D(V_sub))
330+
331+
c.i ~ IEC / B_R - (ICC - IEC) * ifelse(use_Early, (1 - V_CB * V_A), 1.0) +
332+
(C_jC + C_DC) * D(V_CB) - I_sub
333+
b.i ~ -IEC / B_R - ICC / B_F - (C_jC + C_DC) * D(V_CB) - (C_jE + C_DE) * D(V_EB)
334+
e.i ~ -c.i - b.i - I_sub
128335
end
129336
end

0 commit comments

Comments
 (0)