Network implementations

All network implementations are located in mockturtle/networks/:

Headers

  • AIG network: mockturtle/networks/aig.hpp

  • MIG network: mockturtle/networks/mig.hpp

  • XAG network: mockturtle/networks/xag.hpp

  • XMG network: mockturtle/networks/xmg.hpp

  • k-LUT network: mockturtle/networks/klut.hpp

  • COVER network: mockturtle/networks/cover.hpp

  • abstract XAG network: mockturtle/networks/abstract_xag.hpp

  • MUXIG network: mockturtle/networks/muxig.hpp

Interface method

AIG

MIG

XAG

XMG

k-LUT

COVER

abstract XAG

MUXIG

clone

I/O and constants

get_constant

create_pi

create_po

create_ro (**)

create_ri (**)

is_constant

is_pi

is_ci

is_ro (**)

constant_value

Create unary functions

create_buf

create_not

Create binary functions

create_and

create_nand

create_or

create_nor

create_lt

create_le

create_gt

create_ge

create_xor

create_xnor

Create ternary functions

create_maj

create_ite

create_xor3

Create nary functions

create_nary_and

create_nary_or

create_nary_xor

Create arbitrary functions

create_node

clone_node

Restructuring

substitute_node

substitute_nodes

replace_in_node

replace_in_outputs

take_out_node

is_dead

Structural properties

is_combinational

size

num_pis

num_pos

num_cis

num_cos

num_gates

num_registers (**)

fanin_size

fanout_size

incr_fanout_size

decr_fanout_size

depth (*)

level (*)

is_and

is_or

is_xor

is_maj

is_ite

is_xor3

is_nary_and

is_nary_or

is_nary_xor

is_function

Functional properties

node_function

Nodes and signals

get_node

make_signal

is_complemented

node_to_index

index_to_node

pi_at

po_at

ci_at

co_at

ro_at (**)

ri_at (**)

pi_index

po_index

ci_index

co_index

ro_index (**)

ri_index (**)

ro_to_ri (**)

ri_to_ro (**)

Node and signal iterators

foreach_node

foreach_gate

foreach_pi

foreach_po

foreach_ci

foreach_co

foreach_ro (**)

foreach_ri (**)

foreach_register (**)

foreach_fanin

foreach_fanout (*)

Simulate values

compute

Custom node values

clear_values

value

set_value

incr_value

decr_value

Visited flags

clear_visited

visited

set_visited

trav_id

incr_trav_id

General methods

events

Note

(*) For efficiency reasons, depth, level and foreach_fanout are not implemented in the core of most networks. These interfaces can be extended to a network by wrapping it with appropriate Views (in these cases, depth_view or fanout_view).

Note

(**) Sequential interfaces are not provided by default, but they can be extended to networks by wrapping with sequential (See Sequential networks).

Supplementary network types

Block Network

Header: mockturtle/networks/block.hpp

This header file defines a data structure of type block_network, which is primarily designed to represent both single-output and multi-output nodes. This data structure provides additional methods to create multi-output nodes and access the individual pins.

Additional interfaces provided by this network type include:

inline bool mockturtle::block_network::is_multioutput(node const &n) const
inline signal mockturtle::block_network::create_ha(signal a, signal b)
inline signal mockturtle::block_network::create_hai(signal a, signal b)
inline signal mockturtle::block_network::create_fa(signal a, signal b, signal c)
inline signal mockturtle::block_network::create_fai(signal a, signal b, signal c)
inline uint32_t mockturtle::block_network::num_outputs(node const &n) const
inline uint32_t mockturtle::block_network::incr_fanout_size_pin(node const &n, uint32_t pin_index) const
inline uint32_t mockturtle::block_network::decr_fanout_size_pin(node const &n, uint32_t pin_index) const
inline uint32_t mockturtle::block_network::fanout_size_pin(node const &n, uint32_t pin_index) const
inline kitty::dynamic_truth_table mockturtle::block_network::node_function_pin(const node &n, uint32_t pin_index) const
inline uint32_t mockturtle::block_network::get_output_pin(signal const &f) const
inline signal mockturtle::block_network::next_output_pin(signal const &f) const

Cover Network

Header: mockturtle/networks/cover.hpp

This header file defines a data structure of type cover_network, which is primarily designed for reading in a .blif file and then converting it into other network types (COVER to graph conversion). This data structure provides an additional node creation function, create_cover_node.

inline signal mockturtle::cover_network::create_cover_node(std::vector<signal> const &children, cover_type cover)

Creates node with arbitrary cover (SOP or POS).

cover_type is std::pair<std::vector<kitty::cube>, bool>, where the first element defines the cubes (clauses) of the onset (offset) and the second element selects between the onset mode (true) or offset mode (false).

Parameters:
  • children – Fanin signals

  • cover – Cover for node function

Crossed Network

Header: mockturtle/networks/crossed.hpp

The network type crossed_klut_network is an extension to k-LUT network which supports representation of crossing cells. A crossing cell has exactly two inputs and two (ordered) outputs. Additional interfaces provided by this network type include:

inline std::pair<signal, signal> mockturtle::crossed_klut_network::create_crossing(signal const &in1, signal const &in2)

Create a crossing cell.

Returns:

A pair (out1, out2) of two signals to be used as fanouts of the crossing, where in1 connects to out1 and in2 connects to out2.

inline node mockturtle::crossed_klut_network::insert_crossing(signal const &in1, signal const &in2, node const &out1, node const &out2)

Insert a crossing cell on two wires.

After this operation, the network will not be in a topological order.

Parameters:
  • in1 – A fanin signal of the node out1

  • in2 – A fanin signal of the node out2

Returns:

The created crossing cell. No more fanouts should be added to it.

inline bool mockturtle::crossed_klut_network::is_crossing(node const &n) const

Whether a node is a crossing cell.

Parameters:

n – The node to be checked

Returns:

Whether this node is a crossing cell

inline bool mockturtle::crossed_klut_network::is_second(signal const &f) const

Whether a crossing’s fanout signal is the second one.

Parameters:

f – A signal pointing to a crossing cell

Returns:

Whether this fanout connects to the second fanin (return 1) or the first fanin (return 0)

inline signal mockturtle::crossed_klut_network::make_second(signal const &f) const

Take a crossing’s first fanout signal and make it the second.

Parameters:

f – A signal pointing to a crossing cell, referring to the fanout connecting to the first fanin

Returns:

The signal referring to the fanout connecting to the second fanin

inline signal mockturtle::crossed_klut_network::ignore_crossings(signal const &f) const

Get the real fanin signal ignoring all crossings in between.

Parameters:

f – A signal pointing to a crossing

Returns:

The corresponding signal pointing to a non-crossing node

template<typename Fn>
inline void mockturtle::crossed_klut_network::foreach_fanin_ignore_crossings(node const &n, Fn &&fn) const

Iterate through the real fanins of a node, ignoring all crossings in between.

Note that the foreach_gate function of this network iterates through all logic gates as well as crossings.

Buffered Networks

Header: mockturtle/networks/buffered.hpp

This header file implements extensions to several network types to buffered_xxx_network, currently including: buffered_aig_network, buffered_mig_network, and buffered_crossed_klut_network. Buffered networks support explicit representation of one-input, one-output buffer cells. They serve as interfacing data structure mainly for algorithms related to AQFP buffer insertion and verification. Buffered networks provide or override the following functions:

  • create_buf: Creates a buffer cell

  • invert: Turns a buffer cell into an inverter or vice versa.

  • is_buf: Checks if a node is a buffer, splitter (buffer capable of having multiple fanouts), or inverter cell.

  • is_not: Checks if a buffer cell has negated input (i.e., is an inverter).

  • foreach_gate iterates through logic gates (and crossings, in the case of buffered_crossed_klut_network) and neglects buffer, splitter, or inverter cells.

  • Disables restructuring functions, such as substitute_node.

Specific for buffered_crossed_klut_network:

inline node mockturtle::buffered_crossed_klut_network::merge_into_crossing(node const &buf1, node const &buf2)

Merges two buffer nodes into a crossing cell.

After this operation, the network will not be in a topological order. Additionally, buf1 and buf2 will be dangling.

Parameters:
  • buf1 – First buffer node.

  • buf2 – Second buffer node.

Returns:

The created crossing cell.

Simulation of buffered networks

template<uint32_t NumPIs, class Ntk>
std::vector<kitty::static_truth_table<NumPIs>> mockturtle::simulate_buffered(Ntk const &ntk)

Simulates a buffered network.

The implementation is only slightly different from simulate by replacing foreach_gate with foreach_node and checking fanin_size because buffers are not counted as gates but still need to be simulated.

Generic Network

Header: mockturtle/networks/generic.hpp

This header file defines a data structure of type generic_network, which is primarily designed to represent different node types, such as white and black boxes, registers, input or output box pins. This data represent all the elements as nodes, including POs.

Additional interfaces provided by this network type include:

inline bool mockturtle::generic_network::is_node(node const &n) const
inline bool mockturtle::generic_network::is_register(node const &n) const
inline bool mockturtle::generic_network::is_box_input(node const &n) const
inline bool mockturtle::generic_network::is_box_output(node const &n) const
inline signal mockturtle::generic_network::create_box_input(signal a)
inline signal mockturtle::generic_network::create_box_output(signal a)
inline signal mockturtle::generic_network::create_register(signal a, register_t const &l_info = {})
template<typename Fn>
inline void mockturtle::generic_network::foreach_register(Fn &&fn) const
inline void mockturtle::generic_network::clear_values2() const
inline uint32_t mockturtle::generic_network::value2(node const &n) const
inline void mockturtle::generic_network::set_value2(node const &n, uint32_t v) const