import math
V1=15.;##positive supply voltage
V2=-15.;##negative supply voltage
Veb12=-0.6;
Vbe11=0.6;
Rs=40.;
Iref=(V1-V2-Veb12-Vbe11)/Rs;
print"%s %.2f %s"%('\nreference current= ',Iref,' mA\n')
Ic10=19.;
Ic1=Ic10/2.;
print"%s %.2f %s"%('\nIc1=Ic2=Ic3=Ic4= ',Ic1,'microA\n')
Ic1=Ic1*0.001;##mA
Vbe7=0.6;
Vbe6=0.6;
Ic6=Ic1;
R2=1.;
Vc6=Vbe7+Vbe6+Ic6*R2+V2;
print"%s %.2f %s"%('\nvoltage at collector of Q6= ',Vc6,' V\n')
import math
##Example 13.2
Iref=0.72;
Ic17=0.75*Iref;
print"%s %.2f %s"%('\ncollector currents in Q17= ',Ic17,' mA\n')
b=200.;
Ib17=Ic17/b;
Ie17=Ic17;
R8=0.100;
Vbe17=0.6;
R9=50.;
Ic16=Ib17+(Ie17*R8+Vbe17)/R9;
Ic16=Ic16*1000.;
print"%s %.2f %s"%('\ncollector current in Q16= ',Ic16,' microA\n')
import math
##Example 13.3
Is1=10**-14;##reverse saturation currents for Q18 Q19
Is2=3*10**-14;##reverse saturation currents for Q14 Q20
Iref=0.72;
Vt=0.026;
Ic13a=0.25*Iref;
print"%s %.2f %s"%('\nIc13a= ',Ic13a,' mA\n')
Vbe19=0.6;
R10=50.;
Ir1o=Vbe19/R10;
print"%s %.2f %s"%('\ncurrent in Ro= ',Ir1o,' mA\n')
Ic19=Ic13a-Ir1o;
print"%s %.2f %s"%('\ncurrent in Q19 = ',Ic19,'mA\n')
Ic19=Ic19*0.001;##A
Vbe19=Vt*math.log(Ic19/Is1);
print"%s %.2f %s"%('\nB-E voltage of Q19= ',Vbe19,' V\n')
b=200.;
Ic19=Ic19*10**6;##micro A
Iv19=Ic19*1000.;
Ib18=Ic19/b;
Ir1o=Ir1o*1000.;
print"%s %.2f %s"%('\nbase current in Q18= ',Ib18,' microA\n')
Ic18=Ir1o+Ib18;
print"%s %.2f %s"%('\ncurrents in Q18= ',Ic18,' microA\n')
Ic18=Ic18*10**-6;
Vbe18=Vt*math.log(Ic18/Is1);
print"%s %.2f %s"%('\nB-E voltage of Q18= ',Vbe18,' V\n')
Vbb=Vbe18+Vbe19;
print"%s %.2f %s"%('\nvoltage difference Vbb= ',Vbb,' V\n')
Ic14=Is2*math.exp(Vbb/(2.*Vt));
Ic14=Ic14*10**6;##micro A
print"%s %.2f %s"%('\nquiescent currents in Q14 and Q20 ',Ic14,'microA\n')
import math
##Example 13.4
b=200.;
Va=50.
Vt=0.026;
R2=1.;
Ic6=0.0095;
Ic4=Ic6;
Ic16=0.0158;
Ic17=0.54;
r17=b*Vt/Ic17;
print"%s %.2f %s"%('\ninput resistance to gain stage= ',r17,' KOhm\n')
R9=50.;
R8=0.100;
x=r17+(1.+b)*R8;
Re=x*R9/(x+R9);
print"%s %.2f %s"%('\nRe= ',Re,' KOhm\n')
r16=b*Vt/Ic16;
print"%s %.2f %s"%('\nr16= ',r16,' KOhm\n')
Ri2=r16+(1.+b)*Re;
Ri2=Ri2*0.001;##MOhm
print"%s %.2f %s"%('\nRi2= ',Ri2,' KOhm\n')
r6=b*Vt/Ic6;
print"%s %.2f %s"%('\nresistance of the active load= ',r6,' KOhm\n')
gm=Ic6/Vt;
print"%s %.2f %s"%('\ntransconductance = ',gm,'mA/V\n')
ro6=Va/Ic6;
ro6=ro6*0.001;##MOhm
print"%s %.2f %s"%('\nro6= ',ro6,' MOhm\n')
R=ro6*(1.+gm*R2*r6/(R2+r6));
print"%s %.2f %s"%('\neffective resistance of active load= ',R,' MOhm\n')
ro4=Va/Ic4;
ro4=ro4*0.001;##Mohm
print"%s %.2f %s"%('\nResistance ro4= ',ro4,' KOhm\n')
Icq=9.5;
x=Ri2*R/(R+Ri2);
y=ro4*x/(ro4+x);
Ad=-y*Icq/Vt;
print"%s %.2f %s"%('\nsmall signal differential voltage gain=\n',Ad,'')
import math
##Example 13.5
bp=50.;
bn=200.;
Va=50.;
R9=50.;
R8=0.100;
Rl=2.;
Vt=0.026;
Ri2=4070.;
Ic20=0.138;
r20=bp*Vt/Ic20;
print"%s %.2f %s"%('\nr20= ',r20,' KOhm\n')
R20=r20+(1.+bp)*Rl;
print"%s %.2f %s"%('\nR20= ',R20,' KOhm\n')
Ic13A=0.18;
R19=Va/Ic13A;
print"%s %.2f %s"%('\nR19= ',R19,' KOhm\n')
r22=bp*Vt/Ic13A;
print"%s %.2f %s"%('\nr22= ',r22,' KOhm\n')
Ri3=r22+(1.+bp)*R19*R20/(R19+R20);
Ri3=Ri3*0.001;##MOhm
print"%s %.2f %s"%('\ninput resistance to the output stage= ',Ri3,' MOhm\n')
Ic13B=0.54;
R=Va/Ic13B;
print"%s %.2f %s"%('\neffective resistance of the active load= ',R,' KOhm\n')
Ic17=Ic13B;
R17=Va/Ic17;
print"%s %.2f %s"%('\noutput resistance Ro17 = ',R17,'KOhm\n')
Ri3=Ri3*1000.;##KOhm
r17=9.63;
x=R17*Ri3/(Ri3+R17);
y=x*R/(R+x);
A=-bn*R9*(1.+bn)*y/(Ri2*(R9+r17+(1.+bn)*R8));
print"%s %.2f %s"%('\nsmall signal voltage gain=\n',A,'')
import math
##Example 13.6
Ic20=2.;
bn=200.;
bp=50.;
Va=50.;
r17=9.63;
r22=7.22;
R20=0.260;
gm17=20.8;
ro17=92.6;
Ro13B=92.6;
R8=0.100;
Rc17=ro17*(1.+gm17*R8*r17/(R8+r17));
print"%s %.2f %s"%('\nRc17= ',Rc17,' KOhm\n')
Rc22=(r22+Rc17*Ro13B/(Rc17+Ro13B))/(1.+bp);
print"%s %.2f %s"%('\nRc22= ',Rc22,' KOhm\n')
Ic13A=0.18;
Rc19=Va/Ic13A;
print"%s %.2f %s"%('\nRc19= ',Rc19,' KOhm\n')
Rc20=(R20+Rc22*Rc19/(Rc22+Rc19))/(1.+bp);
print"%s %.2f %s"%('\nRc20= ',Rc20,' KOhm\n')
Rc20=Rc20*1000.;##Ohm
R3=22.;
Ro=R3+Rc20;
print"%s %.2f %s"%('\noutput resistance= ',Ro,' Ohm\n')
import math
##Example 13.7
Av2=285.;
C1=30.;
Ci=C1*(1.+Av2);
print"%s %.2f %s"%('\ninput capacitance= ',Ci,' pF\n')
Ri2=4.07;
Ract=7.18;
ro4=5.26;
Ro1=Ract*ro4/(Ract+ro4);
print"%s %.2f %s"%('\ngate stage input resistance= ',Ro1,' MOhm \n')
Req=Ro1*Ri2/(Ri2+Ro1);
print"%s %.2f %s"%('\nequivalent resistance= ',Req,' MOhm\n')
Req=Req*10**6;##Ohm
Ci=Ci*10**-12;##F
fPD=1/(2.*math.pi*Req*Ci);
print"%s %.2f %s"%('\ndominant pole frequency = ',fPD,' Hz\n')
import math
##Example 13.9
##lambda=y
y=0.02;
##W/L=x and u*Cox/2=t
x=12.5;
t=10.;
Kp1=x*t;
print"%s %.2f %s"%('\nconduction parameters of M1 and M2= ',Kp1,' microA/V^2\n')
Kp1=Kp1*0.001;##mA/V^2
Id=0.0199;
ro2=1./(y*Id);
ro2=ro2*0.001;##Mohm
print"%s %.2f %s"%('\noutput resistance= MOhm\n',ro2,'')
Iq=0.0397;
ro2=ro2*1000.;##Kohm
ro4=ro2;
Ad=math.sqrt(2.*Kp1*Iq)*ro2*ro4/(ro2+ro4);
print"%s %.2f %s"%('\nthe gain of input stage= \n',Ad,'')
Kn7=0.250;
Id7=Iq;
gm7=2.*math.sqrt(Kn7*Id7)
print"%s %.2f %s"%('\ntransconductance of M7= ',gm7,' mA/V\n')
ro7=1./(y*Id7);
ro7=ro7*0.001;
print"%s %.2f %s"%('\noutput resistance of M7 and M8 = ',ro7,'MOhm\n')
ro7=ro7*1000.;##Kohm
ro8=ro7;
Av2=gm7*ro7*ro8/(ro7+ro8);
print"%s %.2f %s"%('\ngain of the second stage=\n',Av2,'')
Av=Ad*Av2;
print"%s %.2f %s"%('\noverall voltage gain=\n',Av,'')
import math
##Example 13.10
Iref=100;
Kn=80;
Kp=40;
##W/L=x
x=25;
##lambda=y
y=0.02;
Id=Iref/2.;
gm1=2.*math.sqrt(Kp*x*Id/2.);
print"%s %.2f %s"%('\ntransconductance gm1=gm8= ',gm1,' microA/V\n')
gm6=2.*math.sqrt(Kn*x*Id/2.);
print"%s %.2f %s"%('\ntransconductance= ',gm6,' microA/V\n')
ro1=1./(y*Id);
ro8=ro1;
ro6=ro1;
ro10=ro1;
print"%s %.2f %s"%('\noutput resistance ro1=ro8=ro6=ro10= ',ro1,' MOhm\n')
Id4=Iref;
ro4=1./(y*Id4);
print"%s %.2f %s"%('\nro4= ',ro4,' MOhm\n')
Ro8=gm1*ro8*ro10;
print"%s %.2f %s"%('\ncomposite output resistances = ',Ro8,'MOhm\n')
Ro6=gm6*ro6*ro4*ro1/(ro4+ro1);
print"%s %.2f %s"%('\ncomposite output resistances= ',Ro6,' MOhm\n')
Ad=gm1*Ro6*Ro8/(Ro6+Ro8);
print"%s %.2f %s"%('\ndifferential voltage gain=\n',Ad,'')
import math
##Example 13.12
Kp=0.6;
bn=200.;
Va=50.;
Vt=0.026;
Ic13=0.20;
Ri2=bn*Vt/Ic13;
print"%s %.2f %s"%('\ninput resistance to the gain stage= ',Ri2,' KOhm\n')
Iq5=Ic13;
Ad=math.sqrt(2.*Kp*Iq5)*Ri2;
print"%s %.2f %s"%('\nsmall signal voltage gain=\n',Ad,'')
import math
##Example 13.13
Va=150.;
Vt=0.026;
Ic13=0.2;
gm13=Ic13/Vt;
print"%s %.2f %s"%('\ntransconductance= ',gm13,' mA/V\n')
ro13=Va/Ic13;
print"%s %.2f %s"%('\noutput resistance= ',ro13,' KOhm\n')
Av2=gm13*ro13;
print"%s %.2f %s"%('\nvoltage gain= \n',Av2,'')
import math
##Example 13.14
Av2=5768.;
C1=12.;
Ci=C1*(1.+Av2);
print"%s %.2f %s"%('\neffective input capacitance= ',Ci,' pF\n')
Ri2=26000.;##gain stage input resistance (Ohm)
Ci=Ci*10**-12;##F
fPD=1/(2.*math.pi*Ri2*Ci);
print"%s %.2f %s"%('\ndominant pole frequency= ',fPD,' Hz\n')
Av=73254.;
fT=fPD*Av;
fT=fT*10**-6;##MHz
print"%s %.2f %s"%('\nunity gain bandwidth= ',fT,' MHz\n')