Skip to main content

A simple Python AIG package

Project description

PyAIG: A simpe Python AIG and Truth Table package

AIG

And-Inverter Graph (AIG) is a data structure for logic synthesis and verification. The code follows the AIGER conventions.

Installation

Install using pip:

pip install .

Truth Tables example

Import the package

from pyaig import *

Create the truth table manger - the max number of variables is required

m = truth_tables(6, "ABCDEF")

If the second parameter to truth_tables is provided, it automatically inserts the sequence of names into the global namespace

Build truth tables with operator overloading

f = A.ite(B, C ^ D) & E | F

The truth table support |, &, ^, and ~ for OR, AND, XOR, INVERT, respectively. It also supports ite (if-then-else), iff (if-and-only-if, or EXOR) and implies (logical implication).

Output the truth table

print(f)

Will print the truth as a prime-irredudant cover, in this case:

A&B&E + ~A&C&~D&E + ~A&~C&D&E + F

Or,

print(f.SOP())

Resulting in

-----1 1
0-011- 1
0-101- 1
11--1- 1

Or

print(f.isop())

Resulting in

[{1, 2, 5}, {3, -4, 5, -1}, {-3, 4, 5, -1}, {6}]

All three are the same cover. The first is a human-readable expression. The second is similar to Espresso and BLIF formats, and the third is the list of cubes where negative means negation and the nubmer is the variable number starting from 0.

Manipulate truth tables

In addition to the above, it supports permuting and negating inputs and the output, generating the list of all NPN-equivalent functions and a few other operations.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pyaig-1.0.13-py3-none-any.whl (23.1 kB view hashes)

Uploaded Python 3

pyaig-1.0.13-py2-none-any.whl (23.1 kB view hashes)

Uploaded Python 2

Supported by

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