Skip to main content

Full-featured digital logic library in Python

Project description


LogicB - Python Digital Logic Simulator
=======================================

LogicB is a full-featured digital logic library written in pure Python.
It allows you to simulate combinational and sequential circuits, perform
binary arithmetic, work with multi-bit adders/subtractors/multipliers/dividers,
and build custom encoders/decoders and counters. You can also connect
logic gates together to create complete circuits.

Features
--------
1. Logic Gates:
- AND, OR, NOT, NAND, NOR, XOR, XNOR

2. Converters:
- Binary <-> Hexadecimal
- Binary <-> Decimal
- Decimal <-> Hexadecimal

3. Multi-bit Arithmetic:
- Adders, Subtractors, Multipliers, Dividers

4. Circuit System:
- Gate class to connect inputs and outputs recursively
- Create complex circuits from simple gates

5. Multiplexers / Demultiplexers:
- 2:1 MUX, 1:2 DEMUX (expandable)

6. Encoders / Decoders:
- Custom mappings from input to binary output and vice versa

7. Sequential Circuits:
- Flip-flops: D, T, JK, SR
- Shift Registers: serial-in/serial-out, parallel-in/parallel-out

8. Counters:
- Binary counter
- Ring counter
- Johnson counter

9. Utilities:
- Truth table generator
- Multi-bit circuit simulation

Installation
------------
LogicB can be installed via PyPI (see instructions below):

pip install LogicB

Usage
-----
```python
from LogicB import AND, OR, Gate, DFlipFlop, adder, truth_table

# Simple gates
print(AND(1,0)) # Output: 0
print(OR(1,0)) # Output: 1

# Multi-bit adder
print(adder("1010","0111")) # Output: "10001"

# Circuit system
a, b = 1, 0
g1 = Gate(AND)
g1.connect(a, b)
print(g1.output()) # Output: 0

# Flip-flop example
dff = DFlipFlop()
print(dff.clock(1)) # Output: 1

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logicb-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logicb-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file logicb-0.1.0.tar.gz.

File metadata

  • Download URL: logicb-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for logicb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 86f4276f62044cb4811a344e2059eec3f81054c09ed21cb955d186bd443073e0
MD5 532806d2fb893d55a64d80f268641382
BLAKE2b-256 068cffef98cdf6008860acbe37a3192691e34bdcc5fef7d7659b0c59aa5d303b

See more details on using hashes here.

File details

Details for the file logicb-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: logicb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for logicb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9fab58310777a412277658ef493224d08b42132cd36d822c440de51b32698ef1
MD5 778583bacdc943b138150ae704de5202
BLAKE2b-256 54a3f0a80b0d8cb74865ed027928fc803225c7cf9e077c376e38e216a04c14f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page