{

 "metadata": {

  "name": "",

  "signature": "sha256:21296c3701295d5c104cbfb8dc3256ad4c96ab638c655298f128fa59daa0a30d"

 },

 "nbformat": 3,

 "nbformat_minor": 0,

 "worksheets": [

  {

   "cells": [

    {

     "cell_type": "heading",

     "level": 1,

     "metadata": {},

     "source": [

      "Chapter10: Digital CMOS Logic Circuits"

     ]

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex10.1:pg-962"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 10.1 : To determine t_PHL, t_PLH and t_P\n",

      "# Consider CMOS inverter\n",

      "import math\n",

      "C_ox=6*10.0**-15; # (F/um**2)\n",

      "uC_n=115.0*10**-6; #uC_n=u_n*C_ox (A/V**2)\n",

      "uC_p=30.0*10**-6; #uC_p=u_p*C_ox (A/V**2)\n",

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

      "V_tp=-0.4; # (V)\n",

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

      "W_n=0.375*10**-6; # W for Q_N\n",

      "L_n=0.25*10**-6; # L for Q_N\n",

      "W_p=1.125*10**-6; # W for Q_P\n",

      "L_p=0.25*10**-6; # L for Q_P\n",

      "C_gd1=0.3*W_n*10**-9; # (F)\n",

      "C_gd2=0.3*W_p*10**-9; # (F)\n",

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

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

      "C_g3= 0.375*0.25*6*10**-15+2*0.3*0.375*10**-15; # (F)\n",

      "C_g4=1.125*0.25*6*10**-15+2*0.3*1.125*10**-15; # (F)\n",

      "C_w=0.2*10**-15; # (F)\n",

      "C=2*C_gd1+2.0*C_gd2+C_db1+C_db2+C_g3+C_g4+C_w; # (F)\n",

      "i_DN0=uC_n*W_n*(V_DD-V_tn)**2/(2*L_n); # i_DN0 = i_DN(0) (A)\n",

      "i_DNtPHL=uC_n*W_n*((V_DD-V_tn)*V_DD/2-((V_DD/2.0)**2)/2.0)/L_n; # i_DNtPHL = i_DN(t_PHL) (A)\n",

      "i_DNav=(i_DN0+i_DNtPHL)/2; # i_DN|av (A)\n",

      "t_PHL=C*(V_DD/2)*1e12/i_DNav;\n",

      "print math.ceil(t_PHL),\"= t_PHL (picoseconds)\"\n",

      "t_PLH=1.3*t_PHL; # Since W_p/W_n=3 and u_n/u_p=3.83 thus t_PLH is greater than t_PHL by 3.83/3\n",

      "print round(t_PLH,-1),\"= t_PLH (picoseconds)\"\n",

      "t_P=(t_PHL+t_PLH)/2; \n",

      "print round(t_P),\"= t_P (picoseconds)\"\n",

      "\n",

      " # the answer in the textbook is slightly dirfferent due to approximation"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "23.0 = t_PHL (picoseconds)\n",

        "30.0 = t_PLH (picoseconds)\n",

        "26.0 = t_P (picoseconds)\n"

       ]

      }

     ],

     "prompt_number": 17

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex10.2:pg-972"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 10.2 : W/L ratios for the logic circuit\n",

      "#For basic inverter\n",

      "n=1.5;\n",

      "p=5;\n",

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

      "WbyL=2*n; # W/L for Q_NB , Q_NC , Q_ND\n",

      "print WbyL,\"= W/L ratio for Q_NB\"\n",

      "print WbyL,\"= W/L ratio for Q_NC\"\n",

      "print WbyL,\"= W/L ratio for Q_ND\"\n",

      "WbyL=n; # W/L ratio for Q_NA\n",

      "print WbyL,\"= W/L ratio for Q_NA\"\n",

      "WbyL=3*p; # W/L for Q_PA, Q_PC , Q_PD\n",

      "print WbyL,\"= W/L ratio for Q_PA\" \n",

      "print WbyL,\"= W/L ratio for Q_PC\"\n",

      "print WbyL,\"= W/L ratio for Q_PD\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "3.0 = W/L ratio for Q_NB\n",

        "3.0 = W/L ratio for Q_NC\n",

        "3.0 = W/L ratio for Q_ND\n",

        "1.5 = W/L ratio for Q_NA\n",

        "15 = W/L ratio for Q_PA\n",

        "15 = W/L ratio for Q_PC\n",

        "15 = W/L ratio for Q_PD\n"

       ]

      }

     ],

     "prompt_number": 18

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex10.3:pg-981"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 10.3 : To determine the parameters of pseudo NMOS inverter\n",

      "# Consider a pseudo NMOS inverter\n",

      "uC_n=115.0*10**-6; #uC_n=u_n*C_ox (A/V**2)\n",

      "uC_p=30*10.0**-6; #uC_p=u_p*C_ox (A/V**2)\n",

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

      "V_tp=-0.4; # (V)\n",

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

      "W_n=0.375*10**-6; # W for Q_N (m)\n",

      "L_n=0.25*10**-6; # L for Q_N (m)\n",

      "r=9.0;\n",

      "\n",

      "# 10.3a\n",

      "V_OH=V_DD;\n",

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

      "V_OL=(V_DD-V_tn)*(1-math.sqrt(1.0-1/r));\n",

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

      "V_IL=V_tn+(V_DD-V_tn)/math.sqrt(r*(r+1.0));\n",

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

      "V_IH=V_tn+2*(V_DD-V_tn)/(math.sqrt(3.0*r));\n",

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

      "V_M=V_tn+(V_DD-V_tn)/math.sqrt(r+1.0);\n",

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

      "NM_H=V_OH-V_IH;\n",

      "NM_L=V_IL-V_OL;\n",

      "print round(NM_H,2),\"=The highest and the lowest values of allowable noise margin (V)=\",round(NM_L,2)\n",

      "\n",

      "# 10.3b\n",

      "WbyL_p=uC_n*(W_n/L_n)/(uC_p*r); # WbyL_p=(W/L)_p\n",

      "print round(WbyL_p,2),\"=(W/L)_p\"\n",

      "\n",

      "#10.3c\n",

      "I_stat=(uC_p*WbyL_p*(V_DD-V_tn)**2)/2;\n",

      "print round(I_stat*1e6,1),\"=I_stat (microA)\"\n",

      "P_D=I_stat*V_DD;\n",

      "print round(P_D*1e6),\"=Static power dissipation P_D (microW)\"\n",

      "\n",

      "#10.3d\n",

      "C=7*10**-15;\n",

      "t_PLH=1.7*C/(uC_p*WbyL_p*V_DD);\n",

      "print round(t_PLH*1e9,2),\"=t_PLH (ns)\"\n",

      "t_PHL=1.7*C/(uC_n*(W_n/L_n)*math.sqrt(1-0.46/r)*V_DD);\n",

      "print round(t_PHL*1e9,2),\"= t_PHL (ns)\"\n",

      "t_p=(t_PHL+t_PLH)/2.0;\n",

      "print round(t_p*1e9,2),\"= t_p (ns)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "2.5 = V_OH (V)\n",

        "0.12 = V_OL (V)\n",

        "0.62 =V_IL (V)\n",

        "1.21 = V_IH (V)\n",

        "1.06 = V_M (V)\n",

        "1.29 =The highest and the lowest values of allowable noise margin (V)= 0.5\n",

        "0.64 =(W/L)_p\n",

        "42.3 =I_stat (microA)\n",

        "106.0 =Static power dissipation P_D (microW)\n",

        "0.25 =t_PLH (ns)\n",

        "0.03 = t_PHL (ns)\n",

        "0.14 = t_p (ns)\n"

       ]

      }

     ],

     "prompt_number": 24

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex10.4:pg-985"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 10.4 : To determine parameters for NMOS transistor\n",

      "# Consider NMOS transistor switch\n",

      "uC_n=50.0*10**-6; #uC_n=u_n*C_ox (A/V**2)\n",

      "uC_p=20.0*10.0**-6; #uC_px    `=u_p*C_ox (A/V**2)\n",

      "V_tO=1.0; # (V)\n",

      "y=0.5; # (V**1/2)\n",

      "fie_f=0.6/2; # (V)\n",

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

      "W_n=4*10.0**-6; # (m)\n",

      "L_n=2*10.0**-6; # (m)\n",

      "C=50*10.0**-15; # (F)\n",

      "\n",

      "# 10.4a\n",

      "V_t=1.6; # (V)\n",

      "V_OH=V_DD-V_t; # V_OH is the value of v_O at which Q stops conducting (V)\n",

      "print V_OH,\"= V_OH (V)\"\n",

      " \n",

      "# 10.4b\n",

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

      "L_p=2*10.0**-6; # (m)\n",

      "i_DP=uC_p*W_p*((V_DD-V_OH-V_tO)**2)/(2*L_p);\n",

      "print round(i_DP*1e6),\"= Static current of the inverter (microA)\"\n",

      "P_D=V_DD*i_DP;\n",

      "print round(P_D*1e6),\"= Power dissipated (microW)\"\n",

      "V_O=0.08; # Output voltage (V) found by equating the current of Q_N=18uA\n",

      "print round(V_O,2),\"= The output voltage of the inverter (V) \"\n",

      "\n",

      "# 10.4c\n",

      "i_D0=uC_n*W_n*((V_DD-V_tO)**2)/(2*2*10**-6); # i_D0=i_D(0) (A) current i_D at t=0\n",

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

      "V_t=V_tO+0.5*(math.sqrt(v_O+2*fie_f)-math.sqrt(2*fie_f)); # at v_O=2.5V\n",

      "i_DtPLH=(uC_n*W_n*(V_DD-v_O-V_t)**2)/(2*L_n); # i_DtPLH=i_D(t_PLH) (A) current i_D at t=t_PLH\n",

      "i_Dav=(i_D0+i_DtPLH)/2; # i_Dav=i_D|av (A) average discharge current\n",

      "t_PLH=C*(V_DD/2)/i_Dav;\n",

      "print round(t_PLH*1e9,2),\"t_PHL (ns)\"\n",

      "\n",

      "# 10.4d\n",

      "# Case with v_t going low\n",

      "i_D0=uC_n*W_n*((V_DD-V_tO)**2)/(2*2*10**-6); # i_D0=i_D(0) (A) current i_D at t=0\n",

      "i_DtPHL=uC_n*W_n*((V_DD-V_tO)*v_O-(v_O**2)/2.0)/(L_n); # i_DtPHL=i_D(t_PHL) (A) current i_D at t=T_PHL\n",

      "i_Dav=(i_D0+i_DtPHL)/2; # i_Dav=i_D|av (A) average discarge current\n",

      "t_PHL=C*(V_DD/2)/i_Dav;\n",

      "print round(t_PHL*1e9,2),\"= t_PHL (ns)\"\n",

      "\n",

      "# 10.4e\n",

      "t_P=(t_PHL+t_PLH)/2;\n",

      "print round(t_P*1e9,2),\"= t_P (ns)\"\n",

      " # the answer in the textbook is slightly dirfferent due to approximation"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "3.4 = V_OH (V)\n",

        "18.0 = Static current of the inverter (microA)\n",

        "90.0 = Power dissipated (microW)\n",

        "0.08 = The output voltage of the inverter (V) \n",

        "0.24 t_PHL (ns)\n",

        "0.13 = t_PHL (ns)\n",

        "0.18 = t_P (ns)\n"

       ]

      }

     ],

     "prompt_number": 34

    }

   ],

   "metadata": {}

  }

 ]

}