Package: logic-py
Logic_PyUpdate : Logic_Py 0.4.1If input array contains a non-binary element, A ValueError is returned with the exact location of non-binary element in the input arrayfrombasic_gatesimportANDA=[1,0,1,3]B=[0,0,1,1]y=AND(A,B)Above code returnsValueError: input must be binary, 0 or  1 in first input index 3If all the input array lengths are not same, Again code throws a ValueErrorfrombasic_gatesimportORA=[1,0,1]B=[0,0,1,1]y=OR(A,B)Above code returnsValueError: Length of both inputs must be sameHalf subtractor and Full subtractor are added to Arithmatic gatesfromarithmatic_gatesimporthalf_subtractor,full_subtractorB=[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 circuitsfromcombinational_gatesimportBCD2Excess3,Excess32BCDA=[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,zEncoders and Decoders are added to Logic circuitsfromLogic_circuitsimportDecoder2_4,Decoder4_16,Decoder3_8,Encoder2_1,Encoder4_2,Encoder8_3,Priority_Enc4_2Plots are added for half subtractor and full subtractorfromplottingimportplot_half_subtractorx,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.IntroductionThis 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.Installationpip install logic-pyfromLogic_PyimportAND,full_adder,plot_secondaryBasic Gatesbasic_gatesThere are 7 basic gates, all other secondaary and combinational gates are the combinations of these 7 basic gates.AND, OR, NOT, NAND, NOR,XNOR,XORfromLogic_PyimportANDSecondary Gatessecondary_gatesThere 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 Gatescombintional_gatesFew 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, BCD2Excess3Arithmatic Gatesarithmatic_gatesTwo arithmatic gates are added for the beta version, more will follow in the coming update.update 0.4.1 added subtractorsHalf Adder -half_adderFull Adder -full_adderHalf Subtractor -half_subtractorFull Subtractor -full_subtractorPlotsplottingPlots 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 addedplot_half_adderandplot_full_adderCitationTutorialspoint - digital circuit basicsGeeksforgeeks digital circuitsUseGithubfor 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 consolehelp(AND)