Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import data_processing as proc
import numpy as np
import scipy.interpolate as interp
def threshold_voltage_extraction(i,v,smoothing=True,accuracy=6): # second-derivative method
v_step=np.mean(v[1:]-v[:-1])
gm,v_gm=proc.finite_difference(i, v_step,order=2,accuracy=accuracy)
f = interp.InterpolatedUnivariateSpline(v_gm, gm, k=4)
cr_pts = f.derivative().roots()
cr_pts = np.append(cr_pts, (v_gm[0], v_gm[-1])) # also check the endpoints of the interval
cr_vals = f(cr_pts)
max_index = np.argmax(cr_vals)
vth=cr_pts[max_index]
gm_max=cr_vals[max_index]
return vth, gm_max
def mos_transistor_current(vg,vd,vs=0,vth=0.8,k=1e-4,vea=50,mos_type="nmos",early=True):
if mos_type=="nmos":
vth=abs(vth)
vds=vd-vs
vgs=vg-vs
if mos_type=="pmos":
vth=abs(vth)
vds=vs-vd
vgs=vs-vg
if vgs<vth:
mode="cutoff"
elif vgs>=vds:
mode="saturation"
elif vg-vs<vds:
mode="triode"
if mode=="cutoff":
jd=0
elif mode=="saturation":
jd=k/2*(vgs-vth)**2
elif mode=="triode":
jd=k*((vgs-vth)*(vds)-(vds)**2/2)
if early:
return jd*(1+(vds)/vea)
else:
return jd