Safety Net: A Memory-Safe Netlist Data Structure via Reference Counting
Description
A Rust library for compiling and mutating netlists in a memory-safe way
You can read the docs for the netlist library here, but you may also want to check out the cool side-projects using safety-net:
- nl-compiler - Verilog frontend compilation into safety-net
- safety-pass - Build your own compiler pass pipelines that operate over safety-net netlists + provides a library of logic cells
- eqmap - uses equality saturation to superoptimize netlists
Getting Started
Below is a minimal example to get you started:
use ;
This code is included in the crate and you can run it with cargo run --example simple. Of course, you should generate the documentation with cargo doc and give it a review.
Exporting to MultiDiGraph with the petgraph Crate
The API provides the basic iterators needed to implement graph algorithms like static timing analysis:
iter()(The circuit nodes)connections()(The edges)node_dfs()(Depth-first search)
However, you may want to use another library that leverages a denser representation and already has all the classic algorithms implemented. This crate provides integration with petgraph. Here is a ripple-carry adder example which converts the netlist to a petgraph which is then converted to a dot graph:
cargo run --features graph --example pretty | dot -Tsvg > adder.svg
Then, open it up and take a look: