Git Product home page Git Product logo

CircuitGraph

Python package codecov Code style: black pre-commit

CircuitGraph is a library for working with hardware designs as graphs. CircuitGraph provides an interface to do this built on NetworkX, along with integrations with other useful tools such as sat solvers and the Yosys synthesis tool, and input/output to verilog.

Overview

The Circuit class is at the core of the library and it is essentially a wrapper around a NetworkX graph object. This graph is accessable through the graph member variable of Circuit and can be used as an entrypoint to the robust NetworkX API.

Here's a simple example of reading in a verilog file, adding a node to the graph, and writing back to a new file.

import circuitgraph as cg

c = cg.from_file('/path/to/circuit.v')
# Add an AND gate to the circuit that takes as input nets o0, o1, o2, o3
c.add('g', 'and', fanin=[f'o{i}' for i in range(4)])
cg.to_file(c, '/path/to/output/circuit.v')

The documentation can be found here.

Installation

CircuitGraph requires Python3.7 or greater The easiest way to install is via PyPi:

pip install circuitgraph

To install from the release, download and:

pip install circuitgraph-<release>.tar.gz

Finally, to install in-place with the source, use:

cd <install location>
git clone https://github.com/circuitgraph/circuitgraph.git
cd circuitgraph
pip install -r requirements.txt
pip install -e .

Optional Packages

In addition to the packages enumerated in requirements.txt, there are a few tools you can install to enable additional functionality.

If you would like to use the satisfiability functionality, install PySAT.

Open source synthesis can be perofmred by installing Yosys and adding it to your path. Alternatively, Genus or DesignCompiler can be used by providing the path to a generic library to use by setting the CIRCUITGRAPH_GENUS_LIBRARY_PATH and CIRCUITGRAPH_DC_LIBRARY_PATH environment variables.

Contributing

If you have ideas on how to improve this library we'd love to hear your suggestions. Please open an issue. If you want to develop the improvement yourself, please consider the information below.

Coverage is computed using Codecov. If you would like to generate coverage information locally, install coverage and codecov.

pip install coverage codecov
make coverage

Documentation is built using pdoc3.

pip install pdoc3
make doc

Tests are run using the builtin unittest framework. Some basic linting is performed using flake8.

pip instsall flake8
make test

Code should be formatted using black. Pre-commit is used to automatically run black on commit.

pip install black pre-commit
pre-commit install

Pre-commit also runs a few other hooks, including a docstring formatter and linter. Docs follow the numpy documentation convention.

Citation

If you use this software for your research, we ask you cite this publication: https://joss.theoj.org/papers/10.21105/joss.02646

@article{sweeney2020circuitgraph,
  title={CircuitGraph: A Python package for Boolean circuits},
  author={Sweeney, Joseph and Purdy, Ruben and Blanton, Ronald D and Pileggi, Lawrence},
  journal={Journal of Open Source Software},
  volume={5},
  number={56},
  pages={2646},
  year={2020}
}

Acknowledgements

Circuitgraph icon designed by ncasti.

circuitgraph's Projects

logiclocking icon logiclocking

Lock circuitgraphs using various logic locking techniques

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.