{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter : 8 - CMOS Realization Of Inverters"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.2 : Page No - 333\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import symbols, solve, N\n",
      "x= symbols('x')\n",
      "#Given data\n",
      "NMH= 1 # in V\n",
      "VIH= 2 # in V\n",
      "VTon= 0.5 # in V\n",
      "VOL= 0.2 # in V\n",
      "VDD= 3 # in V\n",
      "KP= 30*10**-6 # in A/V**2\n",
      "PD= 100*10**-6 # power dissipation in W\n",
      "# Formula VIH= VTon +2*sqrt(2*VDD/(3*kn*RL))-1/(kn*RL) (i)\n",
      "# Let x= 1/(kn*RL), putting the values in (i), we get\n",
      "# x**2-5*x+2.25=0\n",
      "expr = x**2-5*x+2.25\n",
      "x , x1= solve(expr, x)\n",
      "# Formula PD= VDD*(VDD-VOL)/(2*RL)\n",
      "RL= VDD*(VDD-VOL)/(2*PD) # in \u03a9\n",
      "print \"The value of RL = %0.1e \u03a9\" %RL\n",
      "kn= 1/(x*RL) # in A/V**2\n",
      "# Formula kn= KP*(W/L)\n",
      "WbyL= kn/KP \n",
      "print \"The value of (W/L)n = %0.2f\" %WbyL"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of RL = 4.2e+04 \u03a9\n",
        "The value of (W/L)n = 1.59\n"
       ]
      }
     ],
     "prompt_number": 83
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.4 : Page No - 335\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "unCox= 40 # in \u00b5A/V**2\n",
      "upCox= 20 # in \u00b5A/V**2\n",
      "Ln= 0.5 # in \u00b5m\n",
      "Lp= 0.5 # in \u00b5m\n",
      "Wn= 2.0 # in \u00b5m\n",
      "Wp= unCox*Wn/upCox # in \u00b5m\n",
      "print \"The value of Wp = %0.f \u00b5m\" %Wp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Wp = 4 \u00b5m\n"
       ]
      }
     ],
     "prompt_number": 84
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.5 : Page No - 337\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from sympy import symbols, solve, N\n",
      "VOUT= symbols('VOUT')\n",
      "# Given data\n",
      "VTO= 0.43 # in V\n",
      "VDD= 2.5 # in V\n",
      "g=0.4  # value of gamma\n",
      "W1= 0.375 \n",
      "L1=0.25 \n",
      "W2= 0.75 \n",
      "L2=0.25 \n",
      "#VDD-VOUT-VT= VDD-VOUT-(VTO+g*(sqrt(0.6+VOUT)-sqrt(0.6)))=0\n",
      "#VOUT**2+VOUT*(2*A-g**2)+(A-0.6*g**2)=0, where\n",
      "A=VTO-VDD-g*sqrt(0.6) # assumed\n",
      "B= (2*A-g**2) # assumed\n",
      "C=(A**2-0.6*g**2) #assumed\n",
      "    #VOUT= [1 B C] \n",
      "    #VOUT= roots(VOUT) # in V\n",
      "    #VOUT= VOUT(2) # in V\n",
      "\n",
      "\n",
      "expr = VOUT**2+VOUT*(2*A-g**2+4.556)+(A-0.6*g**2)\n",
      "VOUT= solve(expr, VOUT)\n",
      "VOH= round(VOUT[1],4) # in V\n",
      "print \"The value of VOH = %0.3f volts\" %VOH\n",
      "Vout=(W1+3*L2)-(VDD-VTO)*(W2*L1/(W1*L2)-1)+ (VDD)/(VDD-VTO)\n",
      "VOL= Vout # in V\n",
      "print \"The value of VOL = %0.3f volts\" %VOL\n",
      "Vth= (VDD+VTO-L1)/(VDD*VTO)*(1-W1*L2/(W2*L1))+(L1*L2/VDD)\n",
      "print \"The value of Vth for circuit A = %0.3f volts\" %Vth\n",
      "W4= 0.365 \n",
      "L4=0.25 \n",
      "W3= 0.75 \n",
      "L3=0.15 \n",
      "Vth=(L3*L4/VDD)+(VDD/(W3*L4*VDD))-(VDD)/(1-W4*L3/(W3*L4))-2*W4\n",
      "print \"The value of Vth for circuit B = %0.3f volts\" %Vth\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of VOH = 1.766 volts\n",
        "The value of VOL = 0.263 volts\n",
        "The value of Vth for circuit A = 1.272 volts\n",
        "The value of Vth for circuit B = 1.087 volts\n"
       ]
      }
     ],
     "prompt_number": 85
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6 : Page No - 338\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from sympy import symbols, solve, N\n",
      "Vx= symbols('Vx')\n",
      "\n",
      "#Given data\n",
      "VTO= 0.43 # in V\n",
      "VDD= 2.5 # in V\n",
      "g=0.5  # value of gamma\n",
      "#VDD-Vx-VT= VDD-Vx-(VTO+g*(sqrt(0.6+Vx)-sqrt(0.6)))=0\n",
      "#Vx**2+Vx*(2*A-g**2)+(A-0.6*g**2)=0, where\n",
      "A=VTO-VDD-g*sqrt(0.6) # assumed\n",
      "B= (2*A-g**2) # assumed\n",
      "C=(A**2-0.6*g**2) #assumed\n",
      "expr = Vx**2+Vx*(2*A-g**2+5)+(A-0.6*g**2)\n",
      "err, Vx= solve(expr , Vx)\n",
      "print \"The value of Vx =\",round(Vx,4),\"volts\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Vx = 1.6991 volts\n"
       ]
      }
     ],
     "prompt_number": 86
    }
   ],
   "metadata": {}
  }
 ]
}