Skip to main content

Python Electronic Design Automation

Project description

PyEDA is a Python library for electronic design automation.

Read the docs!

https://travis-ci.org/cjdrake/pyeda.png?branch=master

Features

  • Symbolic Boolean algebra with a selection of function representations:

    • Logic expressions

    • Truth tables, with three output states (0, 1, “don’t care”)

    • Reduced, ordered binary decision diagrams (ROBDDs)

    • Fast, disjunctive/conjunctive normal form logic expressions

  • SAT solvers:

  • Formal equivalence

  • Multi-dimensional bit vectors

  • DIMACS CNF/SAT parsers

  • Logic expression parser

Download

Bleeding edge code:

$ git clone git://github.com/cjdrake/pyeda.git

For release tarballs and zipfiles, visit PyEDA’s page at the Cheese Shop.

Installation

Latest released version using setuptools:

$ easy_install pyeda

Latest release version using pip:

$ pip install pyeda

Installation from the repository:

$ python setup.py install

Getting Started With Logic Expressions

Invoke your favorite Python terminal, and invoke an interactive pyeda session:

>>> from pyeda.inter import *

Create some Boolean expression variables:

>>> a, b, c, d = map(exprvar, "abcd")

Construct Boolean functions using overloaded Python operators: - (NOT), + (OR), * (AND), >> (IMPLIES):

>>> f0 = -a * b + c * -d
>>> f1 = a >> b
>>> f2 = -a * b + a * -b
>>> f3 = -a * -b + a * b
>>> f4 = -a * -b * -c + a * b * c
>>> f5 = a * b + -a * c

Construct Boolean functions using standard function syntax:

>>> f10 = Or(And(Not(a), b), And(c, Not(d)))
>>> f11 = Implies(a, b)
>>> f12 = Xor(a, b)
>>> f13 = Xnor(a, b)
>>> f14 = Equal(a, b, c)
>>> f15 = ITE(a, b, c)

Construct Boolean functions using higher order operators:

>>> f20 = Nor(a, b, c)
>>> f21 = Nand(a, b, c)
>>> f22 = OneHot(a, b, c)
>>> f23 = OneHot0(a, b, c)

Investigate a function’s properties:

>>> f0.support
frozenset([a, b, c, d])
>>> f0.inputs
(a, b, c, d)
>>> f0.top
a
>>> f0.degree
4
>>> f0.cardinality
16
>>> f0.depth
2

Factor complex expressions into only OR/AND and literals:

>>> f11.factor()
a' + b
>>> f12.factor()
a' * b + a * b'
>>> f13.factor()
a' * b' + a * b
>>> f14.factor()
a' * b' * c' + a * b * c
>>> f15.factor()
a * b + a' * c

Restrict a function’s input variables to fixed values, and perform function composition:

>>> f0.restrict({a: 0, c: 1})
b + d'
>>> f0.compose({a: c, b: -d})
c' * d' + c * d'

Test function formal equivalence:

>>> f2.equivalent(f12)
True
>>> f4.equivalent(f14)
True

Investigate Boolean identities:

# Law of double complement
>>> --a
a

# Idempotent laws
>>> a + a
a
>>> a * a
a

# Identity laws
>>> a + 0
a
>>> a * 1
a

# Dominance laws
>>> a + 1
1
>>> a * 0
0

# Commutative laws
>>> (a + b).equivalent(b + a)
True
>>> (a * b).equivalent(b * a)
True

# Associative laws
>>> a + (b + c)
a + b + c
>>> a * (b * c)
a * b * c

# Distributive laws
>>> (a + (b * c)).to_cnf()
(a + b) * (a + c)
>>> (a * (b + c)).to_dnf()
a * b + a * c

# De Morgan's laws
>>> Not(a + b).factor()
a' * b'
>>> Not(a * b).factor()
a' + b'

# Absorption laws
>>> (a + (a * b)).absorb()
a
>>> (a * (a + b)).absorb()
a

Perform Shannon expansions:

>>> a.expand(b)
a * b' + a * b
>>> (a * b).expand([c, d])
a * b * c' * d' + a * b * c' * d + a * b * c * d' + a * b * c * d

Convert a nested expression to disjunctive normal form:

>>> f = a * (b + (c * d))
>>> f.depth
3
>>> g = f.to_dnf()
>>> g
a * b + a * c * d
>>> g.depth
2
>>> f.equivalent(g)
True

Convert between disjunctive and conjunctive normal forms:

>>> f = -a * -b * c + -a * b * -c + a * -b * -c + a * b * c
>>> g = f.to_cnf()
>>> h = g.to_dnf()
>>> g
(a + b + c) * (a + b' + c') * (a' + b + c') * (a' + b' + c)
>>> h
a' * b' * c + a' * b * c' + a * b' * c' + a * b * c

Getting Started With Multi-Dimensional Bit Vectors

Create some four-bit vectors, and use slice operators:

>>> A = bitvec('A', 4)
>>> B = bitvec('B', 4)
>>> A
[A[0], A[1], A[2], A[3]]
>>> A[2:]
[A[2], A[3]]
>>> A[-3:-1]
[A[1], A[2]]

Perform bitwise operations using Python overloaded operators: ~ (NOT), | (OR), & (AND), ^ (XOR):

>>> ~A
[A[0]', A[1]', A[2]', A[3]']
>>> A | B
[A[0] + B[0], A[1] + B[1], A[2] + B[2], A[3] + B[3]]
>>> A & B
[A[0] * B[0], A[1] * B[1], A[2] * B[2], A[3] * B[3]]
>>> A ^ B
[Xor(A[0], B[0]), Xor(A[1], B[1]), Xor(A[2], B[2]), Xor(A[3], B[3])]

Reduce bit vectors using unary OR, AND, XOR:

>>> A.uor()
A[0] + A[1] + A[2] + A[3]
>>> A.uand()
A[0] * A[1] * A[2] * A[3]
>>> A.uxor()
Xor(A[0], A[1], A[2], A[3])

Create and test functions that implement non-trivial logic such as arithmetic:

>>> from pyeda.logic.addition import *
>>> S, C = ripple_carry_add(A, B)
# Note "1110" is LSB first. This says: "7 + 1 = 8".
>>> S.vrestrict({A: "1110", B: "1000"}).to_uint()
8

Other Function Representations

Consult the documentation for information on normal form expressions, truth tables, and binary decision diagrams. Each function representation has different trade-offs, so always use the right one for the job.

Execute Unit Test Suite

If you have Nose installed, run the unit test suite with the following command:

$ make test

If you have Coverage installed, generate a coverage report (including HTML) with the following command:

$ make cover

Perform Static Lint Checks

If you have Pylint installed, perform static lint checks with the following command:

$ make lint

Build the Documentation

If you have Sphinx installed, build the HTML documentation with the following command:

$ make html

Python Versions Supported

PyEDA is developed using Python 3.2+. It is NOT compatible with Python 2.7.

Contact the Authors

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

pyeda-0.16.2.zip (153.5 kB view details)

Uploaded Source

pyeda-0.16.2.tar.gz (133.8 kB view details)

Uploaded Source

pyeda-0.16.2.tar.bz2 (112.6 kB view details)

Uploaded Source

Built Distributions

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

pyeda-0.16.2.win-amd64-py3.3.exe (328.0 kB view details)

Uploaded Source

pyeda-0.16.2.win-amd64-py3.2.exe (330.0 kB view details)

Uploaded Source

pyeda-0.16.2.win32-py3.3.exe (288.4 kB view details)

Uploaded Source

pyeda-0.16.2.win32-py3.2.exe (293.5 kB view details)

Uploaded Source

File details

Details for the file pyeda-0.16.2.zip.

File metadata

  • Download URL: pyeda-0.16.2.zip
  • Upload date:
  • Size: 153.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyeda-0.16.2.zip
Algorithm Hash digest
SHA256 5bc3e2665786243aa1d2c7dd46c7a85a7f1633924c69246af54a0c01020cdc5f
MD5 966f46cbd9da06178677cc785de46dbd
BLAKE2b-256 5f3b3fedca45a7097831569343f9dddb73dc71f243753cc1358ea3990d15a62b

See more details on using hashes here.

File details

Details for the file pyeda-0.16.2.tar.gz.

File metadata

  • Download URL: pyeda-0.16.2.tar.gz
  • Upload date:
  • Size: 133.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyeda-0.16.2.tar.gz
Algorithm Hash digest
SHA256 3d604c0a853a01c592abd4a0eb660c6710031b8c52f878d8c8e3c7383d66c275
MD5 e4af88f6ecce790f352aa160a8028425
BLAKE2b-256 fdba22785dbc5feeafe5693b6868ee0c4ca82277996f243989543e8d66fb2679

See more details on using hashes here.

File details

Details for the file pyeda-0.16.2.tar.bz2.

File metadata

  • Download URL: pyeda-0.16.2.tar.bz2
  • Upload date:
  • Size: 112.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyeda-0.16.2.tar.bz2
Algorithm Hash digest
SHA256 783ec2f2febf159c54b01f839cc711b9ae6ef09f15112ebc772c6784ec50cefa
MD5 08021d7eca6cdda799d4f8787a3b4059
BLAKE2b-256 0e452852dfd56f0d864c37b4120175161320231bcbda853fd81798359ad76065

See more details on using hashes here.

File details

Details for the file pyeda-0.16.2.win-amd64-py3.3.exe.

File metadata

File hashes

Hashes for pyeda-0.16.2.win-amd64-py3.3.exe
Algorithm Hash digest
SHA256 dcfdc09eb1633010f081799a506443b87d5da05358080b286d1618aef7e48d3e
MD5 42515b86bad6484eea698c613d64f14f
BLAKE2b-256 e6a48d965c44720a25188fcda2bae4b98cc669dd791e8faa55535c97ac104d25

See more details on using hashes here.

File details

Details for the file pyeda-0.16.2.win-amd64-py3.2.exe.

File metadata

File hashes

Hashes for pyeda-0.16.2.win-amd64-py3.2.exe
Algorithm Hash digest
SHA256 6672e39481ae3f5ce985c01a18cd583f2d58ad9103859b66943ddc0dff1facfb
MD5 b66edb456d6bd5c3b9b6751bd99c5802
BLAKE2b-256 f553c6c1f9d81a08a5c70aeeaa65c6a2e6032f5b11cd608cc9ab72673aaa4003

See more details on using hashes here.

File details

Details for the file pyeda-0.16.2.win32-py3.3.exe.

File metadata

File hashes

Hashes for pyeda-0.16.2.win32-py3.3.exe
Algorithm Hash digest
SHA256 1ed8d38546881b414a1b3b9fb8cf17b1d0d69075a6a3469bffd61b8cc02b1fc6
MD5 512f78a6d492d933e335e2458d236a4a
BLAKE2b-256 4e3140db8b04aa7bf839be99818cb093c30a7158896a102dcdc7709ed368b946

See more details on using hashes here.

File details

Details for the file pyeda-0.16.2.win32-py3.2.exe.

File metadata

File hashes

Hashes for pyeda-0.16.2.win32-py3.2.exe
Algorithm Hash digest
SHA256 4b43e617ddbe1d4ba1d900d2d71c022000d20e00c2e5e347205d133d0b56bc5e
MD5 73878bdfbc22b9f5ea5b0659fd18ad8d
BLAKE2b-256 32cb8e7cc7460fcfe9b8dfa82dd07a529dfe6d197d07e39e0272c61322c2ffa9

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