{

 "metadata": {

  "name": "",

  "signature": "sha256:aa3033a597a0bf06128c3fae6fc134561fe0b608c1a6f342b1690de7caed5ad0"

 },

 "nbformat": 3,

 "nbformat_minor": 0,

 "worksheets": [

  {

   "cells": [

    {

     "cell_type": "heading",

     "level": 1,

     "metadata": {},

     "source": [

      "Chapter07:Differential and Multistage amlplifiers"

     ]

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex7.1:pg-690"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 7.1 Analysis of differential amplifier\n",

      "# Consider the differential amplifier\n",

      "\n",

      "B=100.0; # beta value\n",

      "\n",

      "# 7.1a\n",

      "V_T=0.025; # (V)\n",

      "I_E=0.0005; # (A)\n",

      "R_E=150.0; # (ohm)\n",

      "r_e1=V_T/I_E;  # emitter resistance (ohm)\n",

      "r_e2=r_e1; # emitterA resistance (ohm)\n",

      "r_e=r_e1;\n",

      "R_id=2*(B+1)*(r_e+R_E);\n",

      "print round(R_id/1000.0),\"The input differential resistance R_id (kohm)\"\n",

      "\n",

      "# 7.1b\n",

      "R_id=40000.0; # (ohm)\n",

      "R_sig=5000.0; # (ohm)\n",

      "R_C=10000.0; # (ohm)\n",

      "R_E=150.0; # (ohm)\n",

      "A_v=R_id/(R_id+R_sig); # A_v= v_o/v_sig (V/V)\n",

      "A_V=2*R_C/(2.0*(r_e+R_E)); # A_V= v_o/v_id (V/v)\n",

      "A_d=A_v*A_V; # A_d=v_o/v_sig (V/V)\n",

      "print \"Overall differential voltage gain (V/V)\",round(A_d,-1)\n",

      "\n",

      "# 7.1c\n",

      "R_EE=200000.0; # (ohm)\n",

      "deltaR_C=0.02*R_C; # in the worst case\n",

      "A_cm=R_C*deltaR_C/(2.0*R_EE*R_C)\n",

      "print  A_cm,\"Worst case common mode gain (V/V)\"\n",

      "\n",

      "# 7.1d\n",

      "CMRR=20*math.log10(A_d/A_cm)\n",

      "print int(CMRR),\"CMRR in dB\"\n",

      "\n",

      "# 7.1e\n",

      "r_o=200000.0; #(ohm)\n",

      "R_icm=(B+1)*(R_EE*r_o/2.0)/(R_EE+r_o/2.0);\n",

      "print round(R_icm/1e6,1),\"Input common mode resistance (kohm)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "40.0 The input differential resistance R_id (kohm)\n",

        "Overall differential voltage gain (V/V) 40.0\n",

        "0.0005 Worst case common mode gain (V/V)\n",

        "98 CMRR in dB\n",

        "6.7 Input common mode resistance (kohm)\n"

       ]

      }

     ],

     "prompt_number": 15

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex7.2:pg-747"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 7.2 : Analysis of Active loaded MOS differential amplifier\n",

      "W=7.2*10**-6; # (m)\n",

      "L=0.36*10**-6; # (m)\n",

      "C_gs=29*10**-15; # (F)\n",

      "C_gd=5*10**-15; # (F)\n",

      "C_db=5*10**-15;  # (F)\n",

      "uC_n=387*10**-6; # uC_n=u_nC_ox (A/V**2)\n",

      "uC_p=86*10**-6; # uC_p=u_pC_ox (A/V**2)\n",

      "V_an=5; # V_an=V'_An (V/um) (V)\n",

      "V_ap=6; # V_ap=V'_Ap (V/um) (V)\n",

      "I=0.2*10**-3; # (A)\n",

      "R_SS=25000; # (ohm)\n",

      "C_SS=0.2*10**-12; # (F)\n",

      "C_S=25*10**-15; # (F)\n",

      "K_n=uC_n*W/L;\n",

      "I_D=100*10**-6; # bias current (A)\n",

      "V_OV=math.sqrt(2*I_D/K_n);\n",

      "g_m=I/V_OV;\n",

      "g_m1=g_m;\n",

      "g_m2=g_m;\n",

      "r_o1=V_an*0.36/(0.1*10**-3);\n",

      "r_o2=r_o1;\n",

      "K_p=uC_p*W/L;\n",

      "V_OV34=math.sqrt(2*I_D/K_p); # V_OV3,4\n",

      "g_m3=2*0.1*10**-3/V_OV34;\n",

      "g_m4=g_m3;\n",

      "r_o3=V_ap*0.36/(0.1*10**-3);\n",

      "r_o4=r_o3;\n",

      "A_d=g_m*(r_o2*r_o4)/(r_o2+r_o4);\n",

      "print round(A_d,1),\"A_d (V/V)\"\n",

      "A_cm=-1/(2*g_m3*R_SS);\n",

      "print round(A_cm,3),\"A_cm (V/V)\"\n",

      "CMRR=20*log10(-A_d/A_cm); # negative sign to make A_cm positive\n",

      "print round(CMRR,1),\"CMRR in dB\"\n",

      "C_gd1=5*10**-15; # (F)\n",

      "C_db1=5*10**-15; # (F)\n",

      "C_db3=5*10**-15; # (F)\n",

      "C_gs3=20*10**-15; # (F)\n",

      "C_gs4=20*10**-15; # (F)\n",

      "C_m=C_gd1+C_db1+C_db3+C_gs3+C_gs4;\n",

      "C_gd2=5*10**-15; # (F)\n",

      "C_db2=5*10**-15; # (F)\n",

      "C_gd4=5*10**-15; # (F)\n",

      "C_db4=5*10**-15; # (F)\n",

      "C_x=25*10**-15; # (F)\n",

      "C_L=C_gd2+C_db2+C_gd4+C_db4+C_x;\n",

      "print \"poles and zeroes of A_d\"\n",

      "R_o=r_o2*r_o4/(r_o2+r_o4)\n",

      "f_p1=1/(2*math.pi*C_L*R_o);\n",

      "print int(f_p1/1e6),\"f_p1 (MHz)\"\n",

      "f_p2=g_m3/(2*math.pi*C_m);\n",

      "print round(f_p2/1e9,2),\"f_p2 (GHz)\"\n",

      "f_Z=2*f_p2;\n",

      "print round(f_Z/1e9,1),\"f_Z (GHz)\"\n",

      "print \"Dominant pole of CMRR is at location of commom-mode gain zero\"\n",

      "f_Z=1/(2*math.pi*C_SS*R_SS);\n",

      "print round(f_Z/1e6,1),\"f_Z (MHz)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "12.2 A_d (V/V)\n",

        "-0.034 A_cm (V/V)\n",

        "51.1 CMRR in dB\n",

        "poles and zeroes of A_d\n",

        "360 f_p1 (MHz)\n",

        "1.7 f_p2 (GHz)\n",

        "3.4 f_Z (GHz)\n",

        "Dominant pole of CMRR is at location of commom-mode gain zero\n",

        "31.8 f_Z (MHz)\n"

       ]

      }

     ],

     "prompt_number": 28

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex7.3:pg-751"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 7.3 : To determine all parameters for different transistor\n",

      "I_REF=90*10.0**-6; # (A)\n",

      "V_tn=0.7; # (V)\n",

      "V_tp=0.8; # Magnitude is cconsidered\n",

      "uC_n=160.0*10**-6; # uC_n=u_n*C_ox\n",

      "uC_p=40*10.0**-6; # uC_p=u_p*C_ox\n",

      "V_A=10.0; # (V)\n",

      "V_DD=2.5; # (V)\n",

      "V_SS=2.5; # (V)\n",

      "L=0.8*10**-6; # (m)\n",

      "r_o2=222.0; # (ohm)\n",

      "r_o4=222.0; # (ohm)\n",

      "g_m1=0.3; # (mho)\n",

      "A_1=-g_m1*r_o2*r_o4/(r_o2+r_o4);\n",

      "print round(A_1,2),\"=A_1 (V/V)\"\n",

      "r_o6=111.0; # (ohm)\n",

      "r_o7=111.0; # (ohm)\n",

      "g_m6=0.6; # (mho)\n",

      "A_2=-g_m6*r_o6*r_o7/(r_o6+r_o7);\n",

      "print round(A_2,2),\"=A_2 (V/V)\"\n",

      "print \"For Q_1\"\n",

      "W=20*10.0**-6; # (m)\n",

      "I_D=I_REF/2.0; # (A)\n",

      "print round(I_D/(10.0**-6),2),\"=I_D (microA)\"\n",

      "K_p=uC_p*W/L;\n",

      "V_OV=math.sqrt(2*I_D/K_p);\n",

      "print round(V_OV,2),\"=V_OV (V)\"\n",

      "V_GS=V_tp+V_OV;\n",

      "print round(V_GS,2),\"=V_GS (V)\"\n",

      "g_m=2*I_D/V_OV;\n",

      "print round(g_m/(10.0**-3),2),\"=g_m (mA/V)\"\n",

      "r_o=V_A/I_D;\n",

      "print int(r_o/1e3),\"=r_o (kohm)\"\n",

      "print \"For Q_2\"\n",

      "W=20*10.0**-6; # (m)\n",

      "I_D=I_REF/2; # (A)\n",

      "print round(I_D/(10.0**-6),2),\"=I_D (microA)\"\n",

      "K_p=uC_p*W/L;\n",

      "V_OV=math.sqrt(2*I_D/K_p);\n",

      "print round(V_OV,2),\"=V_OV (V)\"\n",

      "V_GS=V_tp+V_OV;\n",

      "print round(V_GS,2),\"=V_GS (V)\"\n",

      "g_m=2*I_D/V_OV;\n",

      "print round(g_m/(10.0**-3),2),\"=g_m (mA/V)\"\n",

      "r_o=V_A/I_D;\n",

      "print round(r_o/1e3),\"=r_o (kohm)\"\n",

      "print \"For Q_3\"\n",

      "W=5*10**-6; # (m)\n",

      "I_D=I_REF/2; # (A)\n",

      "print round(I_D/(10.0**-6),2),\"=I_D (microA)\"\n",

      "K_n=uC_n*W/L;\n",

      "V_OV=math.sqrt(2*I_D/K_n);\n",

      "print round(V_OV,2),\"=V_OV (V)\"\n",

      "V_GS=V_tn+V_OV;\n",

      "print round(V_GS,2),\"=V_GS (V)\"\n",

      "g_m=2*I_D/V_OV;\n",

      "print round(g_m/(10.0**-3),2),\"=g_m (mA/V)\"\n",

      "r_o=V_A/I_D;\n",

      "print round(r_o/1e3),\"=r_o (kohm)\"\n",

      "print \"For Q_4\"\n",

      "W=5*10**-6; # (m)\n",

      "I_D=I_REF/2; # (A)\n",

      "print round(I_D/(10.0**-6),2),\"=I_D (microA)\"\n",

      "K_n=uC_n*W/L;\n",

      "V_OV=math.sqrt(2*I_D/K_n);\n",

      "print round(V_OV,2),\"=V_OV (V)\"\n",

      "V_GS=V_tn+V_OV;\n",

      "print round(V_GS,2),\"=V_GS (V)\"\n",

      "g_m=2*I_D/V_OV;\n",

      "print round(g_m/(10.0**-3),2),\"=g_m (mA/V)\"\n",

      "r_o=V_A/I_D;\n",

      "print round(r_o/1e3),\"=r_o (kohm)\"\n",

      "print \"For Q_5\"\n",

      "W=40*10.0**-6; # (m)\n",

      "I_D=I_REF; # (A)\n",

      "print round(I_D/(10.0**-6),2),\"=I_D (microA)\"\n",

      "K_p=uC_p*W/L;\n",

      "V_OV=math.sqrt(2*I_D/K_p);\n",

      "print round(V_OV,2),\"=V_OV (V)\"\n",

      "V_GS=V_tp+V_OV;\n",

      "print round(V_GS,2),\"=V_GS (V)\"\n",

      "g_m=2*I_D/V_OV;\n",

      "print round(g_m/(10.0**-3),2),\"=g_m (mA/V)\"\n",

      "r_o=V_A/I_D;\n",

      "print round(r_o/1e3),\"=r_o (kohm)\"\n",

      "print \"For Q_6\"\n",

      "W=10*10**-6; # (m)\n",

      "I_D=I_REF; #A\n",

      "print round(I_D/(10.0**-6),2),\"=I_D (microA)\"\n",

      "K_n=uC_n*W/L;\n",

      "V_OV=math.sqrt(2*I_D/K_n);\n",

      "print round(V_OV,2),\"=V_OV (V)\"\n",

      "V_GS=V_tn+V_OV;\n",

      "print round(V_GS,2),\"=V_GS (V)\"\n",

      "g_m=2*I_D/V_OV;\n",

      "print round(g_m/(10.0**-3),2),\"=g_m (mA/V)\"\n",

      "r_o=V_A/I_D;\n",

      "print round(r_o/1e3),\"=r_o (kohm)\"\n",

      "print \"For Q_7\"\n",

      "W=40*10**-6; # (m)\n",

      "I_D=I_REF;#A\n",

      "print round(I_D/(10.0**-6),2),\"=I_D (microA)\"\n",

      "K_p=uC_p*W/L;\n",

      "V_OV=math.sqrt(2*I_D/K_p);\n",

      "print round(V_OV,2),\"=V_OV (V)\"\n",

      "V_GS=V_tp+V_OV;\n",

      "print round(V_GS,2),\"=V_GS (V)\"\n",

      "g_m=2*I_D/V_OV;\n",

      "print round(g_m/(10.0**-3),2),\"=g_m (mA/V)\"\n",

      "r_o=V_A/I_D;\n",

      "print round(r_o/1e3),\"=r_o (kohm)\"\n",

      "print \"For Q_8\"\n",

      "W=40*10**-6; # (m)\n",

      "I_D=I_REF; # A\n",

      "print round(I_D/(10.0**-6),2),\"=I_D (microA)\"\n",

      "K_p=uC_p*W/L;\n",

      "V_OV=math.sqrt(2*I_D/K_p);\n",

      "print round(V_OV,2),\"=V_OV (V)\"\n",

      "V_GS=V_tp+V_OV;\n",

      "print round(V_GS,2),\"=V_GS (V)\"\n",

      "g_m=2*I_D/V_OV;\n",

      "print round(g_m/(10.0**-3),2),\"=g_m (mA/V)\"\n",

      "r_o=V_A/I_D;\n",

      "print int(r_o/1e3),\"=r_o (kohm)\"\n",

      "A_O=A_1*A_2;\n",

      "print round(20*log10(A_O)),\"=The dc open loop gain in dB\"\n",

      "v_ICMmin=-2.5+1;\n",

      "print round(v_ICMmin,2),\"=Lower limit of input common-mode (V)\"\n",

      "v_ICMmax=2.2-1.1;\n",

      "print round(v_ICMmax,2),\"=Upper limit of input common-mode (V)\"\n",

      "v_Omax=V_DD-V_OV;\n",

      "print round(v_Omax,2),\"=Highest allowable output voltage (V)\"\n",

      "v_Omin=-V_SS+V_OV;\n",

      "print round(v_Omin,2),\"=Lowest allowable output voltage (V)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "-33.3 =A_1 (V/V)\n",

        "-33.3 =A_2 (V/V)\n",

        "For Q_1\n",

        "45.0 =I_D (microA)\n",

        "0.3 =V_OV (V)\n",

        "1.1 =V_GS (V)\n",

        "0.3 =g_m (mA/V)\n",

        "222 =r_o (kohm)\n",

        "For Q_2\n",

        "45.0 =I_D (microA)\n",

        "0.3 =V_OV (V)\n",

        "1.1 =V_GS (V)\n",

        "0.3 =g_m (mA/V)\n",

        "222.0 =r_o (kohm)\n",

        "For Q_3\n",

        "45.0 =I_D (microA)\n",

        "0.3 =V_OV (V)\n",

        "1.0 =V_GS (V)\n",

        "0.3 =g_m (mA/V)\n",

        "222.0 =r_o (kohm)\n",

        "For Q_4\n",

        "45.0 =I_D (microA)\n",

        "0.3 =V_OV (V)\n",

        "1.0 =V_GS (V)\n",

        "0.3 =g_m (mA/V)\n",

        "222.0 =r_o (kohm)\n",

        "For Q_5\n",

        "90.0 =I_D (microA)\n",

        "0.3 =V_OV (V)\n",

        "1.1 =V_GS (V)\n",

        "0.6 =g_m (mA/V)\n",

        "111.0 =r_o (kohm)\n",

        "For Q_6\n",

        "90.0 =I_D (microA)\n",

        "0.3 =V_OV (V)\n",

        "1.0 =V_GS (V)\n",

        "0.6 =g_m (mA/V)\n",

        "111.0 =r_o (kohm)\n",

        "For Q_7\n",

        "90.0 =I_D (microA)\n",

        "0.3 =V_OV (V)\n",

        "1.1 =V_GS (V)\n",

        "0.6 =g_m (mA/V)\n",

        "111.0 =r_o (kohm)\n",

        "For Q_8\n",

        "90.0 =I_D (microA)\n",

        "0.3 =V_OV (V)\n",

        "1.1 =V_GS (V)\n",

        "0.6 =g_m (mA/V)\n",

        "111 =r_o (kohm)\n",

        "61.0 =The dc open loop gain in dB\n",

        "-1.5 =Lower limit of input common-mode (V)\n",

        "1.1 =Upper limit of input common-mode (V)\n",

        "2.2 =Highest allowable output voltage (V)\n",

        "-2.2 =Lowest allowable output voltage (V)\n"

       ]

      }

     ],

     "prompt_number": 49

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex7.5:pg-760"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 7.5 : Analysis of given circuit\n",

      "B=100.0; # beta value\n",

      "I_E=0.2510**-3; # (A)\n",

      "R_1=20000.0; # (ohm)\n",

      "R_2=20000; # (ohm)\n",

      "R_3=3000; # (ohm)\n",

      "R_4=2300; # (ohm)\n",

      "R_5=15700; # (ohm)\n",

      "R_6=3000; # (ohm)\n",

      "r_e1=25/0.25; # (ohm)\n",

      "r_e2=r_e1; # (ohm)\n",

      "r_pi1=(B+1)*r_e1;\n",

      "r_pi2=(B+1)*r_e2;\n",

      "R_id=r_pi1+r_pi2;\n",

      "print round(R_id/1e3,2),\"Input differential resistance (kohm)\"\n",

      "I_E=1*10.0**-3;\n",

      "r_e4=25/1.0;\n",

      "r_e5=r_e4;\n",

      "r_pi4=(B+1)*r_e4;\n",

      "r_pi5=(B+1)*r_e5;\n",

      "R_i2=r_pi4+r_pi5;\n",

      "print round(R_i2/1e3,2),\"Input resistance of the second stage R_i2 (kohm)\"\n",

      "A_1=(R_i2*(R_1+R_2)/((R_i2+R_1+R_2)*(r_e1+r_e2)))\n",

      "print round(A_1,1),\"Voltage gain of the first stage (V/V)\"\n",

      "r_e7=25/1.0;\n",

      "R_i3=(B+1)*(R_4+r_e7);\n",

      "print round(R_i3/1e3,1),\"Input resistance of the third stage R_i3 (kohm)\"\n",

      "A_2=(-R_3*R_i3)/((R_3+R_i3)*(r_e4+r_e5));\n",

      "print round(A_2,1),\"Voltage gain of the second stage (V/V)\"\n",

      "r_e8=25/5.0;\n",

      "R_i4=(B+1)*(r_e8+R_6);\n",

      "print round(R_i4/1e3,2),\"Input resistance of the third stage R_i2 (kohm)\"\n",

      "A_3=(-R_5*R_i4)/((R_5+R_i4)*(r_e7+R_4));\n",

      "print round(A_3,2),\"Voltage gain of the third stage (V/V)\"\n",

      "A_4=R_6/(R_6+r_e8);\n",

      "print round(A_4,2),\"Voltage gain of the fourth stage (V/V)\"\n",

      "A=A_1*A_2*A_3*A_4 ; # A=v_o/v_id (V/V)\n",

      "print round(A),\"Overall output gain (V/V)\"\n",

      "print round(20*log10(A),1),\"Overall output gain in dB\"\n",

      "R_o=R_6*(r_e8+R_5/(B+1))/(R_6+r_e8+R_5/(B+1))\n",

      "print round(R_o),\"Output resistance (ohm)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "20.2 Input differential resistance (kohm)\n",

        "5.05 Input resistance of the second stage R_i2 (kohm)\n",

        "22.4 Voltage gain of the first stage (V/V)\n",

        "234.8 Input resistance of the third stage R_i3 (kohm)\n",

        "-59.2 Voltage gain of the second stage (V/V)\n",

        "303.5 Input resistance of the third stage R_i2 (kohm)\n",

        "-6.42 Voltage gain of the third stage (V/V)\n",

        "1.0 Voltage gain of the fourth stage (V/V)\n",

        "8514.0 Overall output gain (V/V)\n",

        "78.6 Overall output gain in dB\n",

        "152.0 Output resistance (ohm)\n"

       ]

      }

     ],

     "prompt_number": 56

    }

   ],

   "metadata": {}

  }

 ]

}