A Python library for working with logic networks, synthesis, and optimization.
Project description
aigverse: A Python Library for Logic Networks, Synthesis, and Optimization
[!Important] This project is still in the early stages of development. The API is subject to change, and some features may not be fully implemented. I appreciate your patience and understanding as work to improve the library continues.
aigverse
is a Python framework designed to bridge the gap between logic synthesis and AI/ML applications. It allows
you to represent and manipulate logic circuits efficiently, making it easier to integrate logic synthesis tasks into
machine learning pipelines. By leveraging the
powerful EPFL Logic Synthesis Libraries,
particularly mockturtle, aigverse
provides a high-level Python interface to
state-of-the-art algorithms for And-Inverter Graph (AIG) manipulation and logic synthesis, widely used in formal
verification, hardware design, and optimization tasks.
Features
- Efficient Logic Representation: Use And-Inverter Graphs (AIGs) to model and manipulate logic circuits in Python.
- File Format Support: Read and write AIGER, Verilog, Bench, PLA, ... files for interoperability with other logic synthesis tools.
- C++ Backend: Leverage the performance of the EPFL Logic Synthesis Libraries for fast logic synthesis and optimization.
- High-Level API: Simplify logic synthesis tasks with a Pythonic interface for AIG manipulation and optimization.
- Integration with Machine Learning: Convenient integration with popular data science libraries.
Motivation
As AI and machine learning (ML) increasingly impact hardware design automation, there's a growing need for tools that
integrate logic synthesis with ML workflows. aigverse
provides a Python-friendly interface for logic synthesis, making
it easier to develop applications that blend both AI/ML and traditional circuit synthesis techniques. With aigverse
,
you can parse, manipulate, and optimize logic circuits directly from Python. Eventually, we aim to provide seamless
integration with popular ML libraries, enabling the development of novel AI-driven synthesis and optimization tools.
Installation
aigverse
requires Python 3.8+ and is built using the EPFL Logic Synthesis Libraries
with pybind11. To install aigverse
:
pip install aigverse
Usage
Basic Example: Creating an AIG
In aigverse
, you can create a simple And-Inverter Graph (AIG) and manipulate it using various logic operations.
from aigverse import Aig
# Create a new AIG network
aig = Aig()
# Create primary inputs
x1 = aig.create_pi()
x2 = aig.create_pi()
# Create logic gates
f_and = aig.create_and(x1, x2) # AND gate
f_or = aig.create_or(x1, x2) # OR gate
# Create primary outputs
aig.create_po(f_and)
aig.create_po(f_or)
# Print the size of the AIG network
print(f"AIG Size: {aig.size()}")
Iterating over AIG Nodes
You can iterate over all nodes in the AIG, or specific subsets like the primary inputs or only logic nodes (gates).
# Iterate over all nodes in the AIG
for node in aig.nodes():
print(f"Node: {node}")
# Iterate only over primary inputs
for pi in aig.pis():
print(f"Primary Input: {pi}")
# Iterate only over logic nodes (gates)
for gate in aig.gates():
print(f"Gate: {gate}")
# Iterate over the fanins of a node
for fanin in aig.fanins(f_and):
print(f"Fanin of {f_and}: {fanin}")
Logic Optimization
You can optimize AIGs using various algorithms. For example, you can perform resubstitution to simplify logic using shared divisors.
from aigverse import aig_resubstitution
# Clone the AIG network for size comparison
aig_clone = aig.copy()
# Optimize the AIG using resubstitution
aig_resubstitution(aig)
# Print the size of the unoptimized and optimized AIGs
print(f"Original AIG Size: {aig_clone.size()}")
print(f"Optimized AIG Size: {aig.size()}")
Equivalence Checking
Equivalence of AIGs (e.g., after optimization) can be checked using SAT-based equivalence checking.
from aigverse import equivalence_checking
# Perform equivalence checking
equiv = equivalence_checking(aig1, aig2)
if equiv:
print("AIGs are equivalent!")
else:
print("AIGs are NOT equivalent!")
AIGER Files
You can read and write (ASCII) AIGER files.
Parsing
from aigverse import read_aiger_into_aig, read_ascii_aiger_into_aig
# Read AIGER files into AIG networks
aig1 = read_aiger_into_aig("example.aig")
aig2 = read_ascii_aiger_into_aig("example.aag")
# Print the size of the AIGs
print(f"AIG Size: {aig1.size()}")
print(f"AIG Size: {aig2.size()}")
Writing
from aigverse import write_aiger
# Write an AIG network to an AIGER file
write_aiger(aig, "example.aig")
Exporting Edge Lists
You can export the AIG as an edge list, which is useful for integration with graph libraries like NetworkX.
from aigverse import to_edge_list
# Export the AIG as an edge list
edges = to_edge_list(aig)
print(edges)
# Convert to list of tuples
edges = [(e.source, e.target, e.weight) for e in edges]
Contributing
Contributions are welcome! If you'd like to contribute to aigverse
, please submit a pull request or open an issue. If
appreciate feedback and suggestions for improving the library.
License
aigverse
is available under the MIT License.
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
Built Distributions
Hashes for aigverse-0.0.7-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ffa72bb03ac711a53bf9ee9e1411a45ea16088c32e905ef0a773227297196b2 |
|
MD5 | 32bdbbb393387d4cceed60e8a62c686d |
|
BLAKE2b-256 | 5175201e3512260c9bec88758ab9953d27beac099357833e34df7cdda5f8aff8 |
Hashes for aigverse-0.0.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8e4eac04ba7816519b3ac27c40e0dd93c2fdf0aed3f04abecf106d7f9c8d63a |
|
MD5 | 4658ff0a8c3a98cf7d919458067eb6a4 |
|
BLAKE2b-256 | 5d949cfd44122ac9e8976adc7a7c9dcfd638b2201ce45f273eae7c8707b90f11 |
Hashes for aigverse-0.0.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c8ad630507c9288f4d64c6129b10d33a2adf5eab47d64eefecac3efe2943a65 |
|
MD5 | f69a46b0599101f7aa52fb21bf7ec170 |
|
BLAKE2b-256 | 122d6da69eccb0f0997c76ddf85738cb06e2fee44b1028a9e3174c5146eb7360 |
Hashes for aigverse-0.0.7-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 506e0bc82a84399ad17f400874eef25d8caeec460eb5b46e1e1fc1592b467228 |
|
MD5 | acbd785a18ab95dff02038a344d0ff60 |
|
BLAKE2b-256 | 4dc5068d5746ad611fe4a36696bc85ad20bd5c8495bff1fed94370536fd07245 |
Hashes for aigverse-0.0.7-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b93964046676f9c63ab95bfed3d3bb3079f1d6475cf1baf18bbb407b20426a4 |
|
MD5 | 4fb8b9efd0443cc3f1771cb0a0afa780 |
|
BLAKE2b-256 | 4b2bdbd864cd3172d31864fbf8ab1e86486bded3e4a9f217ec1bba6078b4a883 |
Hashes for aigverse-0.0.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ed4b5aeeff6351ee5ddae7c373b6e71b6265d97d48e5900b138067c081cf4f2 |
|
MD5 | f7ac42885b4bd4221cd6dd95df4f526a |
|
BLAKE2b-256 | 8b5bbea4c0d2e4b392964396234ab23117d812251974f3398212c69e17f280bf |
Hashes for aigverse-0.0.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a74639a20b589408f96ded2625f79152d37e2b282e0337d20885f05fce0593a1 |
|
MD5 | 9589fb943292f24d786c298634ac961e |
|
BLAKE2b-256 | 87f9e5a742bf36666dfa3884619bd0e31116b06575227c8ecdbad97be08eb55e |
Hashes for aigverse-0.0.7-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cac61f9280e42bc811ca8577a48a1d1afa6b3250fa5f67c5b4db10c5f57541f |
|
MD5 | 70c3a57524befe7eb09b00532a059946 |
|
BLAKE2b-256 | a092de4d3f98be37c5050bbf0257a835717168a9ad87f094d2f00ce1ed9a52ca |
Hashes for aigverse-0.0.7-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1aa6fa850185beccd7f2d66c0b87bda0e7133be841133f3e09af92009976198 |
|
MD5 | c6b668c7be45c65319a7347ff2ef3645 |
|
BLAKE2b-256 | 49b5eb4d1f2423e75dc961fb7a427ff27527ed6ce1ffcde105796429de5cf78f |
Hashes for aigverse-0.0.7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d92183445bd79a2aaeb7d9cd2f0a4ea9124b6fffda06bb17ec09fb0f0ae170a |
|
MD5 | d0a11386410cec29b07e5b6d4b9800f2 |
|
BLAKE2b-256 | 5b5a60f31f8f4d199a4f7afde434c3017782dc02e612e33f19e98487181991f2 |
Hashes for aigverse-0.0.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7e5f8ea935371a073c45acd42b0c613539a5ce9e2b643a34869fb4500342e24 |
|
MD5 | a9ae04cee5d08daa5037fb117cba1964 |
|
BLAKE2b-256 | 8e967f7ff239ba906d30689a53debbd11bd6bbae344d4ae8b51bb194a9625939 |
Hashes for aigverse-0.0.7-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d67a212d12a0f422a09119218a373c72030792739fdf73046037b6124c65f988 |
|
MD5 | 8d6ba59d2b9434a116cd26e2bda76816 |
|
BLAKE2b-256 | 26d405f6914e751f9072e9f1dbdb1b194ec4bc0cb8b0be86c72d9c548d41554f |
Hashes for aigverse-0.0.7-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba07d9d4008fd255e8bed2114c99274be81f6046b0e7e7b3845cf5e651cea8c3 |
|
MD5 | dac38f283a0725d79768ad207917ad08 |
|
BLAKE2b-256 | 5c8d311b63f84b25e6bc9a3d5fbb595fb25c6f1d386e3a2591b76e190c2d5ae1 |
Hashes for aigverse-0.0.7-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13c55a9bce846501979a5f4db2d34b38ca27164ce5bbce2d46bff78c42a5d3fd |
|
MD5 | 0395e416408828021991e8bbf03d2233 |
|
BLAKE2b-256 | 3d27169f18047393a7bd7f85e098670e53d45db6656017496b7019af978abafd |
Hashes for aigverse-0.0.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9e6e00743dd12364cc465479144263f9bee17454c7cfee42f53d8268c9dbe4c |
|
MD5 | 0875b4e7c3d67172f1746972a084a99f |
|
BLAKE2b-256 | e71cd6d82929c3e8417a0dd3897cff0fb7c5da9b38918f7c0add63e4cb0392f6 |
Hashes for aigverse-0.0.7-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dad474b624429c3e382325c4966566ebffb8515a97a00bbdb0e50d7b846f9324 |
|
MD5 | cdf0abade5dfae57cffa6ecdd019728e |
|
BLAKE2b-256 | eb5975a098bf6b7c772b68dc0f40c11ca77a62ff8a4af21e2d781f3470ca658d |
Hashes for aigverse-0.0.7-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1bf54ecdd05b1b81820bf3add272a7ecac073521b382fa17e5e7e9d2bbeec7d |
|
MD5 | 099370d896426c5359063776d8654bcf |
|
BLAKE2b-256 | dfbc5b136792c66ebd7eeed88c0927666a43e755bd51016f34a6e30d141ec70b |
Hashes for aigverse-0.0.7-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b97144c42bf7db2b1d75ed1728de99970c15f6d70e579a87679fb3e42b18e70 |
|
MD5 | cd4f3dc0b316d2472bf3f9e83438a3fb |
|
BLAKE2b-256 | 431612139010b80fe2b51d90b8e9d39083f7e971d69548142bcd79557c0f4134 |
Hashes for aigverse-0.0.7-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9270f5cb85478314e4e599741a7e6a2d05197c384814df8baa6272089cff2e91 |
|
MD5 | 0126caca867bdb5f5a4555a9d59ea880 |
|
BLAKE2b-256 | 625e08285cc7a54e035c41e82168bf844e25a7cf7e80054d0156d1cd9051ef83 |
Hashes for aigverse-0.0.7-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e82abb1729e4fa05ee0aa9a9633e45b2c695488e9ea4c9d0c0af40ebb7bf087a |
|
MD5 | 1b820b3e5e7899f26c368a844a625d15 |
|
BLAKE2b-256 | 55e58229a99ed322b8acf94f6488ca2876397b4decbb93086e2cd2e5256da1a2 |