Usage of IC 74153

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

ic = IC_74153()

print(ic.__doc__)
This is 16-pin dual 4:1 multiplexer with output same as the input.

    Pin Number  Description
    1   Strobe1
    2   Select line B
    3   1C3
    4   1C2
    5   1C1
    6   1C0
    7   1Y - OUTPUT1
    8   Ground
    9   2Y - OUTPUT2
    10  2C0
    11  2C1
    12  2C2
    13  2C3
    14     Select line A
    15     Strobe2
    16  Positive Supply

    Selectlines = BA ; Inputlines1 = 1C0 1C1 1C2 1C3 ; Inputlines2 = 2C0 2C1 2C2 2C3
# The Pin configuration is:

inp = {
    1: 1,
    2: 1,
    3: 1,
    4: 0,
    5: 0,
    6: 0,
    10: 0,
    11: 1,
    12: 0,
    13: 0,
    14: 0,
    15: 0}

# Pin initinalization

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

ic.setIC({16: 1, 8: 0})

# Setting the inputs of the ic

ic.setIC(inp)

# Draw the IC with the current configuration\n

ic.drawIC()
         ┌─────────◡─────────┐
         │                   │
[1]    ──┤  1            16  ├──    [1]
         │                   │
         │                   │
[1]    ──┤  2      7     15  ├──    [0]
         │                   │
         │                   │
[1]    ──┤  3      4     14  ├──    [0]
         │                   │
         │                   │
[0]    ──┤  4      1     13  ├──    [0]
         │                   │
         │                   │
[0]    ──┤  5      5     12  ├──    [0]
         │                   │
         │                   │
[0]    ──┤  6      3     11  ├──    [1]
         │                   │
         │                   │
[Z]    ──┤  7            10  ├──    [0]
         │                   │
         │                   │
[0]    ──┤  8             9  ├──    [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())
{9: 0, 7: 0}
# 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            16  ├──    [1]
         │                   │
         │                   │
[1]    ──┤  2      7     15  ├──    [0]
         │                   │
         │                   │
[1]    ──┤  3      4     14  ├──    [0]
         │                   │
         │                   │
[0]    ──┤  4      1     13  ├──    [0]
         │                   │
         │                   │
[0]    ──┤  5      5     12  ├──    [0]
         │                   │
         │                   │
[0]    ──┤  6      3     11  ├──    [1]
         │                   │
         │                   │
[0]    ──┤  7            10  ├──    [0]
         │                   │
         │                   │
[0]    ──┤  8             9  ├──    [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            16  ├──    [1]
              │                   │
              │                   │
     [1]    ──┤  2      7     15  ├──    [0]
              │                   │
              │                   │
     [1]    ──┤  3      4     14  ├──    [0]
              │                   │
              │                   │
     [0]    ──┤  4      1     13  ├──    [0]
              │                   │
              │                   │
     [0]    ──┤  5      5     12  ├──    [0]
              │                   │
              │                   │
     [0]    ──┤  6      3     11  ├──    [1]
              │                   │
              │                   │
     [0]    ──┤  7            10  ├──    [0]
              │                   │
              │                   │
     [0]    ──┤  8             9  ├──    [0]
              │                   │
              └───────────────────┘
{9: 0, 7: 0}
# Connector Outputs
c = Connector()

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

print(c)
Connector; State: 0