Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
818472a
Add configuration class for executions with a validated constructor.
zkwinkle May 7, 2025
07ac367
Improve validation of struct so that the fields end up in the most co…
zkwinkle May 7, 2025
b244f36
Add to write_tb flag to disable progress prints
zkwinkle May 7, 2025
cd6af03
Add CLI parsing for the configuration parameters. Also rename paramet…
zkwinkle May 7, 2025
58a42e7
Simplify run config and add generate subcommand.
zkwinkle May 8, 2025
27629fd
Add metrics to configuration class and add a default metric.
zkwinkle May 8, 2025
63e97fe
Document that the error threshold is measured in mean relative error …
zkwinkle May 8, 2025
16d09fc
Fix lint warnings for configuration
zkwinkle May 8, 2025
a26465b
Add hamming distance metric
zkwinkle May 8, 2025
1aca2fa
Add csv handling to the configuration class
zkwinkle May 8, 2025
3916076
Clean up circuiterror, make sure compute_error returns float
zkwinkle May 8, 2025
c1afa39
Separate simulation and simulation + compute error
zkwinkle May 8, 2025
1931444
Add in write_tb option to specify a vcd dump file. Add a method to ge…
zkwinkle May 8, 2025
ed59bc6
Make write_to_disk take in a full path instead of a weird filename th…
zkwinkle May 8, 2025
e4df79d
Make simulations execute from the testbench file dir
zkwinkle May 8, 2025
4367471
Allow specifying a different topmodule for a circuit
zkwinkle May 8, 2025
53511c5
Add the runner module and the AREA metric
zkwinkle May 8, 2025
b179907
Fix misc bugs
zkwinkle May 8, 2025
a3f664f
Add CLI check for circuit file existing
zkwinkle May 9, 2025
ccce88c
Improve --show-progress flag docs
zkwinkle May 9, 2025
96c522b
Rename variables in write_to_disk to be clearer and correct
zkwinkle May 9, 2025
aeb4875
Fix decision tree method bug
zkwinkle May 9, 2025
66e40e6
Fix bug with trying to test circuits with multiple outputs where tree…
zkwinkle May 10, 2025
958eab5
Improve decision tree _tree_2_equation to assign constant instead of …
zkwinkle May 10, 2025
d69f45a
Improve assign parser to also handle constants
zkwinkle May 11, 2025
777a618
Remove EXACT_TB and APPROX_TB, no longer needed
zkwinkle May 12, 2025
3939947
Add InOuts methods to runner
zkwinkle May 12, 2025
4bdddfb
Get rid of nonsensical decision tree resynthesis iteration
zkwinkle May 13, 2025
d03d756
Remove requirement for max_iters
zkwinkle May 13, 2025
9d862bd
Add validation option to config
zkwinkle May 13, 2025
ddeca7d
Add --validation flag to CLI
zkwinkle May 13, 2025
26eab15
Add validation option logic to runner and csv generation
zkwinkle May 14, 2025
4c93786
Add ProbPrun method to runner
zkwinkle May 15, 2025
54a20e3
Add significance method to runner
zkwinkle May 15, 2025
b63ae5c
Add --saif flag to CLI
zkwinkle May 15, 2025
66fcd58
Remove max_iters from csv and leave TODO about how csv format is arbi…
zkwinkle May 15, 2025
1b2890a
Add output significances to config object
zkwinkle May 15, 2025
bd94f3a
Add shuffle bag non-repeating distribution
zkwinkle May 16, 2025
de53e97
Fix shuffle bag implementation creation of rows
zkwinkle May 16, 2025
3d454cc
Add --distribution flag to generate subcommand
zkwinkle May 16, 2025
5771625
Add ccarving
zkwinkle May 16, 2025
8e0d4bd
Fix uniform generation of big values
zkwinkle May 16, 2025
ca2f169
Fix resynthesis variable substitution to add quotes around paths
zkwinkle May 18, 2025
9c20493
Add extra print info to runner
zkwinkle May 18, 2025
25b1d5d
Fix simulation when running from a different dir
zkwinkle May 18, 2025
7522303
Improve assign parsing and fix some minor stuff
zkwinkle May 19, 2025
f6973f3
Improve parsing of constants
zkwinkle May 19, 2025
73a6ca8
Adapt inout and probprun methods to work with batches
zkwinkle May 22, 2025
d01ce5f
Fix backtracking when resynthesizing
zkwinkle May 22, 2025
a54c178
Fix inout const methods to work more efficiently and fix pruning meth…
zkwinkle May 22, 2025
c2e3d34
Fix handling of returned circuit for probprun
zkwinkle May 22, 2025
ab99922
add prunes_per_iteration functionality to _run_significance
zkwinkle May 22, 2025
19eabb6
Finish fixing behaviour when resynthesizing and implementing backtrac…
zkwinkle May 22, 2025
e0d3d1d
Fix bug in inconst/outconst runner method
zkwinkle Jun 5, 2025
8ae13b4
Fix is_node_deletable function to take into account if the node is an…
zkwinkle Sep 14, 2025
5e2f1b3
Improve shuffle bag comment
zkwinkle Sep 14, 2025
a76ffd5
Delete unused import
zkwinkle Sep 14, 2025
e0b774e
Improve error message if outputs don't match
zkwinkle Sep 14, 2025
43c1672
Fix hamming distance bitwise xor to use object dtype so it works
zkwinkle Sep 14, 2025
690e9c7
Add -q flag to yosys commands to make output cleaner
zkwinkle Sep 14, 2025
ba93a64
Replace usage of List for list
zkwinkle Sep 14, 2025
99c550e
Improve CSV TODO in configuration.py
zkwinkle Sep 14, 2025
5265824
Update README and remove unused config and help files in favour of th…
zkwinkle Sep 14, 2025
a2d107b
Improve section name
zkwinkle Sep 14, 2025
1be7725
Embolden TODO
zkwinkle Sep 14, 2025
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
96 changes: 68 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ Roger Morales-Monge, student, Tecnológico de Costa Rica
3. [Cloning benchmarks](#cloning-benchmarks)
4. [Executing Demo](#executing-demo)
5. [Using AxLS](#using-axls)
1. [Parsing a netlist](#parsing-a-netlist)
2. [Deleting a node](#deleting-a-node)
3. [Simulation and Error Estimation](#simulation-and-error-estimation)
1. [CLI and simplified API usage](#cli-and-simplified-api-usage)
2. [Library usage](#library-usage)
1. [Parsing a netlist](#parsing-a-netlist)
2. [Deleting a node](#deleting-a-node)
3. [Simulation and Error Estimation](#simulation-and-error-estimation)
6. [ALS Algorithms](#als-algorithms)
1. [Pruning Algorithms](#pruning-algorithms)
- [InOuts](#inouts)
Expand Down Expand Up @@ -179,7 +181,44 @@ Mean Error Distance of approximate circuit with node _101_ deleted: 3.979

## Using AxLS

### Parsing a netlist
AxLS can be used in multiple ways, either through a CLI, it also accepts configuration parameters programmatically in order to execute the ALS methods in a simplified way, or the ALS methods can be used directly—library style.

### CLI and simplified API usage

To print the help, run:

```sh
python . -h
```

The CLI has 2 subcommands:

- `run` for executing an ALS method.
- `generate` in order to generate datasets to be used by the ALS execution for simulation or (in the case of ML methods) training.

Here's an example usage generating a dataset and executing an ALS method:

```sh
# Requires previously having cloned the ALS-benchmark-circuits repo (see cloning benchmarks section)
CIRCUIT=ALS-benchmark-circuits/KS_16b/KS_16b.v
# We generate a simulation dataset of 10k possible input/output pairs for the KS_16b circuit.
# Uses a uniform distribution of inputs by default.
python . generate $CIRCUIT test_dataset 10000
# Run the inconst method, calculating the MRED, circuit area and execution time metrics,
# accepting at max 20% error introduction, separating 10% of the dataset for validation,
# and pruning 10 nodes per iteration.
python . run inconst $CIRCUIT test_dataset mred time area --error 0.2 --validation 0.1 --prunes-per-iteration 10
```

The tool can also be used programmatically with an interface very similar to the CLI. By using the `run`
method from `run.py` directly, passing in an `ApproxSynthesisConfig` configuration object.

### Library usage

This section introduces some basic concepts to manipulate a netlist directly
which is a key part of employing the different ALS mehtods directly.

#### Parsing a netlist

1. First, import the `Circuit` class:

Expand Down Expand Up @@ -250,7 +289,7 @@ Using this node you can implement your own pruning algorithms. Because ElementTr



### Deleting a node
#### Deleting a node

1. The first example method we provide to delete nodes is quite simple, just delete a node based on its name. You can do it in two different ways:

Expand All @@ -269,7 +308,7 @@ our_circuit.delete("_101_")

When you set the attribute `delete` of a node to `yes`, it means that this node will be deleted the next time our circuit is saved in the filesystem. **The node will remain in the xml tree!** (just in case we need to revert a deletion).

### Simulation and Error Estimation
#### Simulation and Error Estimation

Simulation stage and error estimation are executed inside one method called `simulate_and_compute_error`. But first, in order to execute a simulation and calculate its error you need to provide:

Expand Down Expand Up @@ -336,7 +375,7 @@ This framework currently provides 2 kinds of ALS algorithms:
These algorithms suggest which nodes to delete based on circuit data or
heuristics.

TODO: Missing documentation on `ccarving` and `glpsignificance`
**TODO: Missing documentation on `ccarving` and `glpsignificance`**

#### InOuts

Expand Down Expand Up @@ -598,25 +637,26 @@ introducing around ~23% error.

Files and Folders description:

| Name | Description | Used |
| ------------------- | ------------------------------------------------------------ | ------ |
| prunning_algorithms | Folder containing pruning techniques implementations. | |
| `inouts.py` | Contains the implementation of `GetInputs` and `GetOutputs` example pruning methods. | |
| `probprun.py` | Contains the implementation of a pseudo Probabilistic Pruning method. `GetOneNode` is a python generator. It will retrieve one node to delete each time it is called. | |
| templates | Folder containing some libraries and scripts used for synthesis. | |
| `NanGate15nm.lib` | | |
| `NanGate15nm.v` | | |
| `synth.ys` | Script to synthesize a circuit using yosys. | |
| `__main__.py` | It executes the tool using the arguments from the command line. **Still in progress**. | **No** |
| `barcas.py` | Is the Pruning Implementation using the InOuts techniques. | **NO** |
| `circuit.py` | Object that represents a circuit as a XML tree. Receives a rtl and a library in order to build the circuit and be able to simulate it. | |
| `circuiterror.py` | Compares two outputs and computes different error metrics. | |
| `demo.py` | This file is a complete example of how the library should be used. | |
| `netlist.py` | This class parses, extracts and represents the circuit from rtl into an object understandable by python. | |
| `poisonoak.config` | This is going to be used along with `__main__.py` in order to execute poisonoak as an app, and not as a library. | **No** |
| `poisonoak.help` | Contains the menu and tool description of the poison oak app. | **No** |
| `synthesis.py` | Executes the synthesis script (in our case yosys) and clean the intermediate files generated. At the end returns the path of the netlist. | |
| `technology.py` | This class parses, extracts and represents the technology library file into an object understandable by python. | |
| `test.py` | This class implements some unit tests for the poison oak library. **Not implemented yet**. | **No** |
| `utils.py` | Some functions not related with any other class but useful. | |
| Name | Description |
| ------------------- | ------------------------------------------------------------ |
| `prunning_algorithms/` | Folder containing pruning techniques implementations. |
| `prunning_algorithms/inouts.py` | Contains the implementation of `GetInputs` and `GetOutputs` example pruning methods. |
| `prunning_algorithms/probprun.py` | Contains the implementation of a pseudo Probabilistic Pruning method. `GetOneNode` is a python generator. It will retrieve one node to delete each time it is called. |
| `ml_algorithms/` | Folder containing ML techniques implementations. |
| `ml_algorithms/decision_tree` | Contains the implementation of the Decision Tree technique through the `DecisionTreeCircuit` class. |
| `templates/` | Folder containing some libraries and scripts used for synthesis. |
| `templates/NanGate15nm.lib` | Technology file from Nangate. |
| `templates/NanGate15nm.v` | |
| `synth.ys` | Script to synthesize a circuit using yosys. |
| `__main__.py` | It executes the tool using the arguments from the command line. |
| `configuration.py` | Contains a configuration class for executing an ALS flow. Used by the CLI, but can be used by other scripts to do executions programatically without delving into the library's details. |
| `runner.py` | Contains a `run` method which accepts a configuration class in order to execute one of the ALS methods. |
| `circuit.py` | Object that represents a circuit as a XML tree. Receives a rtl and a library in order to build the circuit and be able to simulate it. |
| `circuiterror.py` | Compares two outputs and computes different error metrics. |
| `demo.py` | This file is a complete example of how the library should be used. |
| `netlist.py` | This class parses, extracts and represents the circuit from rtl into an object understandable by python. |
| `synthesis.py` | Executes the synthesis script (in our case yosys) and clean the intermediate files generated. At the end returns the path of the netlist. |
| `technology.py` | This class parses, extracts and represents the technology library file into an object understandable by python. |
| `utils.py` | Some functions not related with any other class but useful. |
| `test.py` | Currently unused file, meant to be used for unit tests. Out of date. |

Loading