{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3: Digital Elements and Features"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example3_1,pg 487"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# equivalence comparator\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "in1   = 1                 # input-1\n",
      "in2   = not(in1)           # input-2\n",
      "\n",
      "\n",
      "#Calculations\n",
      "out=((not(in1))*( not(in2)))+(in1*in2)\n",
      "\n",
      "#Result\n",
      "print(\"output of comparator:\")\n",
      "print(\"out = %d\"% out)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output of comparator:\n",
        "out = 0\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example3_2,pg 487"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# antivalence comparator\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "in1   = 1                 # input-1\n",
      "in2   = not(in1)          # input-2\n",
      "\n",
      "\n",
      "\n",
      "#Calculations\n",
      "out=((not(in1))+( not(in2)))*(in1+in2)\n",
      "\n",
      "#Result\n",
      "print(\"output of comparator:\")\n",
      "print(\"out = %d\"%out)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output of comparator:\n",
        "out = 1\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example3_3,pg 487"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print(\"Theoretical example\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Theoretical example\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example3_4,pg 487"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print(\"Theoretical example\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Theoretical example\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example3_5,pg 488"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# simplify Boolean function\n",
      "\n",
      "import math\n",
      "#Variable declaration(Inputs)\n",
      "#enter binary values only(1bit)\n",
      "a=input(\"enter value of a\")      #input-1\n",
      "b=input(\"enter value of b\")      #input-2\n",
      "c=input(\"enter value of c\")      #input-3\n",
      "    \n",
      "#Calculations\n",
      "x=not(a and b)\n",
      "y=(x or c)                       #final output\n",
      "\n",
      "#Result\n",
      "print(\"\\noutput:y=%d\\n\"%y)\n",
      "print(\"verify from truth table\\n\")\n",
      "print(\"a  b  c          y\\n\")\n",
      "print(\"0  0  0          1\\n\")\n",
      "print(\"0  0  1          1\\n\")\n",
      "print(\"0  1  0          1\\n\")\n",
      "print(\"0  1  1          1\\n\")\n",
      "print(\"1  0  0          1\\n\")\n",
      "print(\"1  0  1          1\\n\")\n",
      "print(\"1  1  0          0\\n\")\n",
      "print(\"1  1  1          1\\n\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "enter value of a1\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "enter value of b1\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "enter value of c0\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "output:y=0\n",
        "\n",
        "verify from truth table\n",
        "\n",
        "a  b  c          y\n",
        "\n",
        "0  0  0          1\n",
        "\n",
        "0  0  1          1\n",
        "\n",
        "0  1  0          1\n",
        "\n",
        "0  1  1          1\n",
        "\n",
        "1  0  0          1\n",
        "\n",
        "1  0  1          1\n",
        "\n",
        "1  1  0          0\n",
        "\n",
        "1  1  1          1\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example3_6,pg 488"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print(\"Theoretical example\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Theoretical example\n"
       ]
      }
     ],
     "prompt_number": 19
    }
   ],
   "metadata": {}
  }
 ]
}