Utility functions

Manipulate windows with network data types

Header: mockturtle/utils/network_utils.hpp

template<typename Ntk, typename SubNtk>
void mockturtle::clone_subnetwork(Ntk const &ntk, std::vector<typename Ntk::node> const &inputs, std::vector<typename Ntk::signal> const &outputs, std::vector<typename Ntk::node> const &gates, SubNtk &subntk)

Constructs a (sub-)network from a window of another network.

The window is specified by three parameters: 1.) inputs are the common support of all window nodes, they do not overlap with gates (i.e., the intersection of inputs and gates is the empty set). 2.) gates are the nodes in the window, supported by the inputs (i.e., gates are in the transitive fanout of the inputs). 3.) outputs are signals (regular or complemented nodes) pointing to nodes in gates or inputs. Not all fanouts of an output node are already part of the window.

Required network functions for the source Ntk:

  • foreach_fanin

  • get_node

  • get_constant

  • is_complemented

Required network functions for the cloned SubNtk:

  • create_pi

  • create_po

  • create_not

  • get_constant

Parameters:
  • ntk – A logic network

  • subntk – An empty network to be constructed

template<typename Ntk, typename SubNtk, typename BeginIter, typename EndIter, typename Fn>
void mockturtle::insert_ntk(Ntk &ntk, BeginIter begin, EndIter end, SubNtk const &subntk, Fn &&fn)

Inserts a network into another network.

Required network functions for the host Ntk:

  • get_constant

  • create_not

Required network functions for the subnetwork SubNtk:

  • num_pis

  • foreach_pi

  • foreach_po

  • foreach_gate

  • foreach_fanin

  • get_node

  • is_complemented

Parameters:
  • ntk – The host logic network

  • begin – Begin iterator of signal inputs in the host network

  • end – End iterator of signal inputs in the host network

  • subntk – The sub-network

  • fn – Callback function

Restore network and PI/PO names

Header: mockturtle/utils/name_utils.hpp

template<typename NtkSrc, typename NtkDest>
void mockturtle::restore_network_name(const NtkSrc &ntk_src, NtkDest &ntk_dest) noexcept

Restores the network name that might have been given to network’s former incarnation.

Parameters:
  • ntk_src – The source logic network, which potentially has a name

  • ntk_dest – The destination logic network, whose name is to be restored

template<typename NtkSrc, typename NtkDest>
void mockturtle::restore_names(const NtkSrc &ntk_src, NtkDest &ntk_dest, node_map<signal<NtkDest>, NtkSrc> &old2new) noexcept

Restores all names that might have been given to a network’s former incarnation.

Required network functions for the NtkSrc:

  • foreach_node

  • foreach_fanin

  • foreach_po

  • get_node

Parameters:
  • ntk_src – The source logic network, which potentially has named signals

  • ntk_dest – The destination logic network, whose names are to be restored

  • old2new – Mapping of nodes from ntk_src to signals of ntk_dest

template<typename NtkSrc, typename NtkDest>
void mockturtle::restore_pio_names_by_order(const NtkSrc &ntk_src, NtkDest &ntk_dest)

Restore PI and PO names, matching by order.

Required network functions for NtkSrc:

  • foreach_pi

  • foreach_po

  • num_pis

  • num_pos

  • has_name

  • get_name

  • make_signal

  • has_output_name

  • get_output_name

Required network functions for NtkDest:

  • foreach_pi

  • num_pis

  • num_pos

  • set_name

  • make_signal

  • set_output_name

Parameters:
  • ntk_src – The source logic network, which potentially has named signals

  • ntk_dest – The destination logic network, whose names are to be restored