Data Structures

Abstract network

struct abstract_storage_node : public mockturtle::mixed_fanin_node<2>

data[0].h1: Fan-out size

data[0].h2: Application-specific value (weight)

data[1].h1: Function literal in truth table cache

data[2].h2: Visited flags

class caterpillar::abstract_network

General network in which each node is characterized by its input signals and an application-specific value.

Public Types

using base_type = abstract_network
using storage = std::shared_ptr<abstract_storage>
using node = uint64_t
using signal = uint64_t

Public Functions

abstract_network()
signal get_constant(bool value = false) const

returns a constant signal

signal create_pi(std::string const &name = std::string())

adds a primary input and returns it

void create_po(signal const &f, std::string const &name = std::string())

adds a primary output

bool is_constant(node const &n) const
bool is_pi(node const &n) const

verifies if a node is a primary input

bool constant_value(node const &n) const
signal create_buf(signal const &a)
signal create_not(signal const &a)

creates a NOT node and returns its outcoming signal

signal create_and(signal a, signal b)

creates an AND node and returns its outcoming signal

signal create_node(std::vector<signal> const &children, uint32_t weight = 1)

creates an abstract node and returns its outcoming signal

auto size() const

returns the number of nodes in the network

auto num_pis() const

returns the number of primary inputs

auto num_pos() const

returns the number of primary outputs

auto num_gates() const

returns the number of actual gates (not considering primary inputs and constant nodes)

uint32_t fanin_size(node const &n) const

returns the number of incoming signals of a node

uint32_t fanout_size(node const &n) const

returns the number of outcoming signals of a node

node get_node(signal const &f) const
signal make_signal(node const &n) const
uint32_t node_to_index(node const &n) const
node index_to_node(uint32_t index) const
template<typename Fn>
void foreach_node(Fn &&fn) const

executes a function for every node of the nework

template<typename Fn>
void foreach_pi(Fn &&fn) const

executes a function for every primary input of the nework

template<typename Fn>
void foreach_po(Fn &&fn) const

executes a function for every primary output of the nework

template<typename Fn>
void foreach_gate(Fn &&fn) const

executes a function for every gate of the nework

template<typename Fn>
void foreach_fanin(node const &n, Fn &&fn) const

executes a function for every incoming signal of a node

void clear_weights() const

clears the application specific value for every node

uint32_t get_weight(node const &n) const

returns the application specific value of a node

void set_weight(node const &n, uint32_t v) const

sets the application specific value of a node

void clear_visited() const
auto visited(node const &n) const
void set_visited(node const &n, uint32_t v) const

Public Members

std::shared_ptr<abstract_storage> _storage

Public Static Attributes

constexpr auto min_fanin_size = 1
constexpr auto max_fanin_size = 32

maximum fanin size

Single-target gate

class caterpillar::stg_gate : public gate_base

A single-target gate is a reversible gate characterized by: _function a control function, _controls a list of control qubits, _targets a list of target qubits.

X gates are applied to the targets whenever the control function evaluates to true.

Public Functions

stg_gate(gate_base const &op, td::qubit_id target)
stg_gate(gate_base const &op, td::qubit_id control, td::qubit_id target)
stg_gate(gate_base const &op, std::vector<td::qubit_id> const &controls, std::vector<td::qubit_id> const &targets)
stg_gate(kitty::dynamic_truth_table const &function, std::vector<td::qubit_id> const &controls, td::qubit_id target)
bool is_unitary_gate() const
uint32_t num_controls() const
uint32_t num_targets() const
auto controls() const
auto targets() const
template<typename Fn>
void foreach_control(Fn &&fn) const
template<typename Fn>
void foreach_target(Fn &&fn) const