In [2]:

```
# Amplifier operates at +10-V/-10-V power supply.
A_v=9/1.0; # sinusoidal voltage input of 1V peak and sinusoidal output voltage of 9V peak
I_o=9/1000.0; # 1 kilo ohms load
print A_v,"= Voltage gain (V/V) "
print round(20*log10(A_v),1),"= Voltage gain (dB) "
I_i=0.0001 # sinusoidal current input of 0.1mA peak
A_i=I_o/I_i;
print A_i,"= Current gain (A/A) "
print round(20*log10(A_i),1),"= Current gain (dB)"
V_orms = 9/math.sqrt(2);
I_orms = 9/math.sqrt(2);
P_L=V_orms*I_orms; # output power in mW
V_irms=1/math.sqrt(2);
I_irms=0.1/math.sqrt(2);
P_I=V_irms*I_irms; # input power in mW
A_p=P_L/P_I;
print A_p,"= Power gain (W/W) "
print round(10*log10(A_p),1),"= Power gain (dB) "
P_dc=10*9.5+10*9.5; # amplifier draws a current of 9.5mA from each of its two power supplies
print P_dc,"= Power drawn from the dc supplies (mW)"
P_dissipated=P_dc+P_I-P_L;
print round(P_dissipated,1),"= Power dissipated in the amplifier (mW)"
n=P_L/P_dc*100;
print round(n,1),"= Amplifier efficiency in percentage"
```

In [3]:

```
# Amplifier has transfer characteristics v_O=10-(10**-11)*(exp**40*v_1) applies for v_1 is greater than or equal 0V and v_o is greater than or equal to 0.3V
L_l = 0.3; # limit L_-
print round(L_l,2),"=The limit L_- (V) "
v_I=1/40.0*math.log((10-0.3)/10**-11); # from the transfer characteristics and v_o=0.3V
print round(v_I,2),"=v_I in volts "
L_u=10-10**-11; # obtained by v_I=0 in transfer characteristics
print round(L_u,3),"=the limit L_+ (V) "
V_I=1/40.0*math.log((10-5)/10**-11); # V_O=5V
print round(V_I,3),"=The value of the dc bias voltage that results in V_O=5V (V)"
A_v=-10**-11*exp(40*V_I)*40; # A_v=dv_O/dv_I
print round(A_v,2),"=Gain at the operating point (V/V) "
print "NOTE the gain is negative that implies the amplifier is an inverting amplifier"
```

In [23]:

```
gainloss_in=10**6/(1*10**6+100.0*10**3); # fraction of input signal is obtained using voltage divider rule , gainloss_in= v_i1/v_s
A_v1=10*100000.0/(100000+1000); # A_v1 = v_i2/v_i1 is the voltage gain at first stage
A_v2=100*10000.0/(10000+1000); # A_v2 = v_i3/v_i2 is the voltage gain at second stage
A_v3=100/(100+10.0); # A_v3 = v_L/v_i3 is the voltage gain at the output stage
A_v=A_v1*A_v2*A_v3; # A_v is the total voltage gain
print round(A_v)," = The overall voltage gain (V/V) "
print round(20.0*log10(A_v),1),"= The overall voltage gain (dB) "
gain_src_ld=A_v*gainloss_in;
print round(gain_src_ld,2),"= The voltage gain from source to gain (V/V) "
print round(20.0*log10(gain_src_ld),1),"= The voltage gain from source to load (dB) "
A_i=10**4*A_v; # A_i=i_o/i_i=(v_L/100)/(v_i1/10**6)
print "{:.2e}".format(A_i)," = The current gain (A/A)"
print round(20.0*log10(A_i),1),"= The current gain (dB) "
A_p=818*818*10**4; # A_p=P_L/P_I=v_L*i_o/v_i1*i_i
print "{:.2e}".format(A_p),"= The power gain (W/W) "
print round(10*log10(A_p),1),"= The power gain (dB) "
```

In [4]:

```
# 1,4a
# using voltage divider rule the fraction of input signal v_be=v_s*r_pi/(r_pi+R_s)
# output voltage v_o=-g_mv_be(R_L||r_o)
r_pi=2.5*10**3; # (ohm)
R_s=5*10**3; # (ohm)
R_L=5*10**3 # (ohm)
g_m=40*10**-3; # (mho)
r_o=100*10**3; # (ohm)
gain=-(r_pi*g_m*(R_L*r_o/(R_L+r_o)))/(r_pi+R_s); # gain=v_o/v_s
print round(gain,1),"= The voltage gain (V/V) "
gain_negl_r_o=-r_pi*g_m*R_L/(r_pi+R_s);
print round(gain_negl_r_o,1),"= Gain neglecting the effect of r_o (V/V) "
# 1.4b
# Bi_b=g_m*v_be
# B is short circuit gain
B=g_m*r_pi;
print B,"= The short circuit gain (A/A) "
```

In [5]:

```
# 1.5b
R_s =20*10**3; # (ohm)
R_i =100.0*10**3; # (ohm)
C_i =60.0*10**-12; # (ohm)
u = 144.0; # (V/V)
R_o = 200.0; # (ohm)
R_L = 1000; # (ohm)
K=u/((1+R_s/R_i)*(1+R_o/R_L));
print K,"= The dc gain (V/V)"
print round(20*log10(K),2)," = The dc gain (dB) "
w_o=1/(C_i*R_s*R_i/(R_s+R_i));
print "{:.0e}".format(w_o)," = The 3-dB frequency (rad/s) "
f_o= w_o/2/math.pi;
print round(f_o/1000,1)," = Frequency (KHz) "
print "{:.0e}".format(100*w_o)," = unity gain frequency (rad/s)"
print round(100*f_o/1e6,2)," = Unity gain frequency (MHz)"
```

In [1]:

```
V_DD=5; # (V)
R=1000.0; # (ohm)
R_on=100.0; # (ohm)
V_offset=0.1; # (V)
C=10.0*10**-12; # (F)
V_OH=5; # (V)
V_OL=V_offset+(V_DD-V_offset)*R_on/(R+R_on);
T=R*C;
v_o_t_PLH=(V_OH+V_OL)/2; #to find t_PLH
t_PLH=0.69*T;# t_PLH is low to high propogtion delay
print t_PLH/1e-9,"= time required for the output to reach (V_OH+V_OL)/2 (miliseconds) "
```