Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
f2dd737
#81: implemented multiDict and InheritanceMapping utilities collections
marco-biasion Sep 9, 2024
ff1492b
#81: implemented newGraph class and Dot parser/writer
marco-biasion Sep 9, 2024
df0014c
#81: nodes store names instead of other nodes. Implemented subgraph g…
marco-biasion Sep 9, 2024
b26cbc2
#81: updated OperationNode(s) to store names of items instead of obje…
marco-biasion Sep 12, 2024
087824c
#81: added utils.inheritance
marco-biasion Sep 12, 2024
110c794
#81: added JSONConverter for newGraph
marco-biasion Sep 12, 2024
4e8d0c1
#81: added flat() and pairwise() to utils.collections
marco-biasion Sep 12, 2024
e77f328
#81: Node cleanup. Node accept str and Node as items.
marco-biasion Sep 12, 2024
3dfda7a
#81: updated get_all_subclasses and leaves variant to return set
marco-biasion Sep 12, 2024
a7f047b
#81: removed Node.SYMBOL and delegated it to DotConverter
marco-biasion Sep 12, 2024
6447dbb
#81: simplified Node, items instead of _items, update AtMost/AtLeast …
marco-biasion Sep 12, 2024
337b6f3
#81: added utils.function. utils cleanup. removed unused files
marco-biasion Sep 13, 2024
4e68850
#81: moved converters to their own file. updated DotConverter
marco-biasion Sep 13, 2024
bc86a00
#81: minor fixes
marco-biasion Sep 13, 2024
2a6c6ec
#81: simplified Node hierarcy
marco-biasion Sep 13, 2024
87412ef
#81: implemented new SharedTemplate
marco-biasion Sep 13, 2024
24ffac2
#81: minor fix and update
marco-biasion Sep 13, 2024
e70bc48
81: added flat utils to utils.collections
marco-biasion Oct 10, 2024
8c6374b
#81: minor type change in utils.inheritance
marco-biasion Oct 11, 2024
1f8596d
#81: updated newConverter
marco-biasion Oct 11, 2024
54825f4
#81: updated newGraph Node hierarchy and added getters to Graph hiera…
marco-biasion Oct 11, 2024
1e90b9e
#81: updated newTemplate
marco-biasion Oct 11, 2024
c7b484f
#81: wip on new encoding layer
marco-biasion Dec 12, 2024
f191fb1
#81: Syncing WIP on non shared refactored template
Francesco-Cos Dec 20, 2024
c28a92b
#81: minor fixes to SOPTemplate
marco-biasion Feb 14, 2025
48b748b
#81: added guard in Graph creation (asserts no undefined node is pres…
marco-biasion Feb 14, 2025
d4e3e1c
#81: minor update in Node.__post_init__ logic
marco-biasion Feb 14, 2025
590bea7
#81: fixed unpack_toint(...)
marco-biasion Feb 14, 2025
bc8bced
#81: minor Makefile simplification
marco-biasion Feb 14, 2025
dd9a6f9
#81: changed Bool/IntInput nodes to Bool/IntVariable to reduce confusion
marco-biasion Feb 14, 2025
36d74fa
added Target/Min/Max nodes, made AtMost/AtLeast node Valued and updat…
marco-biasion Feb 21, 2025
4db59fb
#81: added prune_unused(...) and get_nodes_type(...) methods
marco-biasion Feb 25, 2025
170123c
#81: implemented method to replace nodes with constants (part of old …
marco-biasion Feb 28, 2025
a2034a1
#81: doc added
marco-biasion Feb 28, 2025
a4a8665
#81: updated get_nodes_types to accept multiple graphs
marco-biasion Mar 4, 2025
e6716ba
#81: added targets to SharedTemplate
marco-biasion Mar 4, 2025
f97965e
#81: added nodes groups and updated graph getters for nodes
marco-biasion Mar 4, 2025
eb7c435
#81: moved .with_prefix method from instance method to converters, mi…
marco-biasion Mar 4, 2025
d1954f0
#81: fixed how AtMost was used in Template
marco-biasion Mar 4, 2025
51a19b3
#81: minor change to .operations graph nodes getter
marco-biasion Mar 4, 2025
d164c52
#81: completed Z3FuncEncoder and Integer mapping
marco-biasion Mar 4, 2025
58a7b0a
#81: updated converter::get_nodes_type and added converter::get_nodes…
marco-biasion Mar 10, 2025
c39a80b
#81: removed Switch node and updated all usages with If nodes
marco-biasion Mar 10, 2025
bb120c6
#81: moved AtLeast/Most nodes to their own category
marco-biasion Mar 10, 2025
5141f65
#81: updated unpack_ToInt to generate independent sets of constants f…
marco-biasion Mar 10, 2025
1e6fa12
#81: finished implementation of z3 Encoding for both integer and bit …
marco-biasion Mar 10, 2025
d7048dd
#81: cleanup of new encoding system
marco-biasion Mar 10, 2025
4c38331
#81: more cleanup of new encoding system
marco-biasion Mar 11, 2025
86df11a
#81: implemented solving step for z3int/bitvec. removed encoding stan…
marco-biasion Mar 11, 2025
79134af
#81: minor fixes to .solving module
marco-biasion Mar 11, 2025
3782428
#81: moved new converters to their own submodule
marco-biasion Mar 11, 2025
9f4af59
#81: added docstring to Solver.solve method
marco-biasion Mar 12, 2025
70b2922
#81: minor fixes to solving::__init__
marco-biasion Mar 12, 2025
4bb50b5
#81: moved new templates to their own submodule
marco-biasion Mar 12, 2025
d4b679b
#81: moved new graphs (and nodes) to their own submodule
marco-biasion Mar 12, 2025
01c35e2
#81: merged main
marco-biasion Mar 12, 2025
e9388f2
#81: simplified Node hierarchy (removed Ord2, replaced with improved …
marco-biasion Mar 14, 2025
f32e2be
#81: minor improvements to graph/Graph.py
marco-biasion Mar 14, 2025
9b95ed9
#81: improved converters/graph_porters.py (previously file_converters…
marco-biasion Mar 14, 2025
8feab21
#81: minor fixes to VerilogExporter
marco-biasion Mar 18, 2025
d564fb0
#81: minor changes to {templating,solving}/__init__.py
marco-biasion Mar 18, 2025
06b51ce
#81: updated solving module to return status and model, instead of ju…
marco-biasion Mar 18, 2025
9c20b72
#81: simplified and refactored synthesis.py to only compute metrics i…
marco-biasion Mar 18, 2025
d79110f
#81: minor typing upgrade
marco-biasion Mar 18, 2025
fe17ebb
#81: improved return of MetricsEstimator.estimate_metrics()
marco-biasion Mar 18, 2025
53295e4
#81: added NotEquals node and Graph.__contains__
marco-biasion Mar 18, 2025
e9fe365
#81: added prevent_combination() to converting utils
marco-biasion Mar 18, 2025
2e0937d
#81: fixed Z3FuncEncoder only defining the functions, now it asserts …
marco-biasion Mar 18, 2025
f6fcb3c
#81: minor simplification of helper logic
marco-biasion Mar 21, 2025
a4ae108
#81: renamed GGraph -> IOGraph (InputOutputGraph) and TGraph -> PGrap…
marco-biasion Mar 21, 2025
a86768c
#81: minor module fix
marco-biasion Mar 21, 2025
cf7ff15
\#81: added converter from AnnotatedGraph to SGraph
marco-biasion Mar 21, 2025
b5d066f
#81: minor fixes and improvements
marco-biasion Mar 24, 2025
80315af
#81: fixed NonSharedTemplate
marco-biasion Mar 24, 2025
c3f228c
#81: fixed bug in templating:: where if a node was successor of more …
marco-biasion Mar 24, 2025
4fa1bc1
#81: improved naming for Multiplexer node parameters
marco-biasion Mar 25, 2025
0a5ebfc
#81: fixed SGraph.subgraph_inputs duplication bug
marco-biasion Mar 25, 2025
c05666c
#81: improved typing
marco-biasion Mar 25, 2025
14e48ed
#81: generalized Z3Encoder and added Z3Direct****Solver
marco-biasion Mar 25, 2025
5ae77fb
#81: improved errors for utility classes
marco-biasion Mar 25, 2025
fde4230
#81: fixed bugs in {Shared,NonShared}Template
marco-biasion Mar 25, 2025
669f94a
#81: minor improvements to {NonShared,Shared}Template
marco-biasion Mar 25, 2025
4c0250b
#81: added legacy to iograph logic
marco-biasion Mar 25, 2025
b204dc6
\#81: minor changes
marco-biasion Mar 25, 2025
c06f924
#81: finished upgrade of xplore.py with refactored logic
marco-biasion Mar 25, 2025
972e8cd
#81: removed unused files
marco-biasion Mar 25, 2025
4116b98
#81: fixed set_prefix() not prefixing constants
marco-biasion Mar 25, 2025
65bdc39
#81: passing specifications to .solve
marco-biasion Mar 25, 2025
0ddc346
#81: added temporary file to .gitignore and to make rm_temp
marco-biasion Mar 25, 2025
e1424ac
#81: initial refactoring of Paths component of Specifications
marco-biasion Mar 27, 2025
27b0bca
#81: minor utils improvements
marco-biasion Mar 31, 2025
a214b2b
#81: improved documentation
marco-biasion Mar 31, 2025
247a1b0
#81: requirements.txt cleanup of unused dependencies
marco-biasion Mar 31, 2025
12871f3
#81: improved documentation, type annotations, and minor graph copyin…
marco-biasion Mar 31, 2025
8f5ea70
#81: Graph.nodes return nodes in lexicographical topological order, i…
marco-biasion Mar 31, 2025
5343076
#81: generalized Solver.solve(...) allowing for any amount of graphs …
marco-biasion Mar 31, 2025
038eed5
#81: improvements to filesystem util
marco-biasion Mar 31, 2025
af352b9
#81: added makefile command to delete generated data
marco-biasion Mar 31, 2025
361f369
#81: minor refactoring of main.py, separated actions and localized im…
marco-biasion Mar 31, 2025
f9caea4
#81: minor cleanup
marco-biasion Apr 1, 2025
7c3c791
#81: improved documentation to graph.Node classes
marco-biasion Apr 1, 2025
27efb84
#81: renamed Node.items to .operands for better understanding of the …
marco-biasion Apr 1, 2025
ad05d64
#81: added constant output rewriting logic to NonSharedTemplate
marco-biasion Apr 2, 2025
71c00dc
#81: generalized NonSharedTemplate in preparation of new constant Fal…
marco-biasion Apr 2, 2025
bbade3b
#81: fixed string representation of some nodes
marco-biasion Apr 3, 2025
dd05f40
#81: minor improvements
marco-biasion Apr 3, 2025
d013cb6
#81: minor changes and format
marco-biasion Apr 3, 2025
fe18e5a
#81: minor improvements
marco-biasion Apr 4, 2025
ca87ee0
#81: added Constraint node, minor typing improvements
marco-biasion Apr 4, 2025
ae08a7a
#81: minor fix
marco-biasion Apr 4, 2025
f70f7c3
#81: updated Z3Solver and NonSharedTemplate with new Constraint node
marco-biasion Apr 4, 2025
1b8486e
#81: added IntConstant case to get_nodes_bitwidth(...)
marco-biasion May 2, 2025
a6afd77
#81: continued refactoring of paths component of Specifications
marco-biasion May 2, 2025
a7c5de8
#81: very minor xplore.py refactoring
marco-biasion May 2, 2025
0429149
#81: merged main
marco-biasion May 2, 2025
e72127c
#81: fixed get_nodes_bitwidth() IntConstant extrapolation being off b…
marco-biasion May 2, 2025
9bf0b88
#81: #81: fixed constants rewriting in NonSharedTemplate
marco-biasion May 2, 2025
933014b
#120: alternative constant 0 representation
marco-biasion May 6, 2025
d56a1ce
#125: made OperationNode a superclass and rooted all subclasses to ne…
marco-biasion May 12, 2025
8c9a1be
#125: implemented SolverNode(s) and GlobalNode(s), updated hierarchy.…
marco-biasion May 12, 2025
460a2f6
#125: updated entire node hierarchy and minor changes
marco-biasion May 13, 2025
4ad0353
#125: removed resolved TODO comments
marco-biasion May 13, 2025
c94c4db
#81: restructured utils:: contents
marco-biasion May 19, 2025
f508500
#81: added utils::utils::int_to_strbase to convert from an integer to…
marco-biasion May 19, 2025
c9036fa
#81: fixed multiple models sometimes overwriting eachothers
marco-biasion May 19, 2025
d2181e9
#81: added time_id to Specifications, represents the time (ns) at whi…
marco-biasion May 19, 2025
10d4108
#81: used new specs.time_id in models names, and added iteration number
marco-biasion May 19, 2025
0e8cded
#125: merged branch 81-overall-architecture
marco-biasion May 20, 2025
de21631
Merge pull request #135 from LP-RG/125-implement-solvernodes-min-max-…
marco-biasion May 20, 2025
9d4efc5
#136: upgrade solvers to understand globalnodes (#150)
marco-biasion Jul 1, 2025
224315c
#152: added Xor node
lollospadalaser Jul 7, 2025
ae9b8ac
#81: merged branch main
marco-biasion Jul 7, 2025
7afb0e6
151 implement graph constant evaluator (#159)
marco-biasion Jul 8, 2025
2c7ff5d
#162: fixed metrics (#163)
marco-biasion Jul 18, 2025
0dd1e53
#164: wrong treatment of node vs callnode in z3solver (#165)
marco-biasion Aug 5, 2025
fa06a18
#166: fixes of recent changes regarding 81 (#167)
marco-biasion Aug 6, 2025
7a29b28
#81: fixed bugs in crystallize
lollospadalaser Aug 7, 2025
54145db
#81: expanded support for Xor and Xnor
marco-biasion Aug 11, 2025
4a792b7
#81: renamed crystallize->crystallise, added xnor crystalliser, added…
marco-biasion Aug 11, 2025
ff2eb10
#81: improved crystallise documentation, fixed _nary_bool, reordered …
marco-biasion Aug 11, 2025
bc7c5a8
#81: minor improvement to Xor and Xnor Z3Solver encoding
marco-biasion Aug 11, 2025
349f7b8
#168: improve time recording (#169)
marco-biasion Aug 12, 2025
f0093d9
#81: exposed .now in Timer, to be able to arbitrarily get the time spent
marco-biasion Aug 12, 2025
ef8fddc
#81: small fix in crystallise
lollospadalaser Sep 17, 2025
5e421f1
#81: completely removed non-determinism from graph classes
marco-biasion Sep 22, 2025
bee1c86
Merge branch '81-overall-architecture' of github.com:LP-RG/subxpat in…
marco-biasion Sep 22, 2025
d3e1164
#81: minor doc improvements
marco-biasion Sep 22, 2025
0511536
#81: fixed issue with direct solvers not using the constraints
marco-biasion Sep 22, 2025
a2e5456
#81: fixed missing outid in product redundancy constraint
marco-biasion Sep 22, 2025
f1c56ef
#81: improved Timer.now() discoverability
marco-biasion Sep 22, 2025
f21f197
#81: added flag model_completion=True to model evaluation in Z3Solver
lollospadalaser Oct 2, 2025
cc393e2
172 refactor error evaluation step (#173)
lollospadalaser Oct 3, 2025
cc81f33
#81: added total time logging (main.py)
marco-biasion Oct 3, 2025
e445fbb
#81: fixed 0 bitwidth for constants zero in some cases
marco-biasion Oct 16, 2025
451496e
#177: added Multiplier Node
lollospadalaser Dec 4, 2025
a7a53df
#177: fixed typo
lollospadalaser Dec 4, 2025
946f576
#177: fixed typo
lollospadalaser Dec 4, 2025
72db8f8
#177: fixed typo
lollospadalaser Dec 4, 2025
d27055b
Merge pull request #179 from LP-RG/177-add-multiplier-node
lollospadalaser Dec 16, 2025
0af903c
#81: cherry-picked all common improvements from #140 (PR#181)
marco-biasion Jan 27, 2026
4098b35
#81: added Mul to crystallise
lollospadalaser Jan 27, 2026
bdb2c53
#81: fixed sad circuits (added most significant output in the circuit)
lollospadalaser Feb 3, 2026
d8a5078
#81: added integer division node and fixed Mul
lollospadalaser Feb 5, 2026
8ba518d
#81: fixed missing comma
lollospadalaser Feb 5, 2026
7e200c4
#81: fixed typo
lollospadalaser Feb 5, 2026
1935ad4
#81: major speedup of annotated graph creation (patched Z3Log)
marco-biasion Mar 26, 2026
0d64990
#170: improve data export approach (#191)
marco-biasion Apr 1, 2026
6aad56b
#81: removed chached load of annotated graph
lollospadalaser Apr 2, 2026
55f61d3
#112: implemented Qbf solver (#194)
marco-biasion Apr 10, 2026
6e0c0ec
#15: minor refactoring of naming system
marco-biasion Apr 14, 2026
6942479
#43: implemented manual subgraph extraction and fixed convexity check…
marco-biasion Apr 16, 2026
0933592
#81: added LeftShift and RightShift nodes
lollospadalaser Apr 16, 2026
3373443
#81: fixed subgraph extraction 6
lollospadalaser Apr 16, 2026
036ff5f
#81: added subgraph_dot in run_stats
lollospadalaser Apr 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
/*.sh

#> generated
/venv
/.venv
**/__pycache__
**/yosys_graph.log
**/yosys_log.txt
.history_sta
# input
/input/*
!/input/ver.bak
Expand Down
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

PY := python3
ENV_NAME := .venv
DELETION_DELAY ?= 10

# computed

Expand All @@ -18,7 +19,7 @@ help:

activate:
# warning: will not work (limitation of `make`), you need to run it manually
. $(ENV_NAME)/bin/activate
$(ACTIV_ENV)

py_init:
@echo "\n[[ creating python environment if absent ]]"
Expand All @@ -29,22 +30,25 @@ py_dep: py_init
$(IN_ENV) python3 -m pip install --upgrade pip
$(IN_ENV) pip install --upgrade -r requirements.txt

local_dep:
@echo "\n[[ generating local files ]]"
mkdir -p input/ver/ && cp -r input/ver.bak/* input/ver/
setup: py_init py_dep

setup: py_init py_dep local_dep
rm_data:
@echo "\n[[ deleting all final and intermediary data ]]\n[[ YOU HAVE $(DELETION_DELAY) SECONDS TO CANCEL THIS OPERATION ]]"
@sleep $(DELETION_DELAY)
rm -rf output/ test/

rm_cache:
@echo "\n[[ removing all pycache folders ]]"
find . -name __pycache__ -prune -print -exec rm -rf {} \;

rm_temp:
@echo "\n[[ removing generated temporary files ]]"
rm -f yosys_graph.log
rm -f yosys_graph.log .history_sta

rm_pyenv:
@echo "\n[[ removing the virtual python environment ]]"
rm -rf $(ENV_NAME)

clean: rm_pyenv rm_cache rm_temp
clean: rm_cache rm_temp

clean-all: rm_pyenv rm_data clean
100 changes: 56 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ To prepare the system for execution you will need to follow a few steps:
# individual commands
make py_init # create python environment
make py_dep # install/update requirements
make local_dep # create input folders and local files
```

2. Activate the python environment:
Expand All @@ -47,13 +46,15 @@ To prepare the system for execution you will need to follow a few steps:

- To remove temporary files and the virtual python environment:
```bash
# all together
make clean

# individually
make rm_cache # remove the pycache folders
make rm_temp # remove temporary files
make rm_pyenv # remove the virtual python environment
make rm_data # remove the output results

# all together
make clean # rm_cache, rm_temp
make clean-all # clean, rm_pyenv, rm_data
```

- To display the program help:
Expand All @@ -69,63 +70,74 @@ SubXPAT is used by running the following command:
python3 main.py exact-benchmark [options]
```

### Arguments

Here are all the parameters with their arguments and descriptions:
| **parameter** | **argument** | **default value** | **description** |
| :-------------------------------------------: | ------------------------------------ | ---------------------------------- | ---------------------------------------------------------------------- |
| `exact-benchmark` | Verilog file in `input/ver/` | | Circuit to approximate |
| `--current-benchmark` <br> `--curr` | Verilog file in `input/ver/` | the same as <br> `exact-benchmark` | Approximated circuit used to continue the execution |
| `--max-labeling` | | | Nodes are weighted using their maximum error, instead of minimum error |
| `--no-partial-labeling` | | | Weights are assigned to all nodes, not only the relevant ones |
| `--extraction-mode` <br> `--mode` | { 1, 2, 3, 4, 5, 55, 6, 11, 12 } | 55 | Subgraph extraction algorithm to use |
| `--input-max` <br> `--imax` | `int` > 0 | | Maximum allowed number of inputs to the subgraph |
| `--output-max` <br> `--omax` | `int` > 0 | | Maximum allowed number of outputs from the subgraph |
| `--max-sensitivity` | `int` > 0 | | Maximum partitioning sensitivity |
| `--min-subgraph-size` | `int` > 0 | | Minimum valid size for the subgraph |
| `--num-subgraphs` | `int` > 0 | 1 | The number of attempts for subgraph extraction |
| `--slash-to-kill` | | | Enable the slash pass for the first iteration |
| `--error-for-slash` | `int` > 0 | | The error to use for the slash pass |
| `--subxpat` | | | Run SubXPAT iteratively, instead of standard XPAT |
| `--constants` | { never, always } | always | Usage of constants |
| `--template` | { nonshared, shared } | nonshared | Template logic |
| `--max-lpp` <br> `--max-literals-per-product` | `int` > 0 | | The maximum number of literals per product |
| `--max-ppo` <br> `--max-products-per-output` | `int` > 0 | | The maximum number of products per output |
| `--max-pit` <br> `--products-in-total` | `int` > 0 | | The maximum number of products in total |
| `--wanted-models` | `int` > 0 | 1 | Wanted number of models to generate at each step |
| `--max-error` <br> `-e` | `int` > 0 | | The maximum allowable error |
| `--error-partitioning` <br> `--epar` | { asc, desc, smart_asc, smart_desc } | asc | The error partitioning algorithm to use |
| `--encoding` | { z3int, z3bvec, qbf } | z3bvec | The encoding to use in solving |
| `--cell-library` | | `config/gscl45nm.lib` | The cell library file to use in the metrics estimation |
| `--timeout` | `float` > 0 | 10800 (3h) | The maximum time each cell is given to run (in seconds) |
| `--parallel` | | | Run in parallel whenever possible |
| `--clean` | | | Reset the output folder before running |
| `--help` <br> `-h` | | | Show the help message and exit |

| **parameter** | **argument** | **default value** | **description** |
| :-------------------------------------------: | --------------------------------------- | ---------------------------------- | ---------------------------------------------------------------------- |
| `exact-benchmark` | `path` to Verilog file | | Circuit to approximate |
| `--current-benchmark` <br> `--curr` | `path` to Verilog file | the same as <br> `exact-benchmark` | Approximated circuit used to continue the execution |
| `--max-labeling` | | | Nodes are weighted using their maximum error, instead of minimum error |
| `--no-partial-labeling` | | | Weights are assigned to all nodes, not only the relevant ones |
| `--extraction-mode` <br> `--mode` | { 1, 2, 3, 4, 5, 55, 6, 11, 12, 42 } | 55 | Subgraph extraction algorithm to use |
| `--input-max` <br> `--imax` | `int` > 0 | | Maximum allowed number of inputs to the subgraph |
| `--output-max` <br> `--omax` | `int` > 0 | | Maximum allowed number of outputs from the subgraph |
| `--max-sensitivity` | `int` > 0 | | Maximum partitioning sensitivity |
| `--min-subgraph-size` | `int` > 0 | | Minimum valid size for the subgraph |
| `--num-subgraphs` | `int` > 0 | 1 | The number of attempts for subgraph extraction |
| `--slash-to-kill` | | | Enable the slash pass for the first iteration |
| `--error-for-slash` | `int` > 0 | | The error to use for the slash pass |
| `--subxpat` | | | Run SubXPAT iteratively, instead of standard XPAT |
| `--constants` | { never, always } | always | Usage of constants |
| `--constant-false` | { output, product } | output | Representation of false constants from the subgraph |
| `--template` | { nonshared, shared } | nonshared | Template logic |
| `--max-lpp` <br> `--max-literals-per-product` | `int` > 0 | | The maximum number of literals per product |
| `--max-ppo` <br> `--max-products-per-output` | `int` > 0 | | The maximum number of products per output |
| `--max-pit` <br> `--products-in-total` | `int` > 0 | | The maximum number of products in total |
| `--wanted-models` | `int` > 0 | 1 | Wanted number of models to generate at each step |
| `--encoding` | { z3int, z3bvec, z3dint, z3dbvec, qbf } | z3bvec | The encoding to use in solving |
| `--max-error` <br> `-e` | `int` > 0 | | The maximum allowable error |
| `--error-partitioning` <br> `--epar` | { asc, desc, smart_asc, smart_desc } | asc | The error partitioning algorithm to use |
| `--output` | `path` to folder | `output/` | The base directory for the output |
| `--cell-library` | `path` to lib file | `config/gscl45nm.lib` | The cell library file to use in the metrics estimation |
| `--archive` | | | If the generated files should be archived at the end of the execution |
| `--debug` | | 10800 (3h) | The maximum time each cell is given to run (in seconds) |
| `--timeout` | `float` > 0 | 10800 (3h) | The maximum time each cell is given to run (in seconds) |
| `--parallel` | | | Run in parallel whenever possible |
| `--help` <br> `-h` `-?` | | | Show the help message and exit |

### Results

Once a command is finished executing, you can find the outputs in the `output/{#ID}/` folder, where `#ID` is a unique id assigned to the run, printed at the beginning of the execution.

Inside the `output/{#ID}/` folder, the structure is as follow:
- `run_details.csv`: the file containing the run specifications, such as arguments and global timings
- `run_stats.csv`: the file containing details for every step of the execution
- `verilog/`: the folder containing all generated circuits in Verilog format

If the `--debug` flag is used, more folders will be available:
- `graphviz/`: the folder containing a visual representation of the selected subgraph of each iteration
- `scripts/`: the folder containing generated solver scripts
- `tmp/`: the folder containing other temporary or intermediate products

### Examples

To execute the framework with the XPAT algorithm in the standard configuration, run the following command:
```bash
python3 main.py adder_i8_o5 --max-lpp=8 --max-ppo=32 --max-error=16
python3 main.py benchmarks/v/adder_i8_o5.v --max-lpp=8 --max-ppo=32 --max-error=16
```

To execute the framework with SubXPAT iterations, bit-vector logic encoding, and the defaults, run the following command:
```bash
python3 main.py adder_i8_o5 --subxpat --encoding=z3bvec --max-lpp=8 --max-ppo=10 --imax=6 --omax=3 --max-error=16
python3 main.py benchmarks/v/adder_i8_o5.v --subxpat --encoding=z3bvec --max-lpp=8 --max-ppo=10 --imax=6 --omax=3 --max-error=16
```

To execute the framework with SubXPAT iterations, integer logic encoding, subgraph extraction mode 5 (all sub-outputs weight must be less than the error threshold), maximum labeling, ..., run the following command:
```bash
python3 main.py adder_i8_o5 --subxpat --encoding=z3int --extraction-mode=5 --max-labeling --max-lpp=8 --max-ppo=10 --max-error=16 --imax=2 --omax=8
python3 main.py benchmarks/v/adder_i8_o5.v --subxpat --encoding=z3int --extraction-mode=5 --max-labeling --max-lpp=8 --max-ppo=10 --max-error=16 --imax=2 --omax=8
```


Once a command is finished executing, you can find the outputs in the following directories:

`output/csv/` contains the log of execution and all information for each iteration.
`output/ver/` contains the Verilog descriptions of all the approximate circuits found.
`output/gv/` contains the information of all the subgraphs that have been selected, in a visual form.


## Known limitations

- On Apple devices running M# architecture, you will have problems with some packages. \
Expand Down
1 change: 1 addition & 0 deletions Z3Log_patched/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 4 additions & 0 deletions Z3Log_patched/argument.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# discarded:
# from Z3Log.argument import Arguments

raise RuntimeError('[DEPRECATED] talk with Marco if you need this')
1 change: 1 addition & 0 deletions Z3Log_patched/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions Z3Log_patched/config/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# not patched:
from Z3Log.config.config import *
7 changes: 7 additions & 0 deletions Z3Log_patched/config/path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# discarded:
# from Z3Log.config.path import INPUT_PATH
# from Z3Log.config.path import OUTPUT_PATH
# from Z3Log.config.path import TEST_PATH
# from Z3Log.config.path import LOG_PATH

raise RuntimeError('[DEPRECATED] talk with Marco if you need this')
64 changes: 64 additions & 0 deletions Z3Log_patched/graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from typing import Mapping

from .utils import get_pure_name

# patched:
from Z3Log.graph import Graph as _Graph

__all__ = ['Graph']


class Graph(_Graph):
def __init__(self, circuit_in_gv_path: str, is_clean: bool = False):
"""
takes in a circuit and creates a networkx graph out of it
:param benchmark_name: the input benchmark in gv format
:param is_clean: leave empty for now
"""

# reduced
self.__graph_name = get_pure_name(circuit_in_gv_path)
self.__graph_out_path = circuit_in_gv_path

self.__graph = self.import_graph()

self.__sorted_node_list = None
self.__is_clean = is_clean

if not self.is_clean:
self.clean_graph()
self.sort_graph()

self.remove_output_outgoing_edges()

self.__input_dict = self.sort_dict(self.extract_inputs())
self.__output_dict = self.sort_dict(self.extract_outputs())
self.__gate_dict = self.sort_dict(self.extract_gates())
self.__constant_dict = self.sort_dict(self.extract_constants())

self.__num_inputs = len(self.__input_dict)
self.__num_outputs = len(self.__output_dict)
self.__num_gates = len(self.__gate_dict)
self.__num_constants = len(self.__constant_dict)

@property
def in_path(self): raise RuntimeError('[DEPRECATED] talk with Marco if you need this')
@property
def verilog_in_path(self): raise RuntimeError('[DEPRECATED] talk with Marco if you need this')
@property
def dot_in_path(self): raise RuntimeError('[DEPRECATED] talk with Marco if you need this')

def sort_dict(self, mapping: Mapping) -> dict:
sorted_keys = sorted(mapping.keys())
return {k: mapping[k] for k in sorted_keys}

def __repr__(self):
return (
f'An object of class Graph\n'
f'{self.name = }\n'
# f'{self.in_path = }\n'
f'{self.out_path = }\n'
f'{self.num_inputs = }\n'
f'{self.num_outputs = }\n'
f'{self.num_gates = }\n'
)
4 changes: 4 additions & 0 deletions Z3Log_patched/result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# discarded:
# from Z3Log.result import Result

raise RuntimeError('[DEPRECATED] talk with Marco if you need this')
5 changes: 5 additions & 0 deletions Z3Log_patched/specs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# discarded:
# from Z3Log.specs import Specs


raise RuntimeError('[DEPRECATED] talk with Marco if you need this')
4 changes: 4 additions & 0 deletions Z3Log_patched/stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# discarded:
# from Z3Log.stats import Stats

raise RuntimeError('[DEPRECATED] talk with Marco if you need this')
Loading