L_min=0.4*10**-6; # (m)
t_ox=8*10**-9; # (s)
u_n=450*10**-4; # (A/V**2)
V_t=0.7; # (V)
e_ox=3.45*10**-11;
# 4.1a
C_ox=e_ox/t_ox;
print round(C_ox*1000,2),"= C_ox (fF/micrometer**2)"
k_n=u_n*C_ox;
print round(k_n*1e6),"= k_n (microA/V**2)"
# 4.1b
# Operation in saturation region
W=8*10**-6; # (m)
L=0.8*10**-6; # (m)
i_D=100*10**-6; # (A)
V_GS=math.sqrt(2*L*i_D/(k_n*W)) +V_t;
print round(V_GS,2),"= V_GS (V)"
V_DSmin=V_GS-V_t;
print round(V_DSmin,2),"= V_DSmin (V)"
# 4.1c
# MOSFET in triode region
r_DS=1000; # (ohm)
V_GS=1/(k_n*(W/L)*r_DS)+V_t;
print round(V_GS,2),"= V_GS (V)"
# NMOS transistor is operating in saturation region
I_D=0.4*10**-3; # (A)
V_D=0.5; # (V)
V_t=0.7; # (V)
uC_n=100*10**-6; # (A/V**2)
L=1*10**-6; # (m)
W=32*10**-6; # (m)
V_SS=-2.5; # (V)
V_DD=2.5; # (V)
V_OV=math.sqrt(I_D*2*L/(uC_n*W));
V_GS=V_t+V_OV;
print V_GS,"= V_t (V)"
V_S=-1.2; # (V)
R_S=(V_S-V_SS)/I_D;
print round(R_S/1000,2),"= R_S (Kohm)"
V_D=0.5; # (V)
R_D=(V_DD-V_D)/I_D;
print round(R_D/1000),"= R_D (Kohm)"
# FET is operating in saturation region
I_D=80*10**-6; # (A)
V_t=0.6; # (V)
uC_n=200*10**-6; # (A/V**2)
L=0.8*10**-6; # (m)
W=4*10**-6; # (m)
V_DD=3; # (V)
V_OV=math.sqrt(2*I_D/(uC_n*(W/L)));
V_GS=V_t+V_OV;
V_DS=V_GS;
V_D=V_DS;
print V_D,"V_D (V)"
R=(V_DD-V_D)/I_D;
print R/1000,"R (Kohm)"
# MOSFET is operating in triode region
V_D=0.1; # (V)
V_DD=5; # (V)
V_t=1; # (V=)
K=1*10**-3; # K=k'_n(W/L)
V_GS=5; # (V)
V_DS=0.1; # (V)
I_D=K*((V_GS-V_t)*V_DS-(V_DS**2)/2);
print I_D*1000,"=I_D (mA)"
R_D=(V_DD-V_D)/I_D;
print round(R_D/1000,1),"=R_D (Kohm)"
r_DS=V_DS/I_D;
print round(r_DS),"=r_DS (ohm)"
V_t=1; # (V)
K=1*10**-3; # K=k'_n(W/L)
V_DD=10; # (V)
R_G1=10*10**6; # (ohm)
R_G2=10*10**6; # (ohm)
R_D=6*10**3; # (ohm)
R_S=6*10**3; # (ohm)
I_D=0.5 # mA
# I_D=0.89mA will result in transistor cut off hence we take the other root of the equation
V_G=V_DD*R_G2/(R_G2+R_G1);
I_D=I_D*10**-3;
print I_D*1000,"= I_D (mA)"
V_S=I_D*R_S;
print V_S,"= V_S (V)"
V_GS=V_G-V_S;
print V_GS,"= V_GS (V)"
V_D=V_DD-R_D*I_D;
print V_D,"= V_D (V)"
# V_D>V_G-V_t the transistor is operating in saturation as initially assumed
# MOSFET is in saturation
V_DD=5; # (V)
V_D=3; # (V)
I_D=0.5*10**-3; # (A)
V_t=-1; # (V)
K=1*10**-3; # K=k'_n(W/L)
V_OV=math.sqrt(2*I_D/K);
V_GS=V_t+(-V_OV)
R_D=V_D/I_D;
V_Dmax=V_D-V_t; # - sign as magnitude of V_t is considered
R_D=V_Dmax/I_D;
print R_D/1000,"= R_D (Kohm)"
K_n =1*10**-3; # K_n=k_n*W_n/L_n (A/V**2)
K_p = 1*10**-3; # K_p=k_p*W_p/L_p (A/V**2)
V_tn= 1; # (V)
V_tp= -1; # (V)
V_I=-2.5; # (V)
V_DD=2.5; # (V)
R=10;# (kilo ohm)
# For V_I=0
I_DP=(K_p*(V_DD-V_tn)**2)/2;
I_DN=I_DP;
print round(I_DP*1000,3),"= I_DP (mA) and ",round(I_DN*1000,1),"=I_DN (A) for V_I=0V"
print 0,"= V_O for V_I =0V"
# For V_I=2.5V
# I_DN=K_N(V_GS-V_tn)V_DS
# I_DN=v_O/R
# Solving the two equations we get
I_DN=0.244*10**-3; # (V)
V_O=-2.44; # (V)
print V_O,"= V_O and",round(I_DN*1000,2),"= I_DN for V_I=2.5V"
# For V_I=-2.5V Q_N is cut off
I_DP=2.44*10**-3; # (A)
V_O=2.44; # (V)
print V_O,"= V_O(V), ",round(I_DP*1000,2),"=I_DP (mA) and",0,"= I_DN (A) for V_I=-2.5V"
I_d=0.5*10**-3; # (A)
I_S=0.5*10**-3; # (A)
V_t=1; # (V)
K_n=1*10**-3; # K_n=k_n*W/L (A/V**2)
V_DD=15; # (V)
V_D=10; # (V)
V_S=5; # (V)
R_D=(V_DD-V_D)/I_d;
R_S=V_S/I_S;
V_OV=math.sqrt(I_d*2/K_n);
V_GS=V_t+V_OV;
V_G=V_S+V_GS;
# V_t=1.5V
# I_D=K(V_GS-V_t)**2/2
# 7=V_GS+10I_D
# solving above equations
I_D=0.455*10**-3;
deltaI_D=I_D-I_d; # Change in I_D (A)
change=deltaI_D*100/I_d; # Change in %
print round(change,2),"= Change in I_D (%)"
# Example 4.10 : Small signal analysis
V_t=1.5; # (V)
K=0.00025;#K= k_nW/L (A/V**2)
V_A=50; # (V)
I_D=1.06*10**-3; # (A)
V_D=4.4; # (V)
R_D=10000; # (ohm)
R_L=10000; # (ohm)
V_GS=V_D;
g_m=K*(V_GS-V_t);
r_o=V_A/I_D;
A_v=-g_m*(R_L*R_D*r_o)/(R_D*R_L+R_D*r_o+R_L*r_o);
print round(A_v,1),"= Voltage gain (V/V)"
R_G=10*10**6; #(ohm)
# i_i=v_i*(1-A_v)/R_G
R_in=R_G/(1-(A_v));
print round(R_in/1e6,1),"= Input resistance (Mohm)"
# v_DSmin=v_GSmin-V_t
v_i=V_t/(1+(-A_v)); # - sign to make A_v positive
print round(v_i,2),"= Largest allowable input signal (V)"
v_o=90; # (V)
v_i=9; # (V)
R_sig=100.0*10**3; # (ohm)
R_L=10.0*10**3; # (ohm)
v_sig=10; # (V)
A_vo=v_o/v_i;
print A_vo,"= A_vo (V/V)"
G_vo=v_o/A_vo;
print G_vo,"= G_vo (V/V)"
R_i=G_vo*R_sig/(A_vo-G_vo)
print R_i/1000,"= R_i in Kohm"
print "assume R_L = 10 kilo ohm is connected"
v_o=70.0; # (V)
v_i=8; # (V)
A_v=v_o/v_i;
print A_v,"= A_v (V/V)"
G_v=v_o/A_vo;
print G_v,"= G_v (V/V)"
R_o=R_L*(A_vo-A_v)/A_v;
print round(R_o/1000,2),"= R_o (Kohm)"
R_out=R_L*(G_vo-G_v)/G_v;
print round(R_out/1000,2),"= R_out (Kohm)"
R_in=(v_i*100)/(v_sig-v_i);
print R_in,"= R_in (Kohm)"
G_m=A_vo/R_o;
print G_m,"= G_m (mho)"
A_i=A_v*R_in/R_L;
print A_i,"= A_i (V/V)"
R_inL0=R_sig/((1+R_sig/R_i)*(R_out/R_o)-1); # R_in|R_L=0 (ohm)
print round(R_inL0/1000,1),"= R_in at R_L=0"
A_is=A_vo*R_inL0/R_o;
print int(A_is),"= A_is (A/A)"
# Example 4.12 : Midband gain and upper 3dB frequency
R_sig= 100.0*10**3; # (ohm)
R_G=4.7*10**6; # (ohm)
R_D=15.0*10**3; # (ohm)
R_l=15.0*10**3; # (ohm)
g_m=1*10.0**-3; # (mho)
r_o=150.0*10**3; # (ohm)
C_gs=1*10.0**-12; # (F)
C_gd=0.4*10**-12; # (F)
R_L= 1.0/(1/r_o + 1/R_D + 1/R_l)
A_M=R_G/(R_G + R_sig)*g_m*R_L;
print round(A_M),"= midband gain A_M (V/V)"
C_eq=(1+g_m*R_L)*C_gd;
C_in=C_gs+C_eq;
f_H=(R_G+R_sig)/(2*math.pi*C_in*R_sig*R_G);
print round(f_H/1000),"= f_H (KHz)"
R_G=4.7*10**6; # (ohm)
R_D=15*10**3; # (ohm)
R_L=15*10**3; # (ohm)
R_sig=100*10**3; # (ohm)
g_m=1*10**-3; # (mho)
f_L=100; # (Hz)
C_S=g_m/(2*math.pi*f_L)
print round(C_S*1e6,1),"= C_S (microF)"
f_P2=1/(2*math.pi*C_S/g_m);
f_P1=10; # (Hz)
f_P2=10; # (Hz)
C_C1=1/(2*math.pi*(R_G+R_sig)*10)
print round(C_C1*1e9,1),"= C_C1 (nanoF)"
C_C2=1/(2*math.pi*(R_D+R_L)*10)
print round(C_C2*1e6,2),"= C_C2 (microF)"