GithubHelp home page GithubHelp logo

snowkylin / npn Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 21 KB

A boolean matcher that computes the NPN canonical representative for a given boolean function.

CMake 0.79% Python 36.88% C++ 62.34%
cpp eda logic-synthesis npn pypi-package python boolean-matcher

npn's Introduction

NPN: Compute canonical representatives for boolean functions

This package is a boolean matcher. It simply computes the canonical representative, which is unique for each NPN equivalence class, for a given boolean function represented by truth table.

The backend of this package is implemented by C++ for efficiency.

Currently, this package supports boolean functions with number of inputs <= 8.

Install

pip install npn

Usage

import npn

# the truth table of f(x_2, x_1, x_0) as [f(0, 0, 0), f(0, 0, 1), f(0, 1, 0), f(0, 1, 1), ...]
tt = [True, True, True, False, True, True, True, True]
c = npn.npn_canonical_representative(tt)    # [True, True, True, True, True, True, True, False]
c_int = npn.tt_to_int(c)                    # 254 (11111110)
c, phase, perm, output_inv = npn.npn_canonical_representative(tt, return_details=True, refinement=True)
  • Set return_details parameter to True to return the NPN transformation information (phase, perm, output_inv). For example, here phase = [False, False, True], perm = [0, 1, 2] and output_inv = False means (x_0, x_1, x_2) should be mapped to (x_0, x_1, x_2), then the third variable (x_2) should be inverted and the final result should not be inverted.
  • Set refinement parameter to True to accelerate computation while breaking the lexicographical order of truth tables. See "Building a Better Boolean Matcher and Symmetry Detector" for details.

Build

Compile the shared library libnpn.dll and libnpn.so via CMake on Windows and Linux environment, place them in the \npn folder, then

python setup.py sdist

To upload to PyPI, run

twine upload .\dist\npn-X.X.tar.gz

Test

pip install pytest  # if you haven't install it
python -m pytest

References

  1. Chai, D., and A. Kuehlmann. “Building a Better Boolean Matcher and Symmetry Detector.” In Proceedings of the Design Automation & Test in Europe Conference, 1:1–6, 2006. https://doi.org/10.1109/DATE.2006.243959.
  2. Debnath, D., and T. Sasao. “Efficient Computation of Canonical Form for Boolean Matching in Large Libraries.” In ASP-DAC 2004: Asia and South Pacific Design Automation Conference 2004 (IEEE Cat. No.04EX753), 591–96, 2004. https://doi.org/10.1109/ASPDAC.2004.1337660.
  3. Hinsberger, U., and R. Kolla. “Boolean Matching for Large Libraries.” In Proceedings 1998 Design and Automation Conference. 35th DAC. (Cat. No.98CH36175), 206–11, 1998. https://doi.org/10.1145/277044.277100.

npn's People

Contributors

snowkylin avatar

Watchers

 avatar  avatar

Forkers

gmh5225

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.