# Consider NMOS transistor
# 6.1a
I_D=100.0*10**-6; # (A)
K_n=387.0*10**-6*10; # K_n=u_n*C_ox(W/L) (A/V**2)
V_th=0.48; # (V)
V_OV=math.sqrt(2*I_D/K_n);
print round(V_OV,2),"= V_OV (V)"
V_GS=V_th+V_OV;
print round(V_GS,2),"= V_GS (V)"
# 6.1b
I_C=100*10**-6; # (A)
I_S=6*10**-18 # (A)
V_T=0.025; # (V)
V_BE=V_T*math.log(I_C/I_S);
print round(V_BE,2),"= V_BE (V)"
print "For NMOS transistor"
I_D=100*10**-6; # (A)
V_a=5; # V'_A=V_a (A)
L=0.4; # (um)
K_n=267*4/0.4*10**-6; # K_n=u_n*C_ox*(W/L) (A/V**2)
V_OV=math.sqrt(2*I_D/K_n);
g_m=math.sqrt(2*K_n*I_D)
print round(g_m*1e3,2),"= g_m (mA/V)"
print "R_in is infinite"
r_o=V_a*L/I_D;
print r_o/1000,"= r_o (kohm)"
A_O=g_m*r_o;
print round(A_O,1),"= A_O (V/V)"
print "For npn transistor"
I_C=0.1*10**-3; # collector current
B_o=100; # beta value
V_A=35; # (V)
g_m=I_C/V_T;
print round(g_m*1e3),"= g_m (mA/V)"
R_in=B_o/g_m;
print R_in/1000,"= R_in (Kohm)"
r_o=V_A/I_C;
print r_o/1000,"= r_o (Kohm)"
A_O=g_m*r_o;
print A_O,"= A_O (V/V)"
# For npn transistor
print "For npn transistor"
I_C=10.0*10**-6; # (A)
V_T=0.025; # (V)
V_A=35.0; # (V)
C_jeO=5.0*10**-15; # (F)
C_uO=5*10.0**-15; # (F)
C_L=1*10.0**-12; # (F)
print "The data calculated for I_C=10uA"
g_m=I_C/V_T;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_C;
print int(r_o/1000),"=r_o (Kohm)"
A_O=V_A/V_T;
print A_O,"= A_O (V/V)"
T_F=10*10.0**-12;
C_de=T_F*g_m;
print round(C_de*1e15,2),"= C_de (fF)"
C_je=2*C_jeO;
print round(C_je*1e15,2),"= C_je (fF)"
C_pi=C_de+C_je;
print round(C_pi*1e15,2),"= C_pi (fF)"
C_u=C_uO;
print round(C_u*1e15,2),"= C_u (fF)"
f_T=g_m/(2*math.pi*(C_pi+C_u));
print round(f_T/1e9,1),"= f_T (GHz)"
f_t=g_m/(2*math.pi*C_L);
print round(f_t/1e6,1),"= f_t (MHz)"
print "The data calculated for I_C=100uA"
I_C=100.0*10**-6;
g_m=I_C/V_T;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_C;
print int(r_o/1000),"=r_o (Kohm)"
A_O=V_A/V_T;
print A_O,"= A_O (V/V)"
T_F=10.0*10**-12;
C_de=T_F*g_m;
print round(C_de*1e15,2),"= C_de (fF)"
C_je=2*C_jeO;
print round(C_je*1e15,2),"= C_je (fF)"
C_pi=C_de+C_je;
print round(C_pi*1e15,2),"= C_pi (fF)"
C_u=C_uO;
print round(C_u*1e15,2),"= C_u (fF)"
f_T=g_m/(2*math.pi*(C_pi+C_u));
print round(f_T/1e9,1),"= f_T (GHz)"
f_t=g_m/(2*math.pi*C_L);
print round(f_t/1e6,1),"= f_t (MHz)"
print "The data calculated for I_C=1mA"
I_C=1*10.0**-3;
g_m=I_C/V_T;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_C;
print int(r_o/1000),"=r_o (Kohm)"
A_O=V_A/V_T;
print A_O,"= A_O (V/V)"
T_F=10*10**-12;
C_de=T_F*g_m;
print round(C_de*1e6,3),"= C_de (fF)"
C_je=2*C_jeO;
print round(C_je*1e15,3),"= C_je (fF)"
C_pi=C_de+C_je;
print round(C_pi*1e15,3),"= C_pi (fF)"
C_u=C_uO;
print round(C_u*1e15,2),"= C_u (fF)"
f_T=g_m/(2*math.pi*(C_pi+C_u));
print round(f_T/1e9,1),"= f_T (GHz)"
f_t=g_m/(2*math.pi*C_L);
print round(f_t/1e6,1),"= f_t (MHz)"
# For NMOS transistor
L=0.4*10**-6; # (m)
C_L=1*10.0**-12; # (F)
print "The data calculated for I_D = 10uA"
I_D=10*10.0**-6; # (A)
WbyL=0.12*I_D; # WbyL=(W/L)
print WbyL*10**6,"= (W/L)"
g_m=8*I_D;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=2/I_D;
print int(r_o/1000),"=r_o (Kohm)"
A_O=g_m*r_o;
print A_O,"= A_O (V/V)"
C_gs=(2/3.0)*WbyL*0.4*0.4*5.8+0.6*WbyL*0.4;
print round(C_gs*1e6,2),"= C_gs (fF)"
C_gd=0.6*WbyL*0.4;
print round(C_gd*1e6,2),"= C_gd (fF)"
f_T=g_m/(2*math.pi*(C_gs*10**-15+C_gd*10**-15));
print round(f_T/1e15,1),"=f_T (GHz)"
f_t=g_m/(2*math.pi*C_L)
print round(f_t/1e6,1),"=f_t (MHz)"
print "The data calculated for I_D = 100uA"
I_D=100.0*10**-6; # (A)
WbyL=0.12*I_D; # WbyL=(W/L)
print WbyL*10**6,"=(W/L)"
g_m=8*I_D;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=2/I_D;
print int(r_o/1000),"=r_o (Kohm)"
A_O=g_m*r_o;
print A_O,"=A_O (V/V)"
C_gs=(2/3.0)*WbyL*0.4*0.4*5.8+0.6*WbyL*0.4;
print round(C_gs*1e6,1),"=C_gs (fF)"
C_gd=0.6*WbyL*0.4;
print round(C_gd*1e6,1),"=C_gd (fF)"
f_T=g_m/(2*math.pi*(C_gs*10**-15+C_gd*10**-15));
print round(f_T/1e15,1),"=f_T (GHz)"
f_t=g_m/(2*math.pi*C_L)
print int(f_t/1e6),"=f_t (MHz)"
print "The data calculated for I_D = 1mA"
I_D=1*10**-3; # (A)
WbyL=0.12*I_D; # WbyL=(W/L)
print WbyL*10**6,"=(W/L)"
g_m=8*I_D;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=2/I_D;
print int(r_o/1000),"=r_o (Kohm)"
A_O=g_m*r_o;
print A_O,"=A_O (V/V)"
C_gs=(2/3.0)*WbyL*0.4*0.4*5.8+0.6*WbyL*0.4;
print round(C_gs*1e6,1),"=C_gs (fF)"
C_gd=0.6*WbyL*0.4;
print round(C_gd*1e6,1),"=C_gd (fF)"
f_T=g_m/(2*math.pi*(C_gs*10**-15+C_gd*10**-15));
print round(f_T/1e15,1),"=f_T (GHz)"
f_t=g_m/(2*math.pi*C_L)
print int(f_t/1e6),"=f_t (MHz)"
# the answer in the textbook is slightly different due to approximation
V_DD=3; # (V)
I_REF=100*10**-6; # (A)
I_D1=100*10**-6; # (A)
L=1*10**-6; # (m)
W=10*10**-6; # (m)
V_t=0.7; # (V)
k_n=200*10**-6; # k_n=k'_n (A/V**2)
V_A=20; # V_A=V'_A (V)
V_OV=math.sqrt(I_D1*2*L/(k_n*W));
V_GS=V_t+V_OV;
R=(V_DD-V_GS)/I_REF;
V_Omin=V_OV;
print round(V_Omin,3),"= V_min (V)"
r_o2=V_A/I_REF;
print r_o2/1e6,"= r_o2 (Mohm)"
V_O=V_GS;
deltaV_O=1; # Change in V_O (V)
deltaI_O=deltaV_O/r_o2; # Corresponding change in I_O (A)
print (deltaI_O*1e6),"= The correspondng change in I_O (mA)"
# High frequency response of an amplifier can be characterized by th transfer function
# F_H(s)=(1-s/10**5)/(1+s/10**4)(1+s/4*10**4)
w_H=1/math.sqrt(1/10.0**8+1/(16.0*10**8)-2/10.0**10); # w_H=1/math.sqrt(1/w_P1**2+1/w_P2**2-2/w_Z1**2-2w_Z2**2)
print int(w_H),"= w_H (rad/s)"
# the answer in the textbook is slightly different due to approximation
# Example 6.6 : To determine midband gain and upper 3dB frequency
R_in=420*10**3; # (ohm)
R_sig=100*10**3; # (ohm)
g_m=4*10**-3; # (mho)
R_L=3.33*10**3; # R_L=R'_L (ohm)
C_gs=1*10**-12; # F
C_gd=C_gs;
A_M=-R_in*g_m*R_L/(R_in+R_sig)
print round(A_M,1),"= Midband frequency gain A_M (V/V)"
R_gs=R_in*R_sig/(R_in+R_sig);
R=R_gs; #R=R'
T_gs=C_gs*R_gs; # Oen circuit time constant of C_gs (s)
R_gd=R+R_L+g_m*R_L*R;
T_gd=R_gd*C_gd; # open circuit time constant of C_gd (s)
w_H=1/(T_gs+T_gd); # upper 3dB frequency w_H
f_H=w_H/(2*math.pi);
print round(f_H/1000,1),"= Upper 3dB frequency f_H (KHz)"
# 6.7a
# By miller's theorem
Z=1000.0*10**3; # (ohm)
K=-100.0; # (V/V)
R_sig=10.0*10**3; # (ohm)
Z_1=Z/(1-K);
print round(Z_1/1e3,2),"= Z_1 (Kohm)"
Z_2=Z/(1-(1/K));
print round(Z_2/1e6,2),"= Z_2 (Mohm)"
VobyVsig=-100*Z_1/(Z_1+R_sig); # VobyVsig=(V_o/V_sig)
print round(VobyVsig,1),"= (V_o/V_sig) (V/V)"
#6.7b
# Applying miller's theorem
f_3dB=1/(2*math.pi*1.01*10**-6);
print round(f_3dB/1000,1),"= f_3dB (KHz)"
k_n=200*10**-6; # (A/V**2)
W=4*10**-6; # (m)
L=0.4*10**-6; # (m)
I_REF=100*10**-6; # (A)
V_An=20; # (A)
I_D1=0.1*10**-3; # (A)
V_Ap=10; # (V)
V_DD=3; # (V)
I_D2=0.1*10**-3; # (A)
V_tp=0.6; # (V)
V_tn=0.6; # (V)
g_m1=math.sqrt(2*k_n*(W/L)*I_REF);
print round(g_m1*1e3,2),"=g_m1 (mA/V)"
r_o1=V_An/I_D1;
print r_o1/1000,"= r_o1 (Kohm)"
r_o2=V_Ap/I_D2;
print r_o2/1000,"= r_o2 (Kohm)"
A_v=-g_m1*r_o1*r_o2/(r_o1+r_o2);
print round(A_v),"= A_v (v/V)"
I_D=100*10**-6; # (A)
k_n=65*10**-6; # (A/V**2)
V_OV3=0.53; # (V)
V_SG=V_tp+V_OV3;
print V_SG,"= V_SG (V)"
V_OA=V_DD-V_OV3;
print V_OA,"= V_OA (V)"
V_IB=0.93; # (V)
V_IA=0.88; # (V)
print V_IA,"---",V_IB,"= Coordinates of the extremities of the amplifier V_IB and V_IA"
deltavI=V_IB-V_IA; # width of amplifier region
V_OB=0.33; # (V)
deltavO=V_OB-V_OA; # corresponding output range (V)
deltavObydeltavI=-deltavO/deltavI; # Large signal voltage gain (V/V)
print deltavObydeltavI,"= Large signal voltage gain (V/V)"
# Consider CMOS open source amplifier
from sympy import roots
from sympy import symbols
from sympy import solve
I_D=100.0*10**-6; # (A)
I_REF=I_D;
uC_n=387.0*10**-6; # u_n*C_ox=uC_n (A/V**2)
uC_p=86*10.0**-6; # u_n*C_ox=uC_n (A/V**2)
W=7.2*10**-6; # (m)
L=0.36*10**-6; # (m)
V_An=5*10**-6; # (A)
R_sig=10*10**3; # (ohm)
V_OV=math.sqrt(2*I_D*L/(W*uC_n));
g_m=I_D/(V_OV/2);
print round(g_m*1e3),"= g_m (mA/V)"
r_o1=5*0.36/(0.1*10**-3);
print math.ceil(r_o1/1000),"= r_o1 (ohm)"
r_o2=6*0.36/(.1*10**-3);
print round(r_o2/1000,1),"= r_o2 (Kohm)"
R_L=r_o1*r_o2/(r_o1+r_o2);
print round(R_L/1000,2),"= R_L (Kohm)"
A_m=-g_m*R_L;
print round(A_m,1),"= A_m (V/V)"
C_gs=20.0*10**-15; # (F)
C_gd=5*10.0**-15; # (F)
C_in=C_gs+C_gd*(1+g_m*R_L); # using miller equivalence
print round(C_in*1e15,1),"= C_in (fF)"
f_H=1/(2*math.pi*C_in*R_sig);
print int(f_H/1e6),"= f_H (MHz)"
R_gs=10.0*10**3; # (ohm) using open circuit time constants methods
R_L=9.82*10**3; # (ohm)
R_gd=R_sig*(1+g_m*R_L) + R_L;
print round(R_gd/1000),"= R_gd (Kohm)"
R_CL=R_L;
T_gs=C_gs*R_gs;
print int(T_gs*1e12),"= T_gs (ps)"
T_gd=C_gd*R_gd;
print int(T_gd*1e12),"= T_gd (ps)"
C_L=25*10**-15;
T_CL=C_L*R_CL;
print math.ceil(T_CL*1e12),"= T_CL (ps)"
T_H=T_gs+T_gd+T_CL;
print int(T_H*1e12),"= T_H (ps)"
f_H=1/(2*math.pi*T_H); # 3dB frequency
print int(f_H/1e6),"= f_H (MHz)"
f_Z=g_m/(2*math.pi*C_gd); # frequency of the zero
print math.ceil(f_Z/1e9),"= f_Z (MHz)"
# Denominator polynomial
#p=poly([1 1.16*10**-9 0.0712*10**-18],'s','coeff')
x = symbols('x')
s=solve(1+(1.16*10**-9)*x+(0.0712*10**-18)*x**2,x)
#print p,"Denominator polynomial"
f_P2=s[1]/(-2*math.pi);
f_P1=s[0]/(-2*math.pi)
print round(f_P2/1e6,1)," and ",round(f_P1/1e9,1), "The frequencies f_P1 (MHz) and f_P2 (GHz) are found as the roots of the denominator frequency"
print round(f_P2/1e6,1)," = better estimate for f_H (MHz)"
# Consider the CS amplifier
A_M=-12.3;# (V/V) found from Example 6.9
C_L=25.0*10**-15; # (F)
C_gd=5*10.0**-15; # (F)
R_L=9.82*10**3; # (F)
g_m=1.25*10**-3; # (mho)
f_H=1/(2*math.pi*(C_L+C_gd)*R_L); # 3dB frequency
print round(f_H/1e6),"= f_H (MHz)"
f_t=-A_M*f_H; # Unity-gain frequency - sign to make gain positive as only magnitude is considered
print round(f_t/1e9,1),"= f_t (GHz)"
f_Z=g_m/(2*math.pi*C_gd); # frequency of the zero
print round(f_Z/1e9),"= f_Z (GHz)"
I_D=400*10**-6; # I_D must be quadrupled by changing I_REF to 400uF
V_OV=0.32;
g_m=I_D/(V_OV/2);
print round(g_m*1e3,2),"= g_m (mA/V)"
r_o1=5*0.36/(0.4*10**-3);
print r_o1/1000,"= r_o1 (Kohm)"
r_o2=6*0.36/(0.4*10**-3);
print r_o2/1000,"= r_o2 (Kohm)"
R_L=(r_o1*r_o2)/(r_o1+r_o2);
print round(R_L/1000,1),"= R_L (Kohm)"
A_M=-g_m*R_L;
print round(A_M,2),"= A_M (V/V)"
f_H=1/(2*math.pi*(C_L+C_gd)*R_L);
print round(f_H/1e9,2),"= f_H (GHz)"
f_t=f_H*-A_M; # Unity gain frequency
print round(f_t/1e9,1),"= f_t (GHz)"
# the answer in the textbook is slightly different due to approximation
# Consider the common gate amplifier
g_m=1.25*10**-3; # (A/V)
r_o=18000; # (ohm)
I_D=100*10**-6; # (A)
X=0.2;
R_S=10*10**3; # (ohm)
R_L=100*10**3; # (ohm)
C_gs=20*10**-15;# (F)
C_gd=5*10**-15;# (F)
C_L=0; # (F)
gmplusgmb=g_m+0.2*g_m; # gmplusgmb=g_m+g_mb
A_vo=1+(gmplusgmb)*r_o;
print A_vo,"= A_vo (V/V)"
R_in=(r_o+R_L)/A_vo;
print round(R_in/1000,1),"= R_in (Kohm)"
R_out=r_o+A_vo*R_S;
print int(R_out/1000),"= Kohm"
G_v=A_vo*R_L/(R_L+R_out);
print round(G_v),"= G_v (V/V)"
G_is=A_vo*R_S/R_out;
print round(G_is,2),"= G_is (A/A)"
G_i=G_is*R_out/(R_out+R_L)
print round(G_i,1),"= G_i (A/A)"
R_gs=R_S*R_in/(R_S+R_in);
R_gd=R_L*R_out/(R_L+R_out);
T_H=C_gs*R_gs+C_gd*R_gd;
f_H=1/(2*math.pi*T_H);
print int(f_H/1e6),"= f_H (MHz)"
# 6.12a
# CS amplifier
g_m=1.25*10**-3;
r_o=20*10**3;
R_L=r_o*r_o/(r_o+r_o);
C_gs=20*10**-15;
R_sig=10000;
C_gd=5*10**-15;
C_L=5*10**-15;
C_db=5*10**-15;
A_o=g_m*r_o;
print A_o,"= A_o (V/V)"
A_v=-A_o/2;
print A_v,"= A_v (V/V)"
T_H=C_gs*R_sig+C_gd*((1+g_m*R_L)*R_sig+R_L)+(C_L+C_db)*R_L;
print round(T_H*1e12),"= T_H (ps)"
f_H=1/(2*math.pi*T_H);
print round(f_H/1e6,1),"= f_H (MHz)"
f_t=-A_v*f_H;
print round(f_t/1e9,2),"= f_t (GHz)"
# Cascode amplifier
g_m1=1.25*10**-3;
r_o1=20000;
X=0.2;
r_o2=20000;
R_L=20000;
A_o1=g_m1*r_o1;
print A_o1,"= A_o1 (V/V)"
gm2plusgmb2=g_m1+X*g_m;
A_vo2=1+(gm2plusgmb2)*r_o2;
print A_vo2,"= A_vo2 (V/V)"
R_out1=r_o1;
R_in2=1/(gm2plusgmb2)+R_L/A_vo2;
print round(R_in2/1000.0,1),"= R_in2 (kohm)"
R_d1=R_out1*R_in2/(R_out1+R_in2);
print round(R_d1/1000.0,1),"= R_d1 (Kohm)"
R_out=r_o2+A_vo2*r_o1;
print round(R_out/1000.0,1),"= R_out (Kohm)"
vo1byvi=-g_m1*R_d1;
print round(vo1byvi,1),"= (v_o1/v_i) (V/V)"
A_v=-A_o1*A_vo2*R_L/(R_L+R_out);
print round(A_v,1),"= A_v (V/V)"
C_gs1=20*10**-15;
R_sig=10*10**3;
gm1Rd1=1.5;
C_gd1=5*10**-15;
C_gs2=20*10**-15;
C_db2=5*10**-15;
C_gd2=5*10**-15;
C_db1=5*10**-15;
T_H=R_sig*(C_gs1+C_gd1*(1+gm1Rd1))+R_d1*(C_gd1+C_db1+C_gs2)+((R_L*R_out)/(R_L+R_out))*(C_L+C_db2+C_gd2);
f_H=1/(2*math.pi*T_H);
print round(T_H*1e12),"= T_H (ps)"
print round(T_H*1e12),"= T_H (ps)"
f_t=-A_v*f_H;
print round(T_H*1e12),"= T_H (ps)"
# 6.12b
# CS amplifier
A_v=-12.5;
R_L=10*10**3;
print A_v,"= A_v (V/V)"
T_H=(C_gd+C_L+C_db)*R_L;
print round(T_H*1e12),"= T_H (ps)"
f_H=1/(2*math.pi*T_H);
print round(f_H/1e9,2),"= f_H (GHz)"
f_t=-A_v*f_H;
print round(f_t/1e9,1),"= f_t (GHz)"
# Cascode amplifier
R_L=640*10**3;
R_out=640*10**3;
R_out1=20*10**3;
A_v=-A_o1*A_vo2*R_L/(R_L+R_out);
print A_v,"= A_v (V/V)"
R_in2=1/gm2plusgmb2+R_L/A_vo2;
print round(R_in2/1000.0,1),"= R_in2 (Kohm)"
R_d1=R_in2*R_out1/(R_in2+R_out1);
print round(R_d1/1000.0,1),"= R_d1 (Kohm)"
T_H=R_d1*(C_gd1+C_db1+C_gs2)+(R_L*R_out/(R_L+R_out))*(C_L+C_gd2+C_db2);
print round(T_H*1e12),"= T_H (ps)"
f_H=1/(2*math.pi*T_H);
print round(f_H/1e6,1),"= f_H (MHz)"
f_t=-A_v*f_H;
print round(f_t/1e9,1),"= f_t (GHz)"
# Consider a CC-CE amplifier
# at an emitter bias current of 1mA for Q_1 and Q_2
g_m=40.0*10**-3; # (A/V)
r_e=25.0; # (ohm)
B=100.0; # beta value
C_u=2*10.0**-12; # (F)
f_T=400*10.0**6 # (Hz)
r_pi= B/g_m;
print round(r_pi/1000,1),"= r_pi (Kohm)"
C_pi=g_m/(2*math.pi*f_T)-C_u;
print round(C_pi*1e12,1),"= C_pi (pF)"
R_in2=2500.0; # (ohm)
r_pi2=2500.0 # (ohm)
r_pi1=2500.0; # (ohm)
r_e1=0.025; # (ohm)
B_1=100.0; # beta value
R_in=(B_1+1)*(r_e1+R_in2);
print round(R_in/1000),"= R_in (Kohm)"
R_sig=4*10.0**3; # (ohm)
R_L=4000.0; # (ohm)
Vb1byVsig=R_in/(R_in+R_sig); # (V_b1/V_sig)
print round(Vb1byVsig,2),"= (V_b1/V_sig) (V/V)"
Vb2plusVb1=R_in2/(R_in2+r_e1); # (V_b2/V_b1)
print round(Vb2plusVb1,3),"= (V_b2/V_b1) (V/V)"
VobyVb2=-g_m*R_L; # (V_o/V_b2)
print round(VobyVb2,2),"= (V_o/V_b2) (V/V)"
A_M=VobyVb2*Vb2plusVb1*Vb2plusVb1;
print int(A_M),"= A_M (V/V)"
R_u1=R_sig*R_in/(R_sig+R_in);
print round(R_u1/1000,1),"= R_u1 (Kohm)"
R_pi1=(R_sig+R_in2)/(1+(R_sig/r_pi1)+(R_in2/r_e1)); # C_pi1 sees a resistance R_pi1
print round(R_pi1*1000,2),"= R_pi1 (ohm)"
R_out1=25+4000/101;
R_pi2=R_in2*R_out1/(R_in2+R_out1); # C_pi2 sees a resistance R_pi2
print round(R_pi2,1),"= R_pi2 (ohm)"
R_u2=(1+g_m*R_L)*R_pi2+R_L;
print round(R_u2/1000,2),"= R_u2 (Kohm)"
C_u1=2*10**-12; # (F)
R_u1=3940; # (ohm)
C_pi1=13.9*10**-12; # (F)
C_u2=2*10**-12; # (F)
C_pi2=13.9*10**-12; # (F)
T_H=C_u1*R_u1+C_pi1*R_pi1+C_u2*R_u2+C_pi2*R_pi2;
print round(T_H*1e9),"= T_H (ns)"
f_H=1/(2*math.pi*T_H);
print round(f_H/1e6,1),"= f_H (MHz)"
A_M=r_pi*(-g_m*R_L)/(r_pi+R_sig);
print round(A_M,2),"= A_M (V/V)"
R_pi=r_pi*R_sig/(r_pi+R_sig);
print round(R_pi/1000,2),"= R_pi (Kohm)"
R_u=(1+g_m*R_L)*R_pi +R_L;
print round(R_u/1000,1),"= R_u (Kohm)"
T_H=C_pi*R_pi+C_u*R_u;
print round(T_H*1e9,1),"= T_H (ns)"
f_H=1/(2*math.pi*T_H);
print int(f_H/1e3),"= f_H (KHz)"
# the answer in the textbook is slightly different due to approximation
# The circuits generate a constant current I_D=10uA which operate at a supply of 10V
V_BE=0.7; # (V)
V_t=0.025; # (V)
I_REF=10.0*10**-6; # (A)
V_DD=10.0; # (V)
I=1*10.0**-3; # (A)
V_BE1=V_BE+V_t*math.log(I_REF/I); # Voltage drop across Q_1
print round(V_BE1,2),"= V_BE1 (V)"
R_1=(V_DD-V_BE1)/(I_REF); # For the Widlar circuit we decide I_REF=1mA and V_BE1=0.7V
print round(R_1/1000,1),"= R_1 (kohm)"
R_2=(V_DD-V_BE)/I;
print R_2/1000,"= R_2 (kohm)"
R_3=(V_t/I_REF)*math.log(I/I_REF);
print round(R_3/1000,1),"= R_3 (kohm)"
# the answer in the textbook is slightly different due to approximation