Introduction
BinPy is a python library with the vision to virtualize electronics.
It gives an easy way to design circuits and test them. One of the best thing about BinPy is that it has no dependencies other than pure python. Currently it supports python2.
Getting started
You can install BinPy using pip or you can install it using the source code
Installing using pip
sudo pip install BinPy
Installing using source code
~$ git clone http://github.com/BinPy/BinPy -b master ~$ cd BinPy ~/BinPy$ python setup.py installIt will install the latest stable version.
To install the development version
~$ git clone http://github.com/BinPy/BinPy ~$ cd BinPy ~/BinPy$ python setup.py install
Using BinPy
BinPy gives you the power of virtual electronic components. You have all 7400 series ICs, several 4000 series ICs, Logic Gates, Adder, Subtractor, Multiplier, MUX(2:1, 4:1, 8:1, 16:1), Latch, DFlipFlop, Counter, Clock at your disposal.Let's start our demo with making a small circuit to convert Gray Code numbers to BCD numbers.
W = A
X = NOT(A) AND B
Y = (NOT(A) AND B AND NOT(C)) OR (NOT(B) AND C)
Z = (NOT(A) AND B AND NOT(C) AND NOT(D)) OR (NOT(B) AND NOT(C) AND D) OR (B AND C AND D) OR (NOT(B) AND C AND NOT(D))
Implementing the converter using gates.
from BinPy import gates input = [] def gray_2_bcd(input): A = input[0] B = input[1] C = input[2] D = input[3] W = A X = AND(NOT(A), B) Y = OR(AND(NOT(A), B, NOT(C)), AND(C, NOT(B)) ) Z = OR(AND(NOT(A), B, NOT(C), NOT(D)), AND(NOT(B), NOT(C), D), AND(B, C, D), AND(NOT(B), C, NOT(D)) ) output = [W, X, Y, Z] return output
Next time we'll use 4000 Series ICs to implement the converter.