NOTE: Will update this document soon.
We generate large synthetic combinatorial circuits using BONY. We did slightly modification to the code and hold the code in Ironprop-Stone/Bony.
- Generate the raw data by yourself
- Please follow the instruction from Ironprop-Stone/Bony.
- More details will be added later.
- Setup from the generated dataset
- The data directory structure is shown as follows.
${deepgate}/data_raw/random_circuits └── bench │ ├── 600.bench │ ├── 601.bench │ ├── ... ├── circuit_figs │ ├── 600_0.png │ ├── 601_0.png │ └── ... ├── labels │ ├── 600_0.txt │ ├── 601_0.txt │ └── ... ├── sub_circuits │ ├── 600_0.txt │ ├── 601_0.txt │ └── ...
- The
bench
contains the raw benchmark files generated by Bony. Thecircuit_figs
constains theC1
predictions vs.simulated probability
. Thelabels
constains thesimulated probability
labels for every circuit. Thesub_circuits
contains the extracted sub-circuits frombench
. - We only need the
bench
for the data generation.
cd data/random_circuits python prepare_random_circuits.py cd ../..
- The data directory structure is shown as follows.
After this step, you should end up with two files in the data\random_circuits
directory: random_circuits_graphs.npz
for the circuit graphs, and random_circuits_labels.npz
for the semi ground-truth probability labels, which will look like
${PoseAug}
├── data/random_circuits
│ ├── random_circuits_graphs.npz
│ ├── random_circuits_labels.npz
Here are 3 methods to generate the dataset for SAT problem.
The source of SAT problems all follows the generation algorithm described in NeuroSAT. Here, we have different way to pre-process the generated SAT problems:
- CNF format. The raw format from SAT generator.
- Conventional Circuit format (AND, OR, NOT). Three types of gates are considered here. The expansion from CNF to conventional circuits follows the procedure in CircuitSAT.
- AIG format (AND, NOT).
The details of AIG conversion is shown as follow:
The libraries we need:
- abc: System for sequential logic system and formal verification;
- AIGER: A format, library and sets of utilities for And-Inverter Graphs (AIGs);
- CNFtoAIG: A converter extracts an AIG in AIGER format from a CNF in DIMACS format;
- PyMiniSolvers: a Python API for the MiniSat and MiniCard constraint solvers.
- Step1: PyMiniSovlers to generate SAT and UNSAT pairs in dimacs format, which representing the propositional equations as CNF;
- Step2: CNFtoAIG to convert the CNF circuits into AIG circuits;
- Step3: ABC to optimize AIG and output optimized AIG, which is usually be done for synthesis. The optimization process follows the demo example: 1, (Balancing)
balance
; 2, (Synthesis)balance; rewrite -l; rewrite -lz; balance; rewrite -lz; balance
; 3, (Verification)ces
; 4, Save AIGwrite *.aig
. I assume the networks before and after synthesis are equivalent. - Step4: aigtoaig (utilities in AIGER) to convert binary AIGER format (*.aig) into ASCII AIGER (*.aag) format.
- Step5: Parse and construct graphs in PyGeometric format with generated AIG circuits.
- The generation of random CNF formula follows the procedure described in NeuroSAT. The outputs are a few pairs of SAT and UNSAT CNFs. In each pair, SAT and UNSAT CNFs only have difference on the final clauses.
- Convert the CNF formula to flat circuit in verilog format. The depth of circuit is only 3 (literal -> clause -> primary output).
- Use Yosys synthesis the flat circuits.
- Convert the post-synthesize circuit to bench format.
- Generate the random non-CNF circuits with specific parameters.
- Maintain the fan-in list and verify satisfiability of each gate in circuits.
- Extract the SAT and UNSAT gates as subcircuits, the primary inputs of the subcircuit are the original PIs in fan-in list, the only primary output is the corresponding SAT or UNSAT gate.