Extract linear subcircuit

Header: mockturtle/algorithms/extract_linear.hpp

These functions can extract the linear part of an XAG. All AND gates will be removed. The two fan-ins of each AND gate will become primary outputs of the new circuit and the fan-out of the AND gate will be a primary inputs.

xag_network xag = ...

// signals is a vector of three tuples with PI/PO for each AND gate
const auto [linxag, signals] = extract_linear_circuit( xag );

// linxag has only XOR gates and inverters possibly only at the primary
// outputs;
// xag2 will be equivalent to xag
const auto xag2 = merge_linear_circuit( linxag, signals.size() );
inline std::pair<xag_network, std::vector<std::array<xag_network::signal, 3>>> mockturtle::extract_linear_circuit(xag_network const &xag)

Extract linear circuit from XAG.

Creates a new XAG that only contains the XOR gates of the original XAG. For each AND gate, the new XAG will contain one additional PI (for the AND output) and two additional POs (for the AND inputs) in the same order as the AND gates are traversed in topological order.

Besides the new XAG, this function returns a vector of the size of all original AND gates with pointers to the signals referring to the AND’s fanin and fanout (in that order).

inline xag_network mockturtle::merge_linear_circuit(xag_network const &xag, uint32_t num_and_gates)

Re-insert AND gates in linear circuit.

Given an extracted linear circuit from extract_linear_circuit and the number of original AND gates, this function re-inserts the AND gates, assuming that they are represented as PI and PO pairs at the end of the original PIs and POs.