Skip to main content

SIRC - Digital Logic and Circuit Simulation Engine

Project description

SIRC

SIRC - Digital Logic and Circuit Simulation Engine

SIRC is a lightweight, fully typed Python library for simulating digital logic at the transistor level. It models Nodes, Devices, and Transistors and computes stable LogicValues through fixed-point iteration and dynamic connectivity.


📦 Installation

Install from PyPI:

pip install sirc

Import the device simulator:

from sirc.simulator.device import DeviceSimulator

🚀 Quick Start

from sirc.simulator.device import DeviceSimulator
from sirc.core.logic import LogicValue
from sirc.core.transistor import NMOS, PMOS
from sirc.core.device import VDD, GND, Input, Probe, Port

sim = DeviceSimulator()

# Create Devices and Transistors
vdd = VDD()
gnd = GND()

inp = Input()
probe = Probe()

inp_port = Port()
out_port = Port()

pmos = PMOS()
nmos = NMOS()

# Register Devices and Transistors
sim.register_devices([vdd, gnd, inp, probe, inp_port, out_port])
sim.register_transistors([pmos, nmos])

# Connect Components
sim.connect(inp.terminal, inp_port.terminal)
sim.connect(inp_port.terminal, pmos.gate)
sim.connect(inp_port.terminal, nmos.gate)
sim.connect(vdd.terminal, pmos.source)
sim.connect(gnd.terminal, nmos.source)
sim.connect(pmos.drain, out_port.terminal)
sim.connect(nmos.drain, out_port.terminal)
sim.connect(out_port.terminal, probe.terminal)

# Simulate and Sample Output
inp.set_value(LogicValue.ONE)
sim.tick()
print(repr(probe.sample()))

# Change Input and Resimulate
inp.set_value(LogicValue.ZERO)
sim.tick()
print(repr(probe.sample()))

🔧 Features

Core Devices

  • VDD
  • GND
  • Input
  • Probe
  • Port

Transistors

  • NMOS
  • PMOS

Fully Typed

from sirc.simulator.device import DeviceSimulator
from sirc.core.logic import LogicValue
from sirc.core.node import Node
from sirc.core.device import LogicDevice, VDD, GND, Input, Probe, Port
from sirc.core.transistor import Transistor, NMOS, PMOS

📂 Project Structure

src/
    sirc/
        core/
            device.py
            logic.py
            node.py
            transistor.py
        simulator/
            device.py
tests/
    sirc/
        core/
            test_device.py
            test_logic.py
            test_node.py
            test_transistor.py
        simulator/
            test_device.py

🧪 Testing

Run the full test suite:

pytest

📝 License

MIT License


🔗 Links

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

sirc-1.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

sirc-1.1.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file sirc-1.1.0.tar.gz.

File metadata

  • Download URL: sirc-1.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sirc-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b5ec7016e336045b997ed16075f6147ba915e230127309c7f7cdcbece2f28fa9
MD5 609443b15e4b9d9e854e7b2f51f75082
BLAKE2b-256 400c5590b405a8faadfe3cfb53ffa35ec13c59c11860940e446dc7cad7a28993

See more details on using hashes here.

File details

Details for the file sirc-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: sirc-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sirc-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19cc933fc791708dc9390eb94be0acb12a65cb08ca658889fd28f0b876112f21
MD5 8053fe399edd92a139c806d58337c1c9
BLAKE2b-256 ca0ab7afff81a1709a186d1c07f25133587245efa328827b2699167e644e9c69

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