Example for DEMUX class.ΒΆ
from __future__ import print_function
from BinPy.combinational.combinational import *
# Initializing the DEMUX class
# Must be a single input
demux = DEMUX(1)
# Put select lines
# Select Lines must be power of 2
demux.select_lines(0)
# Output of demux
print (demux.output())
[1, 0]
# Input changes
# Input at index 1 is changed to 0
demux.set_input(0, 0)
# New Output of the demux
print (demux.output())
[0, 0]
# Get Input States
print (demux.get_input_states())
[0]
# Using Connectors as the input lines
# Take a Connector
conn = Connector()
# Set Output of demux to Connector conn
# sets conn as the output at index 0
demux.set_output(0, conn)
# Put this connector as the input to gate1
gate1 = AND(conn, 0)
# Output of the gate1
print (gate1.output())
0
# Changing select lines
#selects input line 2
demux.select_line(0, 1)
# New output of demux
print (demux.output())
[0, 0]
# Information about demux instance can be found by
print (demux)
DEMUX Gate; Output: [0, 0]; Inputs: [0];