# Chapter 4 - Differential amplifiers¶

## Exa 4.1 - page 317¶

In :
# Given data
V_CC= 10 # in volt
V_EE= -10 # in volt
I= 1 # in mA
I=I*10**-3 # in A
R_C= 10 # in kohm
R_C=R_C*10**3 # in kohm
V_BE=0.7 # in volt

i_C1= I/2 # in A
i_C2= i_C1 # in A
print "Value of i_C1 = %0.2f mA" %(i_C1*10**3)

V_C1= V_CC-i_C1*R_C # in V
# For V_cm=0 volt
V_E= -0.7 # in volt
V_CE1= V_C1-V_E # in volt
print "For V_cm =0, The value of V_CE1 = %0.2f Volt" %(V_CE1)

# For V_cm= -5 volt
V_cm= -5 # in V
V_B= V_cm # in V
# From V_BE= V_B-V_E
V_E= V_B-V_BE # in volt
V_CE1= V_C1-V_E # in volt
print "For V_cm =-5V, The value of V_CE1 = %0.2f Volt" %V_CE1

# For V_cm= 5 volt
V_cm= 5 # in V
V_B= V_cm # in V
V_E= V_B-V_BE # in volt
V_CE1= V_C1-V_E # in volt
print "For V_cm =5V, The value of V_CE1 = %0.2f Volt" %V_CE1

Value of i_C1 = 0.50 mA
For V_cm =0, The value of V_CE1 = 5.70 Volt
For V_cm =-5V, The value of V_CE1 = 10.70 Volt
For V_cm =5V, The value of V_CE1 = 0.70 Volt


## Exa 4.2 - page 338¶

In :
from numpy import sqrt
# Given data
V_DD= 1.5 # in V
V_SS= V_DD # in V
KnWL= 4 # in mA/V**2
KnWL=KnWL*10**-3 # in A/V**2
Vt= 0.5 # in V
I=0.4 # in mA
I=I*10**-3 #in A
R_D= 2.5 # in kΩ
R_D= R_D*10**3 # in Ω

# Part (a)
print "Part (a)"
V_OV= sqrt(I/KnWL) # in V
V_GS= V_OV+Vt # in V
print "Value of V_OV = %0.2f Volt" %V_OV
print "Value of V_GS = %0.2f Volt" %V_GS

# Part (b)
print "Part (b)"
V_CM= 0 # in volt
V_S= -V_GS # in volt
print "Value of V_S = %0.2f Volt" %V_S
I=0.4 # in mw
i_D1= I/2 # in mA
print "Value of i_D1 = %0.2f mA" %i_D1
i_D1=i_D1*10**-3 # in A
V_D1= V_DD-i_D1*R_D # in V
V_D2=V_D1 # in V
print "Value of V_D1 = %0.2f Volt" %V_D1
print "Value of V_D2 = %0.2f Volt" %V_D2

# Part (c)
print "Part (c)"
V_CM=1 # in V
V_GS= 0.82 # in V
V_G= 1 # in V
V_S= V_G-V_GS # in V
print "Value of V_S = %0.2f Volt" %V_S
i_D1= I/2 # in mA
print "Value of i_D1 = %0.2f mA" %i_D1
i_D1=i_D1*10**-3 # in A
V_D1= V_DD-i_D1*R_D # in V
V_D2=V_D1 # in V
print "Value of V_D1 = %0.2f Volt" %V_D1
print "Value of V_D2 = %0.2f Volt" %V_D2

# Part (d)
print "Part (d)"
V_CM_max= Vt+V_DD-i_D1*R_D
print "Highest value of V_CM = %0.2f Volt" %V_CM_max

# Part (e)
V_S= 0.4 # in V
print "Part (e)"
V_CM_min= -V_SS+V_S+Vt+V_OV # in V
print "Lowest value of V_CM = %0.2f Volt " %V_CM_min
V_Smin= V_CM_min-V_GS # in volt
print "Lowest value of V_S = %0.2f Volt" %V_Smin

Part (a)
Value of V_OV = 0.32 Volt
Value of V_GS = 0.82 Volt
Part (b)
Value of V_S = -0.82 Volt
Value of i_D1 = 0.20 mA
Value of V_D1 = 1.00 Volt
Value of V_D2 = 1.00 Volt
Part (c)
Value of V_S = 0.18 Volt
Value of i_D1 = 0.20 mA
Value of V_D1 = 1.00 Volt
Value of V_D2 = 1.00 Volt
Part (d)
Highest value of V_CM = 1.50 Volt
Part (e)
Lowest value of V_CM = -0.28 Volt
Lowest value of V_S = -1.10 Volt


## Exa 4.3 - page 341¶

In :
# Given data
I= 0.4 # in mA
unCox= 0.2 # in mA/V**2
i_D= I/2 # in mA
V_OV1= 0.2 # in V
V_OV2= 0.3 # in V
V_OV3= 0.4 # in V
WbyL1= 2*i_D/(unCox*V_OV1**2)
gm1= I/V_OV1 # in mA/V
WbyL2= 2*i_D/(unCox*V_OV2**2)
gm2= I/V_OV2 # in mA/V
WbyL3= 2*i_D/(unCox*V_OV3**2)
gm3= I/V_OV3 # in mA/V
print "Vov (in V)         ",V_OV1,"             ",V_OV2,"         ",V_OV3
print "W/L                ",WbyL1,"            ",round(WbyL2,1),"        ",WbyL3
print "gm(in mA/V)        ",gm1,"             ",round(gm2,2),"        ",gm3

Vov (in V)          0.2               0.3           0.4
W/L                 50.0              22.2          12.5
gm(in mA/V)         2.0               1.33          1.0


## Exa 4.4 - page 341¶

In :
# Given data
V_A= 20 # in V
R_D= 5 # in kΩ
R_D= R_D*10**3 # in Ω
I= 0.8 # in mA
I=I*10**-3 # in A
i_D= I/2 # in A
unCox= 0.2 # mA/V**2
unCox= unCox*10**-3 # in A/V**2
WbyL= 100
# Formula i_D= 1/2*unCox*WbyL*V_OV**2
V_OV= sqrt(2*i_D/(unCox*WbyL)) # in V
print "The value of V_OV = %0.2f Volts" %V_OV
gm= I/V_OV # in A/V
print "The value of gm = %0.f mA/V" %(gm*10**3)
r_o= V_A/i_D # in Ω
print "The value of r_o = %0.f kΩ" %(r_o*10**-3)
# Ad= v_o/v_id = gm*(R_D || r_o)
print "Differential gain = %0.1f V/V  " %Ad

The value of V_OV = 0.20 Volts
The value of gm = 4 mA/V
The value of r_o = 50 kΩ
Differential gain = 18.2 V/V


## Exa 4.5 - page 342¶

In :
from __future__ import division
from numpy import log10
# Given data
R_D= 5 # in kΩ
R_D= R_D*10**3 # in Ω
R_SS= 25 # in kΩ
R_SS= R_SS*10**3 # in Ω
I= 0.8 # in mA
I=I*10**-3 # in A
i_D= I/2 # in A
unCox= 0.2 # mA/V**2
unCox= unCox*10**-3 # in A/V**2
WbyL= 100
# Formula i_D= 1/2*unCox*WbyL*V_OV**2
V_OV= sqrt(2*i_D/(unCox*WbyL)) # in V
gm= i_D/V_OV # in A/V

# Part (a)
print "Differential gain = %0.f V/V" %(Ad)
Acm= -R_D/(2*R_SS) # in V/V
print "Common mode gain = %0.1f V/V" %Acm
CMRRindB= round(20*log10(CMRR)) # in dB
print "Common mode rejection ratio = %0.f dB" %CMRRindB

# Part (b)
print "Part (b) when output is taken differentially"
print "Differential gain = %0.f V/V" %Ad
Acm= 0
print "Common mode gain = %0.1f V/V "%Acm
print "Common mode rejection ratio = %0.f dB" %CMRRindB

# Part (c)
print "Part (c) when output is taken differentially but the drain resistance have a 1% mismatch."
print "Differential gain = %0.f V/V" %Ad
# delta_R_D= 1% of R_D
delta_R_D= R_D*1.0/100 # in Ω
Acm= R_D/(2*R_SS)*delta_R_D/R_D # in V/V
print "Common mode gain = %0.3f V/V" %Acm
print "Common mode rejection ratio = %0.1f dB" %CMRRindB

# Note: In the book, there is putting wrong value of Ad (20 at place of 10)
#to evaluate the value of CMRR in dB in part(c) , So the answer of CMRR in dB of Part (c) is wrong

Differential gain = 5 V/V
Common mode gain = -0.1 V/V
Common mode rejection ratio = 34 dB
Part (b) when output is taken differentially
Differential gain = 10 V/V
Common mode gain = 0.0 V/V
Common mode rejection ratio = inf dB
Part (c) when output is taken differentially but the drain resistance have a 1% mismatch.
Differential gain = 10 V/V
Common mode gain = 0.001 V/V
Common mode rejection ratio = 80.0 dB


## Exa 4.6 - page 343¶

In :
# Given data (From Exa 4.4)
R_D= 5 # in kΩ
R_D= R_D*10**3 # in Ω
R_SS= 25 # in kΩ
R_SS= R_SS*10**3 # in Ω
I= 0.8 # in mA
I=I*10**-3 # in A
i_D= I/2 # in A
unCox= 0.2 # mA/V**2
unCox= unCox*10**-3 # in A/V**2
WbyL= 100
# Formula i_D= 1/2*unCox*WbyL*V_OV**2
V_OV= sqrt(2*i_D/(unCox*WbyL)) # in V
gm= i_D/V_OV # in A/V
# gm mismatch have a negligible effect on Ad
# delta_gm= 1% of gm
delta_gm = gm*1/100 # in A/V
Acm= R_D/(2*R_SS)*delta_gm/gm
print "CMRR is %0.f dB"%CMRRindB

CMRR is 80 dB


## Exa 4.7 - page 344¶

In :
# Given data
V_CM= 0
V_BE= -0.7 # in volt
v_E= V_CM-V_BE # in volt
print "Value of v_E = %0.1f Volts" %v_E

I_E= (5-0.7)/10**3 # in A
v_B1= 0.5 # in V
v_B2= 0 # in V
# Due to Q1 is off  therefore
v_C1= -5 # in V
v_C2= I_E*10**3-5 # in V
print "Value of v_C1 = %0.1f Volts" %v_C1
print "Value of v_C2 = %0.1f Volts" %v_C2

Value of v_E = 0.7 Volts
Value of v_C1 = -5.0 Volts
Value of v_C2 = -0.7 Volts


## Exa 4.8 - page 345¶

In :
from numpy import log
# Given data
iE1_by_I= 0.99   # as it is given that iE1= 0.99 *I
VT= 0.025 # in volt
# Formula iE1= I/(1+%e**(-vid/VT))
# %e**(-vid/VT)= 1/iE1_by_I-1
vid= log( 1/iE1_by_I-1)*(-VT) # in volt
print "Input differential signal = %0.1f mV" %round(vid*10**3)

Input differential signal = 115.0 mV


## Exa 4.9 - page 345¶

In :
# Given data
Beta= 100

# Part (a)
RE= 150 # in Ω
VT= 25 # in mV
VT= VT*10**-3 # in V
IE= 0.5 # in mA
IE=IE*10**-3 # in A
re1= VT/IE #in Ω
R_id= 2*(Beta+1)*(re1+RE) # in Ω
R_id= round(R_id*10**-3) # in kΩ
print "(a) The input differential resistance = %0.1f kΩ" %R_id

# Part (b)
RC=10 #in kΩ
RC=RC*10**3 #in Ω
Rsig= 5+5 # in kΩ
VoltageGain1= R_id/(Rsig+R_id) #voltage gain from the signal source to the base of Q1 and Q2 in V/V
VoltageGain2= 2*RC/(2*(re1+RE)) # voltage gain from the bases to the output in V/V
print "(b) The overall differential voltage gain = %0.1f V/V" %Ad

# Part (c)
delta_RC= 0.02*RC
R_EE= 200 #in kΩ
R_EE=R_EE*10**3 #in Ω
Acm= RC/(2*R_EE)*delta_RC/RC #in V/V
print "(c) Common mode gain = %0.e V/V" %Acm

# Part (d)
print "(d) CMRR = %.f dB" %CMRRindB

# Part (e)
V_A= 100 # in V
r_o= V_A/(IE) # in Ω
# Ricm= (Beta+1)*(R_EE || r_o/2)
Ricm= (Beta+1)*(R_EE*(r_o/2)/(R_EE+(r_o/2)))
print "(e) Input common mode resistance = %0.1f MΩ" %(Ricm*10**-6)

(a) The input differential resistance = 40.0 kΩ
(b) The overall differential voltage gain = 40.0 V/V
(c) Common mode gain = 5e-04 V/V
(d) CMRR = 98 dB
(e) Input common mode resistance = 6.7 MΩ


## Exa 4.10 - page 347¶

In :
# Given data
delta_RDbyRD= 2/100
delta_WLbyWL= 2/100
delta_Vt= 2 #in mV
delta_Vt= delta_Vt*10**-3 # in V
#(From Exa 4.4)
V_A= 20 # in V
R_D= 5 # in kΩ
R_D= R_D*10**3 # in Ω
I= 0.8 # in mA
I=I*10**-3 # in A
i_D= I/2 # in A
unCox= 0.2 # mA/V**2
unCox= unCox*10**-3 # in A/V**2
WbyL= 100
# Formula i_D= 1/2*unCox*WbyL*V_OV**2
V_OV= sqrt(2*i_D/(unCox*WbyL)) # in V
V_OS1= V_OV/2*delta_RDbyRD # in V

# V_OS due to W/L ratio
V_OS2= V_OV/2*delta_WLbyWL # in V

# V_OS due to threshold voltage
V_OS3= delta_Vt # in V
# Total offset voltage
V_OS= sqrt(V_OS1**2+V_OS2**2+V_OS3**2) # in V
V_OS= V_OS*10**3 # in mV
print "Total offset voltage = %0.1f mV" %V_OS

Total offset voltage = 3.5 mV


## Exa 4.11 - page 348¶

In :
# Given data
WLn= 100
WLp= 200
unCox= 0.2 # mA/V**2
unCox=unCox*10**-3 #in A/V**2
I=0.8 # in mA
I=I*10**-3 #in A
V_A= 20 # in V
i_D= I/2 # in A
# Formula i_D= 1/2*unCox*WLn*V_OV**2
V_OV= sqrt(2*i_D/(unCox*WLn)) # in V
gm= I/V_OV # in A/V
print "Value of Gm = %0.1f mA/V" %(gm*10**3)
ro2= V_A/(I/2) # in ohm
ro4= ro2 # in ohm
Ro= ro2*ro4/(ro2+ro4) # in ohm
print "Value of Ro = %0.1f kΩ" %(Ro*10**-3)
# Finding the value of gm3
upCox= 0.1 # mA/V**2
upCox=upCox*10**-3 #in A/V**2
# Formula i_D= 1/2*upCox*WLp*V_OV**2
V_OV= sqrt(2*i_D/(upCox*WLp)) # in V
gm3= I/V_OV # in A/V
print "Value of |Acm| = %0.3f V/V" %(abs(Acm))
print "CMRR = %0.f dB" %(round(CMRRindB))

Value of Gm = 4.0 mA/V
Value of Ro = 25.0 kΩ
Value  of Ad = 100.0 V/V
Value of |Acm| = 0.005 V/V
CMRR = 86 dB


## Exa 4.12 - page 349¶

In :
# Given data
I=0.8 # in mA
I=I*10**-3 #in A
V_A= 100 # in V
Beta=160
VT=25 # in mV
VT= VT*10**-3 #in V
gm= (I/2)/VT # in A/V
Gm= gm # Short circuit trnsconductance in mA/V
print "The value of Gm = %0.1f mA/V" %(Gm*10**3)
ro2= V_A/(I/2) # in ohm
ro4= ro2 # in ohm
Ro= ro2*ro4/(ro2+ro4) # in ohm
print "The value of Ro = %0.1f kΩ" %(Ro*10**-3)
r_pi= Beta/gm #in Ω
Rid= 2*r_pi # in Ω
print "The value of Rid = %0.1f kΩ" %(Rid*10**-3)

The value of Gm = 16.0 mA/V
The value of Ro = 125.0 kΩ
Value  of Ad = 2000.0 V/V
The value of Rid = 20.0 kΩ


## Exa 4.13 - page 349¶

In :
# Given data
Vtp= -0.8 # in V
KpWL= 3.5 # in mA/V**2
I=0.7 # in mA
I=I*10**-3 # in A
R_D= 2 # in kΩ
R_D=R_D*10**3 # in Ω
KpWL=KpWL*10**-3 #in A/V**2
v_G1= 0 # in V
v_G2=v_G1 # in V
VSS= 2.5 # in V
VDD=VSS # in V
VCS= 0.5 # in V
print "Part (a)"
V_OV= -sqrt(I/KpWL) # in V
print "The value of V_OV = %0.2f Volts" %V_OV
V_GS= V_OV+Vtp # in V
print "The value of V_GS = %0.2f Volts" %V_GS
V_G= 0 # as gate is connected ground
v_S1= V_G-V_GS # in V
v_S2= v_S1 # in V
print "The value of v_S1 = %0.2f Volts" %v_S1
v_D1= I/2*R_D-VDD # in V
v_D2=v_D1 # in V
print "The value of v_D1 = %0.1f Volts" %v_D1
print "The value of v_D2 = %0.1f Volts" %v_D2

print "Part (b)"
V_CMmin= I*R_D/2-VDD+Vtp # in V
V_CMmax= VSS-VCS+Vtp+V_OV # in V
print "The value of V_CMmin = %0.1f Volts" %V_CMmin
print "The value of V_CMmax = %0.2f Volts" %V_CMmax

Part (a)
The value of V_OV = -0.45 Volts
The value of V_GS = -1.25 Volts
The value of v_S1 = 1.25 Volts
The value of v_D1 = -1.8 Volts
The value of v_D2 = -1.8 Volts
Part (b)
The value of V_CMmin = -2.6 Volts
The value of V_CMmax = 0.75 Volts


## Exa 4.14 - page 351¶

In :
# Given data
V_OV= 0.2 # in V
gm=1 # in mA/V
gm=gm*10**-3 # in A/V
Vt=0.8 # in V
unCox= 90 # in µA/V**2
unCox=unCox*10**-6 # in A/V**2
# gm= I/V_OV
I= gm*V_OV # in A
print "Bias current = %0.1f mA" %(I*10**3)
I_D= I/2 # in A
# Formula I_D= 1/2*unCox*WLn*V_OV**2
WbyL= 2*I_D/(unCox*V_OV**2)
print "W/L ratio is %0.1f "%WbyL

Bias current = 0.2 mA
W/L ratio is 55.6


## Exa 4.15 - page 351¶

In :
# Given data
I=0.5 # in mA
I=I*10**-3 # in A
WbyL= 50
unCox= 250 # in µA/V**2
unCox=unCox*10**-6 # in A/V**2
V_A= 10 # in V
R_D= 4 #in kΩ
R_D= R_D*10**3 #in Ω
V_OV= sqrt(I/(WbyL*unCox)) #in V
print "The value of V_OV = %0.2f V " %V_OV
gm= I/V_OV # in A/V
print "The value of gm = %0.2f mA/V" %(gm*10**3)
I_D=I/2 # in A
ro= V_A/I_D # in Ω
print "The value of ro = %0.2f kΩ" %(ro*10**-3)

The value of V_OV = 0.20 V
The value of gm = 2.50 mA/V
The value of ro = 40.00 kΩ
The value of Ad = 9.09 V/V


## Exa 4.16 - page 352¶

In :
# Given data
I=1 # in mA
I=I*10**-3 # in A
i_C=1 # in mA
i_C=i_C*10**-3 # in A
V_CC= 5 # in V
V_CM= -2 # in V
V_BE= 0.7 # in V
R_C= 3 # in kΩ
R_C= R_C*10**3 # in Ω
Alpha=1
Beta=100
V_B= 1 # in V
i_C1= Alpha*I # in A
i_C2=0   # A
v_E= V_B-V_BE # in V
print "Emitters voltage = %0.2f Volt" %v_E,
v_C1= V_CC-i_C1*R_C # in V
v_C2= V_CC-i_C2*R_C # in V
print "Output voltage is",v_C1,"V &",v_C2,"V"

Emitters voltage = 0.30 Volt Output voltage is 2.0 V & 5 V