Diff pair with active load - Problem Set #6, Problem 1

*
* POWER SUPPLIES
*
vsup  100 0 2.5
vsupn 200 0 -2.5
.global 100 200

*
* AMPLIFIER SUBCIRCUIT
*
.subckt  amp (p n out)
m1  3    p   s   s   cmosn l=length w=wn
m2  out  n   s   s   cmosn l=length w=wn
m3  3    3   100 100 cmosp l=length w=wp
m4  out  3   100 100 cmosp l=length w=wp
.param wp=100u wn=50u length=1u
* The problem does not specify whether to include the body effect.
* The body effect is ignored here by connecting
* the source to the well for both M1 and M2.

it  s    200 100u
rt  s    200 1meg
*For n-chan, kp = un*cox = 550*1.38e-7 = 127 uA/V**2
*For p-chan, kp = up*cox = 250*1.38e-7 =  58 uA/V**2
.model cmosn nmos level=1 lambda=0.105263 vto=0.7  kp=127u ld=0.12u
.model cmosp pmos level=1 lambda=0.0625   vto=-0.7 kp= 58u ld=0.18u
.ends amp

*
* TWO IDENTICAL COPIES OF THE AMPLIFIER ARE USED.  ONE IS USED TO FIND
* THE DM GAIN.  THE OTHER IS USED TO FIND THE CM GAIN.  THESE TWO
* SIMULATIONS COULD HAVE BEEN RUN ONE AFTER THE OTHER USING ONE CIRCUIT,
* BUT THIS APPROACH DOES NOT ALLOW SPICE TO CALCULATE THE CMRR.
*

*
* AMPLIFIER WITH DM INPUT
*
xdm (p 0 out_dm) amp

*
* AMPLIFIER WITH CM INPUT
*
xcm (p n out_cm) amp

*
* INPUTS
*
vi p 0 0 ac 1
eic n 0 p 0 1

*
* ANALYSIS
*
.options nopage nomod
.tf v(out_dm) vi
.dc vi -0.1 0.1 0.01
.plot dc v(out_dm)
.ac dec 1 1 10
.measure ac dm_gain find vm(out_dm) at=1
.measure ac cm_gain find vm(out_cm) at=1
.measure cmrr param='dm_gain/cm_gain'
.end
