Crates.io | cnfgen-nand-opt |
lib.rs | cnfgen-nand-opt |
version | 0.1.1 |
source | src |
created_at | 2022-10-22 09:53:09.303437 |
updated_at | 2023-02-22 12:41:24.093819 |
description | Generate CNF for circuits |
homepage | |
repository | https://github.com/matszpk/cnfgen-nand-opt |
max_upload_size | |
id | 694318 |
size | 53,091 |
This program can generate CNF (Conjunctive Normal Form) to check possibility to build circuit built on NAND or NOR gates that returns given values from table.
WARNING: For some greater examples this program can generates CNF that can excess 1 gigabyte.
This program can read problem from file. If no given file then program read problem from standard input. The format of input is in TOML format:
gate = "Nand"
layers = 5
max_gates = 18
table = [ 6, 62, 11, 17, 26, 47, 53, 35 ]
The gate
field is gate type - it can be Nand
or Nor
. The layers
defines number
of layers (steps) of calcuation in circuit. The max_gates
defines maximal number of
gates. The table
is table of values that should be returned by circuit.
List of commands:
SAT_SOLVER
environment variable must be set to path to SAT solver executable.Sample output:
Number of gates for layers: [8, 11, 12, 6, 12, 6]
Layer 1:
(0, 0) 0
(0, 0) 0
(0, 2) 2
(0, 2) 2
....
Output:
(6, 1) 167
(6, 2) 168
(6, 0) 166
(5, 7) 159
It returns structure of circuit. In the layer listing are gate inputs where the first number in parentheses is number of layer (0 - index input) and number of output.