Tools for working with Boolean circuits as graphs.
Project description
CircuitGraph
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. CircuitGraph is still in the pre-release stage, so for now installation must be done by cloning this repository as such:
cd <install location>
git clone https://github.com/circuitgraph/circuitgraph.git
pip install -r requirements.txt
pip install .
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 perform simulation you can install Verilator which is interfaced with using PyVerilator. Note that PyVerilator is a little finicky, and we are looking into better solutions for simulation.
If you would like to perform synthesis you can install either Cadence Genus or Yosys. If you're going to use Genus, you must provide the path to a synthesis library to use by setting the CIRCUITGRAPH_GENUS_LIBRARY_PATH
variable.
Developing
CI Testing and coverage is setup using Travis CI and 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.
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
Citation
Please check back soon.
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 Distribution
Hashes for circuitgraph-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f47a9d82489b8440002766738ad59524b252523f5f7cc460e0b1ba339471a5d9 |
|
MD5 | cef1b3e0568ec15d378f9d3f6b85973b |
|
BLAKE2b-256 | 4a0e1d1067bbb609e22f1112d518a317ea349a1215284550930701a29105ddad |