Usage of IC 7403

from __future__ import print_function
from BinPy import *
# Usage of IC 7403:

ic = IC_7403()

print(ic.__doc__)
This is a Quad 2-input open-collector NAND gate IC

Pin Number      Description
    1   A Input Gate 1
    2   B Input Gate 1
    3   Y Output Gate 1
    4   A Input Gate 2
    5   B Input Gate 2
    6   Y Output Gate 2
    7   Ground
    8   Y Output Gate 3
    9   B Input Gate 3
    10  A Input Gate 3
    11  Y Output Gate 4
    12  B Input Gate 4
    13  A Input Gate 4
    14  Positive Supply


This class needs 14 parameters. Each parameter being the pin value. The input has to be defined as a dictionary
with pin number as the key and its value being either 1 or 0

To initialise the ic 7403:
    1. set pin 7:0
    2. set pin 14:1

How to use:

    >>> ic = IC_7403()
    >>> pin_config = {1: 1, 2: 0, 4: 0, 5: 0, 7: 0, 9: 1, 10: 1, 12: 0, 13: 0, 14: 1}
    >>> ic.setIC(pin_cofig)
    >>> ic.drawIC()
    >>> ic.run()
    >>> ic.setIC(ic.run())
    >>> ic.drawIC()

Default pins:
    pins = [None,0,0,None,0,0,None,0,None,0,0,None,0,0,0]
# The Pin configuration is:

inp = {1: 1, 2: 0, 4: 0, 5: 0, 7: 0, 9: 1, 10: 1, 12: 0, 13: 0, 14: 1}

# Pin initinalization

# Powering up the IC - using -- ic.setIC({14: 1, 7: 0})

ic.setIC({14: 1, 7: 0})

# Setting the inputs of the ic

ic.setIC(inp)

# Draw the IC with the current configuration\n

ic.drawIC()
         ┌─────────◡─────────┐
         │                   │
[1]    ──┤  1            14  ├──    [1]
         │                   │
         │                   │
[0]    ──┤  2      7     13  ├──    [0]
         │                   │
         │                   │
[Z]    ──┤  3      4     12  ├──    [0]
         │                   │
         │                   │
[0]    ──┤  4      0     11  ├──    [Z]
         │                   │
         │                   │
[0]    ──┤  5      3     10  ├──    [1]
         │                   │
         │                   │
[Z]    ──┤  6             9  ├──    [1]
         │                   │
         │                   │
[0]    ──┤  7             8  ├──    [Z]
         │                   │
         └───────────────────┘
# Run the IC with the current configuration using -- print ic.run() --

# Note that the ic.run() returns a dict of pin configuration similar to

print (ic.run())
{8: 0, 11: 1, 3: 1, 6: 1}
# Seting the outputs to the current IC configuration using -- ic.setIC(ic.run()) --\n

ic.setIC(ic.run())

# Draw the final configuration

ic.drawIC()
         ┌─────────◡─────────┐
         │                   │
[1]    ──┤  1            14  ├──    [1]
         │                   │
         │                   │
[0]    ──┤  2      7     13  ├──    [0]
         │                   │
         │                   │
[1]    ──┤  3      4     12  ├──    [0]
         │                   │
         │                   │
[0]    ──┤  4      0     11  ├──    [1]
         │                   │
         │                   │
[0]    ──┤  5      3     10  ├──    [1]
         │                   │
         │                   │
[1]    ──┤  6             9  ├──    [1]
         │                   │
         │                   │
[0]    ──┤  7             8  ├──    [0]
         │                   │
         └───────────────────┘
# Seting the outputs to the current IC configuration using -- ic.setIC(ic.run()) --

ic.setIC(ic.run())

# Draw the final configuration

ic.drawIC()

# Run the IC

print (ic.run())
              ┌─────────◡─────────┐
              │                   │
     [1]    ──┤  1            14  ├──    [1]
              │                   │
              │                   │
     [0]    ──┤  2      7     13  ├──    [0]
              │                   │
              │                   │
     [1]    ──┤  3      4     12  ├──    [0]
              │                   │
              │                   │
     [0]    ──┤  4      0     11  ├──    [1]
              │                   │
              │                   │
     [0]    ──┤  5      3     10  ├──    [1]
              │                   │
              │                   │
     [1]    ──┤  6             9  ├──    [1]
              │                   │
              │                   │
     [0]    ──┤  7             8  ├──    [0]
              │                   │
              └───────────────────┘
{8: 0, 11: 1, 3: 1, 6: 1}
# Connector Outputs
c = Connector()

# Set the output connector to a particular pin of the ic
ic.setOutput(8, c)

print(c)
Connector; State: 0