Skip to main content

Logic_Py

Made with Python3 GitHub license Github version

Update : Logic_Py 0.4.1

  • If input array contains a non-binary element, A ValueError is returned with the exact location of non-binary element in the input array
from basic_gates import AND
A = [1,0,1,3]
B = [0,0,1,1]
y = AND(A,B)

Above code returns ValueError: input must be binary, 0 or 1 in first input index 3

  • If all the input array lengths are not same, Again code throws a ValueError
from basic_gates import OR
A = [1,0,1]
B = [0,0,1,1]
y = OR(A,B)

Above code returns ValueError: Length of both inputs must be same

  • Half subtractor and Full subtractor are added to Arithmatic gates
from arithmatic_gates import half_subtractor, full_subtractor
B = [1,1,0,1,1,0,0,1,0,0]
A = [0,0,0,1,0,1,1,0,1,1]
Difference, Borrow = half_subtractor(A,B)
print("Difference : ", Difference, "Borrow : ", Borrow)

Above snippet returns Difference : Difference : [1, 1, 0, 0, 1, 1, 1, 1, 1, 1] Borrow : [0, 0, 0, 0, 0, 1, 1, 0, 1, 1]

  • Code conversions BCD to Excess3 and vice versa are added to Combinational circuits
from combinational_gates import BCD2Excess3, Excess32BCD
A = [1,1,0,1,1,0,0,1,0,0]
B = [0,0,0,1,0,1,1,0,1,1]
C = [0,1,0,1,0,1,0,0,0,0]
D = [1,1,0,1,1,0,0,1,0,0]
w,x,y,z = BCD2Excess3(A,B,C,D)

Above code saves 4 coverted Excess3 bits in w,x,y,z

  • Encoders and Decoders are added to Logic circuits
from Logic_circuits import Decoder2_4,Decoder4_16,Decoder3_8,Encoder2_1,Encoder4_2,Encoder8_3,Priority_Enc4_2
  • Plots are added for half subtractor and full subtractor
from plotting import plot_half_subtractor
x,y = plot_half_subtractor(B,C)

Above snippet returns a plot of difference and Borrow and also loads difference and borrow onto the variables x and y. Half Subtractor

Introduction

This Python package enables the user to realise Logic based combinational circuits built on basic logic gates. All the inputs must be binary and of same length for the functions to perform desired operation.

Installation

pip install logic-py

from Logic_Py import AND, full_adder, plot_secondary

Basic Gates

basic_gates

There are 7 basic gates, all other secondaary and combinational gates are the combinations of these 7 basic gates.

  • AND, OR, NOT, NAND, NOR,XNOR,XOR
from Logic_Py import AND

Secondary Gates

secondary_gates

There are 16 Secondary gates, which take 4 binary inputs and 1 binary output.

  • AND_AND, AND_OR, AND_NAND, AND_NOR, OR_AND, OR_OR, OR_NAND, OR_NOR, NAND_AND, NAND_OR, NAND_NAND, NAND_NOR, NOR_AND, NOR_OR, NOR_NAND, NOR_NOR,

Combinational Gates

combintional_gates

Few combinational circuits are added as start in this beta version, few more will follow in the coming update.

  • Binary2Gray, Gray2Binary, EParity_gen, EParity_check, OParity_gen, OParity_check, Excess32BCD, BCD2Excess3

Arithmatic Gates

arithmatic_gates Two arithmatic gates are added for the beta version, more will follow in the coming update. update 0.4.1 added subtractors

  • Half Adder - half_adder
  • Full Adder - full_adder
  • Half Subtractor - half_subtractor
  • Full Subtractor - full_subtractor

Plots

plotting

Plots for the basic gates, secondary gates and arithmatic gates are available with the current version.

  • plot_full_adder, plot_half_adder, plot_secondary, plot_basic
  • *update 0.4.1 added plot_half_adder and plot_full_adder

Citation

Use Github for further updates. Please kindly cite incase you use the package and fork.

Use Hellow world example for the syntax or use help function in python console

help(AND)

Metadata

Release files for logic-py 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for logic-py 0.4.3
File Size Uploaded Provenance
Logic_Py-0.4.3.tar.gz 11.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for logic-py 0.4.3
File Interpreter ABI Platform
Logic_Py-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 28.5 kB

Release files / Logic_Py-0.4.3.tar.gz

Download URL Logic_Py-0.4.3.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2f9ad33d19df94c092c8c39046ce1523f597dd9b4f097655862030da9f9f520c
BLAKE2b-256 checksum
How to use checksums
c0ccc5842ee4ffe0927ad5e5637fa676a15b28606ad31a64a8d35d7646365bf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.7.10 Windows/10

Release files / Logic_Py-0.4.3-py3-none-any.whl

Download URL Logic_Py-0.4.3-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bdd9a317d38ffcf57a67d5a1c4658cef66e8e45d46381beecdcb39cf871968fc
BLAKE2b-256 checksum
How to use checksums
b46f1e631bf410745df46f272e331c36c86774c157fc3eb1cb9494c2b9352364
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.7.10 Windows/10

Security for logic-py 0.4.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page