# Chapter06:Single-Stage Integrated- Circuit Amplifiers¶

## Ex6.1:pg-553¶

In :
# 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)"

0.23 = V_OV (V)
0.71 = V_GS (V)
0.76 = V_BE (V)


## Ex6.2:pg-556¶

In :
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 NMOS transistor
0.73 = g_m (mA/V)
R_in is infinite
20.0 = r_o (kohm)
14.6 = A_O (V/V)
For npn transistor
4.0 = g_m (mA/V)
25.0 = R_in (Kohm)
350.0 = r_o (Kohm)
1400.0 = A_O (V/V)


## Ex6.3:pg-559¶

In :
# 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

For npn transistor
The data calculated for I_C=10uA
0.4 = g_m (mA/V)
3500 =r_o (Kohm)
1400.0 = A_O (V/V)
4.0 = C_de (fF)
10.0 = C_je (fF)
14.0 = C_pi (fF)
5.0 = C_u (fF)
3.4 = f_T (GHz)
63.7 = f_t (MHz)
The data calculated for I_C=100uA
4.0 = g_m (mA/V)
350 =r_o (Kohm)
1400.0 = A_O (V/V)
40.0 = C_de (fF)
10.0 = C_je (fF)
50.0 = C_pi (fF)
5.0 = C_u (fF)
11.6 = f_T (GHz)
636.6 = f_t (MHz)
The data calculated for I_C=1mA
40.0 = g_m (mA/V)
35 =r_o (Kohm)
1400.0 = A_O (V/V)
0.0 = C_de (fF)
10.0 = C_je (fF)
410.0 = C_pi (fF)
5.0 = C_u (fF)
15.3 = f_T (GHz)
6366.2 = f_t (MHz)
The data calculated for I_D = 10uA
1.2 = (W/L)
0.1 = g_m (mA/V)
200 =r_o (Kohm)
16.0 = A_O (V/V)
1.03 = C_gs (fF)
0.29 = C_gd (fF)
9.7 =f_T (GHz)
12.7 =f_t (MHz)
The data calculated for I_D = 100uA
12.0 =(W/L)
0.8 = g_m (mA/V)
20 =r_o (Kohm)
16.0 =A_O (V/V)
10.3 =C_gs (fF)
2.9 =C_gd (fF)
9.7 =f_T (GHz)
127 =f_t (MHz)
The data calculated for I_D = 1mA
120.0 =(W/L)
8.0 = g_m (mA/V)
2 =r_o (Kohm)
16.0 =A_O (V/V)
103.0 =C_gs (fF)
28.8 =C_gd (fF)
9.7 =f_T (GHz)
1273 =f_t (MHz)


## Ex6.4:pg-565¶

In :
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)"

0.316 = V_min (V)
0.2 = r_o2 (Mohm)
5.0 = The correspondng change in I_O (mA)


## Ex6.5:pg-574¶

In :
# 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)
# the answer in the textbook is slightly different due to approximation

9794 = w_H (rad/s)


## Ex6.6:pg-576¶

In :
# 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)"

-10.8 = Midband frequency gain A_M (V/V)
128.3 = Upper 3dB frequency f_H (KHz)


## Ex6.7:pg-580¶

In :
# 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)"

9.9 = Z_1 (Kohm)
0.99 = Z_2 (Mohm)
-49.8 = (V_o/V_sig) (V/V)
157.6 = f_3dB (KHz)


## Ex6.8:pg-586¶

In :
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)"

0.63 =g_m1 (mA/V)
200.0 = r_o1 (Kohm)
100.0 = r_o2 (Kohm)
-42.0 = A_v (v/V)
1.13 = V_SG (V)
2.47 = V_OA (V)
0.88 --- 0.93 = Coordinates of the extremities of the amplifier V_IB and V_IA
42.8 = Large signal voltage gain (V/V)


## Ex6.9:pg-593¶

In :
# 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/(-2*math.pi);
f_P1=s/(-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)"

1.0 = g_m (mA/V)
18.0 = r_o1 (ohm)
21.6 = r_o2 (Kohm)
9.82 = R_L (Kohm)
-12.2 = A_m (V/V)
86.1 = C_in (fF)
184 = f_H (MHz)
142.0 = R_gd (Kohm)
200 = T_gs (ps)
709 = T_gd (ps)
246.0 = T_CL (ps)
1155 = T_H (ps)
137 = f_H (MHz)
40.0 = f_Z (MHz)
145.4  and  2.4 The frequencies f_P1  (MHz) and f_P2 (GHz) are found as the roots of the denominator frequency
145.4  = better estimate for f_H (MHz)


## Ex6.10:pg-599¶

In :
# 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

540.0 = f_H (MHz)
6.6 = f_t (GHz)
40.0 = f_Z (GHz)
2.5 = g_m (mA/V)
4.5 = r_o1 (Kohm)
5.4 = r_o2 (Kohm)
2.5 = R_L (Kohm)
-6.14 = A_M (V/V)
2.16 = f_H (GHz)
13.3 = f_t (GHz)


## Ex6.11:pg-609¶

In :
# 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)"

28.0 = A_vo (V/V)
4.2 = R_in (Kohm)
298 = Kohm
7.0 = G_v (V/V)
0.94 = G_is (A/A)
0.7 = G_i (A/A)
366 = f_H (MHz)


## Ex6.12:pg-620¶

In :
# 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)"

25.0 = A_o (V/V)
-12.5 = A_v (V/V)
1025.0 = T_H (ps)
155.3 = f_H (MHz)
1.94 = f_t (GHz)
25.0 = A_o1 (V/V)
31.0 = A_vo2 (V/V)
1.3 = R_in2 (kohm)
1.2 = R_d1 (Kohm)
640.0 = R_out (Kohm)
-1.5 = (v_o1/v_i) (V/V)
-23.5 = A_v (V/V)
653.0 = T_H (ps)
653.0 = T_H (ps)
653.0 = T_H (ps)
-12.5 = A_v (V/V)
150.0 = T_H (ps)
1.06 = f_H (GHz)
13.3 = f_t (GHz)
-387.5 = A_v (V/V)
21.3 = R_in2 (Kohm)
10.3 = R_d1 (Kohm)
5110.0 = T_H (ps)
31.1 = f_H (MHz)
12.1 = f_t (GHz)


## Ex6.13:pg-642¶

In :
# 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

2.5 = r_pi (Kohm)
13.9 = C_pi (pF)
253.0 = R_in (Kohm)
0.98 = (V_b1/V_sig) (V/V)
1.0 = (V_b2/V_b1) (V/V)
-160.0 = (V_o/V_b2) (V/V)
-159 = A_M (V/V)
3.9 = R_u1 (Kohm)
65.0 = R_pi1 (ohm)
62.4 = R_pi2 (ohm)
14.05 = R_u2 (Kohm)
37.0 = T_H (ns)
4.3 = f_H (MHz)
-61.54 = A_M (V/V)
1.54 = R_pi (Kohm)
251.7 = R_u (Kohm)
524.8 = T_H (ns)
303 = f_H (KHz)


## Ex6.14:pg-654¶

In :
#  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

0.58 = V_BE1 (V)
941.5 = R_1 (kohm)
9.3 = R_2 (kohm)
11.5 = R_3 (kohm)