# Consider a design of the folded-cascode op amp
I=200*10.0**-6; # (A)
I_B=250.0*10**-6; # (A)
V_OV=0.25; # (V)
k_n=100.0*10**-6; # k_n=k'_n (A/V**2)
k_p=40*10.0**-6; # k_p=k'_p (A/V**2)
V_A=20.0; # V_A=V'_A (V/um)
V_DD=2.5; # (V)
V_SS=2.5; # (V)
V_t=0.75; # (V)
L=1*10.0**-6; # (m)
C_L=5*10.0**-12; # (F)
print "Data calculated for Q1"
I_D=I/2;
print round(I_D*1e6),"= I_D (microA)"
g_m=2*I_D/V_OV;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_D;
print r_o/1000,"= r_o (Kohm)"
WbyL=2*I_D/(k_n*V_OV**2); # WbyL =W/L
print WbyL,"= W/L"
print "Data calculated for Q2"
I_D=I/2;
print round(I_D*1e6),"= I_D (microA)"
g_m=2*I_D/V_OV;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_D;
print r_o/1000,"= r_o (Kohm)"
WbyL=2*I_D/(k_n*V_OV**2); # WbyL =W/L
print WbyL,"= W/L"
print "Data calculated for Q3"
I_D=I_B-I/2;
print round(I_D*1e6),"= I_D (microA)"
g_m=2*I_D/V_OV;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_D;
print int(r_o/1000),"= r_o (Kohm)"
WbyL=2*I_D/(k_p*V_OV**2); # WbyL =W/L
print WbyL,"= W/L"
print "Data calculated for Q4"
I_D=I_B-I/2;
print round(I_D*1e6),"= I_D (microA)"
g_m=2*I_D/V_OV;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_D;
print int(r_o/1000),"= r_o (Kohm)"
WbyL=2*I_D/(k_p*V_OV**2); # WbyL =W/L
print WbyL,"= W/L"
print "Data calculated for Q5"
I_D=I_B-I/2;
print round(I_D*1e6),"= I_D (microA)"
g_m=2*I_D/V_OV;
print g_m,"= g_m (mA/V)"
r_o=V_A/I_D;
print int(r_o/1000),"= r_o (Kohm)"
WbyL=2*I_D/(k_n*V_OV**2); # WbyL =W/L
print WbyL,"= W/L"
print "Data calculated for Q6"
I_D=I_B-I/2;
print round(I_D*1e6),"= I_D (microA)"
g_m=2*I_D/V_OV;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_D;
print int(r_o/1000),"= r_o (Kohm)"
WbyL=2*I_D/(k_n*V_OV**2); # WbyL =W/L
print WbyL,"= W/L"
print "Data calculated for Q7"
I_D=I_B-I/2;
print round(I_D*1e6),"= I_D (microA)"
g_m=2*I_D/V_OV;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_D;
print int(r_o/1000),"= r_o (Kohm)"
WbyL=2*I_D/(k_n*V_OV**2); # WbyL =W/L
print WbyL,"= W/L"
print "Data calculated for Q8"
I_D=I_B-I/2;
print round(I_D*1e6),"= I_D (microA)"
g_m=2*I_D/V_OV;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_D;
print int(r_o/1000),"= r_o (Kohm)"
WbyL=2*I_D/(k_n*V_OV**2); # WbyL =W/L
print WbyL,"= W/L"
print "Data calculated for Q9"
I_D=I_B;
print round(I_D*1e6),"= I_D (microA)"
g_m=2*I_D/V_OV;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_D;
print int(r_o/1000),"= r_o (Kohm)"
WbyL=2*I_D/(k_p*V_OV**2); # WbyL =W/L
print WbyL,"= W/L"
print "Data calculated for Q10"
I_D=I_B;
print round(I_D*1e6),"= I_D (microA)"
g_m=2*I_D/V_OV;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_D;
print int(r_o/1000),"= r_o (Kohm)"
WbyL=2*I_D/(k_p*V_OV**2); # WbyL =W/L
print WbyL,"= W/L"
print "Data calculated for Q11"
I_D=I;
print round(I_D*1e6),"= I_D (microA)"
g_m=2*I_D/V_OV;
print round(g_m*1e3,1),"= g_m (mA/V)"
r_o=V_A/I_D;
print r_o/1000,"= r_o (Kohm)"
WbyL=2*I_D/(k_n*V_OV**2); # WbyL =W/L
print WbyL,"= W/L"
gmro=160; # gmro=g_m*r_o
print gmro,"= g_m*r_o for all transistors is (V/V)"
V_GS=1;
print V_GS,"= V_GS for all transistors is (V)"
V_ICMmin=-V_SS+V_OV+V_OV+V_t;
print V_ICMmin,"= The lowest value of input common mode voltage (V)"
V_ICMmax=V_DD-V_OV+V_t;
print V_ICMmax,"= The highest value of input common mode voltage (V)"
v_omin=-V_SS+V_OV+V_OV+V_t;
print v_omin,"= The lowest value of output swing allowable (V)"
v_omax=V_DD-V_OV-V_OV;
print v_omax,"= The highest value of output swing allowable (V)"
r_o2=200.0*10**3; # r_o calculated for Q2
r_o10=80.0*10**3; # r_o calculated for Q10
R_o4=gmro*(r_o2*r_o10)/(r_o2+r_o10);
r_o8=133333.0; # r_o calculated for Q8
R_o6=gmro*r_o8;
R_o=R_o4*R_o6/(R_o4+R_o6);
print round(R_o/1e6,1),"= Output resistance (Mohm)"
G_M=0.0008;
A_v=G_M*R_o;
print round(A_v),"= Voltage gain (V/V)"
f_t=G_M/(2*math.pi*C_L);
print round(f_t/1e6,1),"= Unity gain bandwidth (MHz)"
f_P=f_t/A_v;
print round(f_P/1e3),"= Dominant pole frequency (KHz)"
SR=I/C_L;
print round(SR/1e6),"= Slew Rate (V/microsecond)"
I_t=0.5*10**-3; # total current
V_S=5; # Supply voltage
P_D=I_t*V_S;
print round(P_D*1e3,1),"= Power dissipated (mW)"