Skip to content

Commit

Permalink
Improvements to the mapping framework (#629)
Browse files Browse the repository at this point in the history
* Add a warning when multi-output gates have better delay than single-output gates

* Adding cell libraries in Mockturtle

* Adding cell library bindings to mapper experiment

* Adding verilog writer for mapped networks (cell_view) with multi-output cell compatibility, CEC for mapped networks with multi-output blocks, and code improvements

* Adding filter to use only gates with minimum size for mapping

* Adding names_view in emap experiment

* Moving emap from experimental to algorithms, verbose option in write_verilog

* Adding hybrid matching

* Changing the default data stracture of emap to be the block_network

* Cleaning emap code

* Fixes in write_verilog, adding tests for write_verilog

* Fixing warning messages in tech_library

* Correcting emap tests

* Adding test cases, small fixes

* Fix required time decrease with multi-output cells in emap
  • Loading branch information
aletempiac authored Feb 15, 2024
1 parent b9a9e95 commit 174d175
Show file tree
Hide file tree
Showing 23 changed files with 2,766 additions and 316 deletions.
36 changes: 20 additions & 16 deletions docs/algorithms/mapper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,24 @@ To increase this limit, change `max_cut_num` in `fast_network_cuts`.
Extended technology mapping
---------------------------

**Header:** ``mockturtle/algorithms/experimental/emap.hpp``
**Header:** ``mockturtle/algorithms/emap.hpp``

The command `emap` stands for extended mapper. The current version
supports up to 2-output gates, such as full adders and half adders,
and it provides a 2x speedup in mapping time compared to command `map`
The command `emap` stands for extended mapper. It supports large
library cells, of more than 6 inputs, and can perform matching using 3
different methods: Boolean, pattern, or hybrid. The current version
can map to 2-output gates, such as full adders and half adders,
and provides a 2x speedup in mapping time compared to command `map`
for similar or better quality. Similarly, to `map`, the implementation
is independent of the underlying graph representation. Moreover, `emap`
supports "don't touch" white boxes.
is independent of the underlying graph representation.
Additionally, `emap` supports "don't touch" white boxes (gates).

Command `emap` can return the mapped network in two formats.
Command `emap` returns a `cell_view<block_network>` that supports
multi-output cells. Command `emap_klut` returns a `binding_view<klut_network>`
similarly as command `map`.

The following example shows how to perform delay-oriented technology mapping
from an and-inverter graph using the default settings:
from an and-inverter graph using large cells up to 9 inputs:

.. code-block:: c++

Expand All @@ -163,13 +170,10 @@ from an and-inverter graph using the default settings:
std::vector<gate> gates;
std::ifstream in( ... );
lorina::read_genlib( in, genlib_reader( gates ) )
tech_library tech_lib( gates );
tech_library<9> tech_lib( gates );
/* perform technology mapping */
binding_view<klut_network> res = emap( aig, tech_lib );
The mapped network is returned as a `binding_view` that extends a k-LUT network.
Each k-LUT abstracts a cell and the view contains the binding information.
cell_view<block_network> res = emap<9>( aig, tech_lib );
The next example performs area-oriented graph mapping using multi-output cells:

Expand All @@ -187,10 +191,10 @@ The next example performs area-oriented graph mapping using multi-output cells:
emap_params ps;
ps.area_oriented_mapping = true;
ps.map_multioutput = true;
cell_view<block_network> res = emap_block( aig, tech_lib, ps );
cell_view<block_network> res = emap( aig, tech_lib, ps );
In this case, `emap_block` is used to return a `block_network`, which can respresent multi-output
cells as single nodes. Alternatively, also `emap` can be used but multi-output cells
In this case, `emap` is used to return a `block_network`, which can respresent multi-output
cells as single nodes. Alternatively, also `emap_klut` can be used but multi-output cells
would be reporesented by single-output nodes.

The maximum number of cuts stored for each node is limited to 32.
Expand All @@ -210,6 +214,6 @@ related tests.
**Algorithm**

.. doxygenfunction:: mockturtle::emap(Ntk const&, tech_library<NInputs, Configuration> const&, emap_params const&, emap_stats*)
.. doxygenfunction:: mockturtle::emap_block(Ntk const&, tech_library<NInputs, Configuration> const&, emap_params const&, emap_stats*)
.. doxygenfunction:: mockturtle::emap_klut(Ntk const&, tech_library<NInputs, Configuration> const&, emap_params const&, emap_stats*)
.. doxygenfunction:: mockturtle::emap_node_map(Ntk const&, tech_library<NInputs, Configuration> const&, emap_params const&, emap_stats*)
.. doxygenfunction:: mockturtle::emap_load_mapping(Ntk&)
242 changes: 242 additions & 0 deletions experiments/cell_libraries/asap7.genlib

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions experiments/cell_libraries/mcnc.genlib
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
GATE inv1 1 O=!a; PIN * INV 1 999 0.9 0.3 0.9 0.3
GATE inv2 2 O=!a; PIN * INV 2 999 1.0 0.1 1.0 0.1
GATE inv3 3 O=!a; PIN * INV 3 999 1.1 0.09 1.1 0.09
GATE inv4 4 O=!a; PIN * INV 4 999 1.2 0.07 1.2 0.07
GATE nand2 2 O=!(a*b); PIN * INV 1 999 1.0 0.2 1.0 0.2
GATE nand3 3 O=!(a*b*c); PIN * INV 1 999 1.1 0.3 1.1 0.3
GATE nand4 4 O=!(a*b*c*d); PIN * INV 1 999 1.4 0.4 1.4 0.4
GATE nor2 2 O=!(a+b); PIN * INV 1 999 1.4 0.5 1.4 0.5
GATE nor3 3 O=!(a+b+c); PIN * INV 1 999 2.4 0.7 2.4 0.7
GATE nor4 4 O=!(a+b+c+d); PIN * INV 1 999 3.8 1.0 3.8 1.0
GATE and2 3 O=a*b; PIN * NONINV 1 999 1.9 0.3 1.9 0.3
GATE or2 3 O=a+b; PIN * NONINV 1 999 2.4 0.3 2.4 0.3
GATE xor2a 5 O=a*!b+!a*b; PIN * UNKNOWN 2 999 1.9 0.5 1.9 0.5
#GATE xor2b 5 O=!(a*b+!a*!b); PIN * UNKNOWN 2 999 1.9 0.5 1.9 0.5
GATE xnor2a 5 O=a*b+!a*!b; PIN * UNKNOWN 2 999 2.1 0.5 2.1 0.5
#GATE xnor2b 5 O=!(!a*b+a*!b); PIN * UNKNOWN 2 999 2.1 0.5 2.1 0.5
GATE aoi21 3 O=!(a*b+c); PIN * INV 1 999 1.6 0.4 1.6 0.4
GATE aoi22 4 O=!(a*b+c*d); PIN * INV 1 999 2.0 0.4 2.0 0.4
GATE oai21 3 O=!((a+b)*c); PIN * INV 1 999 1.6 0.4 1.6 0.4
GATE oai22 4 O=!((a+b)*(c+d)); PIN * INV 1 999 2.0 0.4 2.0 0.4
GATE buffer 2 O=a; PIN * NONINV 1 999 1.0 0.0 1.0 0.0
GATE zero 0 O=CONST0;
GATE one 0 O=CONST1;
Loading

0 comments on commit 174d175

Please sign in to comment.