Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
66b6eff
window_view.
hriener Sep 30, 2020
3643264
identify output signals using reference counting.
hriener Oct 1, 2020
3cdfe46
window_view.
hriener Oct 4, 2020
2ed9b32
window_view.
hriener Oct 4, 2020
56abcd6
`belongs_to`.
hriener Oct 4, 2020
0af8448
window_view.
hriener Oct 6, 2020
3c229cc
zero-cost TFI expansion.
hriener Oct 6, 2020
407269c
remove printing.
hriener Oct 6, 2020
edce0ff
bugfix expand0_towards_tfi.
hriener Oct 6, 2020
fac3233
documentation: expand0_towards_tfi.
hriener Oct 6, 2020
82fe448
expand_towards_tfi.
hriener Oct 6, 2020
533758a
cleanup test cases.
hriener Oct 7, 2020
560530e
better documentation for TFI expansion.
hriener Oct 7, 2020
655ee14
`levelized_expand_towards_tfo`,
hriener Oct 7, 2020
853eea3
refactory: use abstract colors_map.
hriener Oct 7, 2020
832851f
create_window.
hriener Oct 7, 2020
522bf7b
create_window.
hriener Oct 7, 2020
7883bc6
missing header.
hriener Oct 8, 2020
f47b454
color_view.
hriener Oct 14, 2020
e2049e4
integrate color_view.
hriener Oct 14, 2020
c99fdb1
window_utils: allows first allocate a new color.
hriener Oct 15, 2020
04f7dcb
window_utils: always first allocate a new color.
hriener Oct 15, 2020
0be74a1
tighter integration of color_view.
hriener Oct 15, 2020
695945d
traits.
hriener Oct 15, 2020
d2166c4
window_utils.
hriener Oct 15, 2020
74ff92b
window_utils.
hriener Oct 15, 2020
b4a5c7f
quality test.
hriener Oct 16, 2020
72a1d43
update tests.
hriener Oct 16, 2020
3ee7a0f
interface.
hriener Oct 19, 2020
28020ca
changelog.
hriener Oct 19, 2020
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
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ v0.2 (not yet released)
* Views:
- Assign names to signals and outputs (`names_view`) `#181 <https://github.com/lsils/mockturtle/pull/181>`_ `#184 <https://github.com/lsils/mockturtle/pull/184>`_
- Creates a CNF while creating a network (`cnf_view`) `#274 <https://github.com/lsils/mockturtle/pull/274>`_
- Revised window view (`window_view`) `#381 <https://github.com/lsils/mockturtle/pull/381>`_
- In-place and out-of-place color view (`color_view`, `out_of_place_color_view`) `#381 <https://github.com/lsils/mockturtle/pull/381>`_
* I/O:
- Write networks to DIMACS files for CNF (`write_dimacs`) `#146 <https://github.com/lsils/mockturtle/pull/146>`_
- Read BLIF files using *lorina* (`blif_reader`) `#167 <https://github.com/lsils/mockturtle/pull/167>`_
Expand Down Expand Up @@ -63,6 +65,8 @@ v0.2 (not yet released)
- Random logic networks for XAGs (`random_logic_generator`) `#366 <https://github.com/lsils/mockturtle/pull/366>`_
* Properties:
- Costs based on multiplicative complexity (`multiplicative_complexity` and `multiplicative_complexity_depth`) `#170 <https://github.com/lsils/mockturtle/pull/170>`_
* Utils:
- Computing windows and manipulating cuts (`create_window_impl`, `collect_nodes`, `collect_inputs`, `collect_outputs`, `expand0_towards_tfi`, `expand_towards_tfi`, `expand_towards_tfo`, `levelized_expand_towards_tfo`) `#381 <https://github.com/lsils/mockturtle/pull/381>`_

v0.1 (March 31, 2019)
---------------------
Expand Down
14 changes: 14 additions & 0 deletions docs/implementations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,17 @@ All network implementations are located in `mockturtle/networks/`:
+--------------------------------+-------------+-------------+-------------+-------------+-----------------+
| ``get_output_name`` | | | | | |
+--------------------------------+-------------+-------------+-------------+-------------+-----------------+
| | *Coloring methods* |
+--------------------------------+-------------+-------------+-------------+-------------+-----------------+
| ``new_color`` | | | | | |
+--------------------------------+-------------+-------------+-------------+-------------+-----------------+
| ``current_color`` | | | | | |
+--------------------------------+-------------+-------------+-------------+-------------+-----------------+
| ``color`` | | | | | |
+--------------------------------+-------------+-------------+-------------+-------------+-----------------+
| ``paint`` | | | | | |
+--------------------------------+-------------+-------------+-------------+-------------+-----------------+
| ``eval_color`` | | | | | |
+--------------------------------+-------------+-------------+-------------+-------------+-----------------+
| ``eval_fanins_color`` | | | | | |
+--------------------------------+-------------+-------------+-------------+-------------+-----------------+
11 changes: 11 additions & 0 deletions docs/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,14 @@ algorithm. Several views are implemented in mockturtle.

.. doxygenclass:: mockturtle::cnf_view
:members:

`color_view`: Manages traversal IDs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Header:** ``mockturtle/views/color_view.hpp``

.. doxygenclass:: mockturtle::color_view
:members:

.. doxygenclass:: mockturtle::out_of_place_color_view
:members:
9 changes: 7 additions & 2 deletions include/mockturtle/algorithms/dont_cares.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "../views/fanout_view.hpp"
#include "../views/topo_view.hpp"
#include "../views/window_view.hpp"
#include "../views/color_view.hpp"

#include <fmt/format.h>
#include <kitty/bit_operations.hpp>
Expand Down Expand Up @@ -74,8 +75,10 @@ kitty::dynamic_truth_table satisfiability_dont_cares( Ntk const& ntk, std::vecto

fanout_view<Ntk> fanout_ntk{ntk};
fanout_ntk.clear_visited();
color_view<Ntk> color_ntk{fanout_ntk};

window_view<fanout_view<Ntk>> window_ntk{fanout_ntk, extended_leaves, leaves, false};
std::vector<node<Ntk>> gates{collect_nodes( color_ntk, extended_leaves, leaves )};
window_view window_ntk{color_ntk, extended_leaves, leaves, gates};

default_simulator<kitty::dynamic_truth_table> sim( window_ntk.num_pis() );
const auto tts = simulate_nodes<kitty::dynamic_truth_table>( window_ntk, sim );
Expand Down Expand Up @@ -110,8 +113,10 @@ kitty::dynamic_truth_table observability_dont_cares( Ntk const& ntk, node<Ntk> c
{
fanout_view<Ntk> fanout_ntk{ntk};
fanout_ntk.clear_visited();
color_view<Ntk> color_ntk{fanout_ntk};

window_view<fanout_view<Ntk>> window_ntk{fanout_ntk, leaves, roots, false};
std::vector<node<Ntk>> gates{collect_nodes( color_ntk, leaves, roots )};
window_view window_ntk{color_ntk, leaves, roots, gates};

default_simulator<kitty::dynamic_truth_table> sim( window_ntk.num_pis() );
unordered_node_map<kitty::dynamic_truth_table, Ntk> node_to_value0( ntk );
Expand Down
64 changes: 58 additions & 6 deletions include/mockturtle/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,17 +916,69 @@ class network final
/*! \brief Sets the visited value of a node. */
void set_visited( node const& n, uint32_t v ) const;

/*! \brief An id that can be used as a visited flag.
*
* By using the traversal is, one can reuse multiple visited flags over
* several levels.
*/
/*! \brief Returns the current traversal id. */
uint32_t trav_id() const;

/*! \brief Increment the current traversal id. */
void incr_trav_id() const;
#pragma endregion

#pragma beginregion Color values
/* Color values offer a more recent and flexible mechanism to manage
and manipulate traversal ids. */

/*! \brief Returns a new color and increases the current color. */
uint32_t new_color() const;

/*! \brief Returns the current color. */
uint32_t current_color() const;

/*! \brief Resets all nodes colors to value `color`. */
void clear_colors( uint32_t color = 0 ) const;

/*! \brief Returns the color of a node. */
auto color( node const& n ) const;

/*! \brief Returns the color of a node. */
auto color( signal const& n ) const;

/*! \brief Assigns the current color to a node. */
void paint( node const& n ) const;

/*! \brief Assigns `color` to a node. */
void paint( node const& n, uint32_t color ) const;

/*! \brief Copies the color from `other` to `n`. */
void paint( node const& n, node const& other ) const;

/*! \brief Evaluates a predicate on the color of a node.
*
* The predicate `pred` is any callable that must have the signature
* ``bool(color_type)``, where `color_type` is the
* implementation-dependent type returned by the method `color`.
*/
template<typename Pred>
bool eval_color( node const& n, Pred&& pred ) const;

/*! \brief Evaluates a predicate on the colors of two nodes.
*
* The predicate `pred` is any callable that must have the signature
* ``bool(color_type,color_type)``, where `color_type` is the
* implementation-dependent type returned by the method `color`.
*/
template<typename Pred>
bool eval_color( node const& a, node const& b, Pred&& pred ) const;

/*! \brief Evaluates a predicate on the colors of the fanins of a node.
*
* The predicate `pred` is any callable that must have the signature
* ``bool(color_type)``, where `color_type` is the
* implementation-dependent type returned by the method `color`.
*/
template<typename Pred>
bool eval_fanins_color( node const& n, Pred&& pred ) const;
#pragma endregion

#pragma region Signal naming
/*! \brief Checks if a signal has a name. */
bool has_name( signal const& s ) const;
Expand All @@ -945,7 +997,7 @@ class network final

/*! \brief Returns the name of an output signal. */
std::string get_output_name( uint32_t index ) const;
#end endregion
#pragma endregion

#pragma region General methods
/*! \brief Returns network events object.
Expand Down
105 changes: 105 additions & 0 deletions include/mockturtle/traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,111 @@ template<class Ntk>
inline constexpr bool has_has_output_name_v = has_has_output_name<Ntk>::value;
#pragma endregion

#pragma region has_new_color
template<class Ntk, class = void>
struct has_new_color : std::false_type
{
};

template<class Ntk>
struct has_new_color<Ntk, std::void_t<decltype( std::declval<Ntk>().new_color() )>> : std::true_type
{
};

template<class Ntk>
inline constexpr bool has_new_color_v = has_new_color<Ntk>::value;
#pragma endregion

#pragma region has_current_color
template<class Ntk, class = void>
struct has_current_color : std::false_type
{
};

template<class Ntk>
struct has_current_color<Ntk, std::void_t<decltype( std::declval<Ntk>().current_color() )>> : std::true_type
{
};

template<class Ntk>
inline constexpr bool has_current_color_v = has_current_color<Ntk>::value;
#pragma endregion

#pragma region has_clear_colors
template<class Ntk, class = void>
struct has_clear_colors : std::false_type
{
};

template<class Ntk>
struct has_clear_colors<Ntk, std::void_t<decltype( std::declval<Ntk>().clear_colors( uint32_t() ) )>> : std::true_type
{
};

template<class Ntk>
inline constexpr bool has_clear_colors_v = has_clear_colors<Ntk>::value;
#pragma endregion

#pragma region has_color
template<class Ntk, class = void>
struct has_color : std::false_type
{
};

template<class Ntk>
struct has_color<Ntk, std::void_t<decltype( std::declval<Ntk>().color( std::declval<node<Ntk>>() ) )>> : std::true_type
{
};

template<class Ntk>
inline constexpr bool has_color_v = has_color<Ntk>::value;
#pragma endregion

#pragma region has_paint
template<class Ntk, class = void>
struct has_paint : std::false_type
{
};

template<class Ntk>
struct has_paint<Ntk, std::void_t<decltype( std::declval<Ntk>().paint( std::declval<node<Ntk>>() ) )>> : std::true_type
{
};

template<class Ntk>
inline constexpr bool has_paint_v = has_paint<Ntk>::value;
#pragma endregion

#pragma region has_eval_color
template<class Ntk, class = void>
struct has_eval_color : std::false_type
{
};

template<class Ntk>
struct has_eval_color<Ntk, std::void_t<decltype( std::declval<Ntk>().eval_color( std::declval<node<Ntk>>(), std::declval<void( uint32_t )>() ) )>> : std::true_type
{
};

template<class Ntk>
inline constexpr bool has_eval_color_v = has_eval_color<Ntk>::value;
#pragma endregion

#pragma region has_eval_fanins_color
template<class Ntk, class = void>
struct has_eval_fanins_color : std::false_type
{
};

template<class Ntk>
struct has_eval_fanins_color<Ntk, std::void_t<decltype( std::declval<Ntk>().eval_fanins_color( std::declval<node<Ntk>>(), std::declval<void( uint32_t )>() ) )>> : std::true_type
{
};

template<class Ntk>
inline constexpr bool has_eval_fanins_color_v = has_eval_fanins_color<Ntk>::value;
#pragma endregion

/*! \brief SFINAE based on iterator type (for compute functions).
*/
template<typename Iterator, typename T>
Expand Down
Loading