BinPy.Combinational package

Submodules

BinPy.Combinational.combinational module

class BinPy.Combinational.combinational.BCDAdder(input1, input2, carry)[source]

Bases: BinPy.Gates.gates.GATES

This Class implements 4 bit BCD Adder, and return its BCD Sum and Carry Output: [SUM, CARRY] Example:

>>> from BinPy import *
>>> ba = BCDAdder([0, 1, 1, 0], [1, 0, 1, 0], 0)
>>> ba.output()
[0, 0, 0, 0, 1]
fill(arr, size)[source]
setOutput(index, value)[source]
trigger()[source]
class BinPy.Combinational.combinational.BinaryAdder(input1, input2, carry)[source]

Bases: BinPy.Gates.gates.GATES

This Class implements Binary Adder, Arithmetic sum of two bit strings and return its Sum and Carry Output: [CARRY, SUM] Example:

>>> from BinPy import *
>>> ba = BinaryAdder([0, 1], [1, 0], 0)
>>> ba.output()
[0, 1, 1]
fill(arr, size)[source]
setOutput(index, value)[source]
trigger()[source]
class BinPy.Combinational.combinational.BinarySubtractor(input1, input2, borrow)[source]

Bases: BinPy.Gates.gates.GATES

This Class implements Binary Subtractor, Arithmetic difference of two bit strings and return its difference and borrow Output: [BORROW, DIFFERENCE] Example:

>>> from BinPy import *
>>> bs = BinarySubtractor([0, 1], [1, 0], 1)
>>> bs.output()
[1, 1, 0]
fill(arr, size)[source]
setOutput(index, value)[source]
trigger()[source]
class BinPy.Combinational.combinational.DEMUX(*inputs)[source]

Bases: BinPy.Gates.gates.GATES

This class can be used to create DEMUX in your circuit. DEMUX is used to select It takes single input and n select lines and decode the select lines into BCD form base upon the input. In case of high input, it works as a decoder. INPUT: Single Input, 1 or 0 OUTPUT: BCD form of select lines in case of high input, else low output SELECT LINES: nth select line at nth index

Example:
>>> from BinPy import *
>>> demux = DEMUX(0)             "DEMUX takes 1 input (digital or Connector)"
>>> demux.selectLines(0)         "Put select Lines"
>>> demux.output()
[0, 0]
>>> demux.selectLine(0, 1)       "Select line at index 0 is changed to 1"
>>> demux.output()
[0, 1]
selectLine(index, value)[source]
selectLines(*select)[source]
setInput(index, value)[source]
setInputs(*inputs)[source]
setOutput(index, value)[source]
trigger()[source]
class BinPy.Combinational.combinational.Decoder(*inputs)[source]

Bases: BinPy.Gates.gates.GATES

This class can be used to create decoder in your circuit. Input is taken as Binary String and returns the equivalent BCD form. INPUT: n Binary inputs, nth input ant the nth index OUTPUT: Gives equivalent BCD form

Example:
>>> decoder = Decoder(0)            "Decoder with 1 input, 0"
>>> decoder.output()
[1, 0]
>>> decoder.setInputs(0, 1)         "sets the new inputs to the decoder"
[0, 1, 0, 1]
setInput(index, value)[source]
setInputs(*inputs)[source]
setOutput(index, value)[source]
trigger()[source]
class BinPy.Combinational.combinational.Encoder(*inputs)[source]

Bases: BinPy.Gates.gates.GATES

This class can be used to create encoder in your circuit. It converts the input BCD form to binary output. It works as the inverse of the decoder INPUT: Input in BCD form, length of input must me in power of 2 OUTPUT: Encoded Binary Form

Example:
>>> encoder = Encoder(0, 1)             "Encoder with BCD input 01 "
>>> encoder.output()                    "Binary Form"
[1]
>>> encoder.setInputs(0, 0, 0, 1)       "Sets the new inputs"
[1 , 1]
setInput(index, value)[source]
setInputs(*inputs)[source]
setOutput(index, value)[source]
trigger()[source]
class BinPy.Combinational.combinational.FullAdder(input1, input2, carry)[source]

Bases: BinPy.Gates.gates.GATES

This Class implements Full Adder, Arithmetic sum of three bits and return its Sum and Carry Output: [SUM, CARRY] Example:

>>> from BinPy import *
>>> fa = FullAdder(0, 1, 1)
>>> fa.output()
[0, 1]
setOutput(index, value)[source]
trigger()[source]
class BinPy.Combinational.combinational.FullSubtractor(input1, input2, borrow)[source]

Bases: BinPy.Gates.gates.GATES

This Class implements Full Subtractor, Arithmetic difference of three bits and return its Difference and Borrow Output: [DIFFERENCE, BORROW] Example:

>>> from BinPy import *
>>> fs = FullSubtractor(0, 1, 1)
>>> fs.output()
[0, 1]
setOutput(index, value)[source]
trigger()[source]
class BinPy.Combinational.combinational.HalfAdder(input1, input2)[source]

Bases: BinPy.Gates.gates.GATES

This Class implements Half Adder, Arithmetic sum of two bits and return its Sum and Carry Output: [SUM, CARRY] Example:

>>> from BinPy import *
>>> ha = HalfAdder(0, 1)
>>> ha.output()
[1, 0]
setOutput(index, value)[source]
trigger()[source]
class BinPy.Combinational.combinational.HalfSubtractor(input1, input2)[source]

Bases: BinPy.Gates.gates.GATES

This Class implements Half Subtractor, Arithmetic difference of two bits and return its Difference and Borrow output Output: [DIFFERENCE, BORROW] Example:

>>> from BinPy import *
>>> hs = HalfSubtractor(0, 1)
>>> hs.output()
[1, 1]
setOutput(index, value)[source]
trigger()[source]
class BinPy.Combinational.combinational.MUX(*inputs)[source]

Bases: BinPy.Gates.gates.GATES

This class can be used to create MUX in your circuit. MUX is used to select a single output line out of many inputs. This class can be used as any 2^n X n Multiplexer where n is the number of select lines used to select the input out of 2^n input lines. INPUT: nth index has nth input value, input should be power of 2 OUTPUT: single output, 1 or 0 SELECT LINES: In binary form, select line for 4 will be 1 0 0

Example:
>>> from BinPy import *
>>> mux = MUX(0, 1)            "MUX takes its 2^n inputs (digital or Connector)"
>>> mux.selectLines(0)         "Put select Line"
>>> mux.output()
0
>>> mux.selectLine(0, 1)       "Select line at index 0 is changed to 1"
>>> mux.output()
1
>>> mux.setInput(1, 0)         "Input line at index 1 is changed to 0"
>>> mux.output()
0
selectLine(index, value)[source]
selectLines(*select)[source]
setInput(index, value)[source]
trigger()[source]

Module contents

Table Of Contents

Previous topic

BinPy.Analog package

Next topic

BinPy.Gates package

This Page