Sequential networks

Header: mockturtle/networks/sequential.hpp

Plain network implementations model the combinational part of circuits. Representation of memory elements (called registers, though they can also be used to model latches) can be extended to some network implementations by wrapping the network with sequential.

sequential<aig_network> sequential_aig;
sequential<xag_network> sequential_xag;
sequential<mig_network> sequential_mig;
sequential<xmg_network> sequential_xmg;
sequential<klut_network> sequential_klut;
sequential<cover_network> sequential_cover;

Storing register information

struct register_t

Register information.

Public Members

std::string control = ""

Control (clocking or enabling) signal.

uint8_t init = 3

Initial (reset) value.

std::string type = ""

Type of register or latch (active high/low, rising/falling edge)

Sequential interface APIs

By wrapping a network with sequential, the following interface APIs are provided (or overwritten).

template<typename Ntk, bool aig_like = detail::is_aig_like_v<typename Ntk::base_type>>
class sequential

Private Functions

signal create_ro()

Creates a register output in the network.

Each created register output is stored in a node and contributes to the size of the network. Register outputs must be created after all primary inputs have been created and must have a corresponding register input that is created with create_ri.

Register outputs serve as inputs for the network.

Register outputs and register inputs always have to be created in pairs; they are associated to each other by index, i.e., the first created register output corresponds to the first created register input, etc.

uint32_t create_ri(signal const &f)

Creates a register input in the network.

A register input is not stored in terms of a node, and it also does not contribute to the size of the network. A register input is created for a signal in the network and it is possible that multiple register inputs point to the same signal. Register inputs must be created after all primary outputs have been created and must have a corresponding register output that is created with create_ro.

Register inputs serve as outputs for the network.

Register outputs and register inputs always have to be created in pairs; they are associated to each other by index, i.e., the first created register output corresponds to the first created register input, etc.

Parameters:

f – Signal that drives the created register input

bool is_ci(node const &n) const

Checks whether a node is a combinational input (PI or RO).

bool is_ro(node const &n) const

Checks whether a node is a register output.

bool is_combinational() const

Checks whether the network is combinational.

Returns true if and only if the network has no registers (neither register outputs nor register inputs).

auto num_cis() const

Returns the number of combinational inputs (PIs and ROs).

auto num_cos() const

Returns the number of combinational outputs (POs and RIs).

auto num_registers() const

Returns the number of registers.

This number is usually equal to the number of register outputs and register inputs because they have to appear in pairs. During the construction of a network, the number of register outputs and register inputs may diverge.

node ci_at(uint32_t index) const

Returns the combinational input node for an index.

Parameters:

index – A value between 0 (inclusive) and the number of combinational inputs (exclusive).

signal co_at(uint32_t index) const

Returns the combinational output signal for an index.

Parameters:

index – A value between 0 (inclusive) and the number of combinational outputs (exclusive).

node ro_at(uint32_t index) const

Returns the register output node for an index.

Parameters:

index – A value between 0 (inclusive) and the number of register outputs (exclusive).

signal ri_at(uint32_t index) const

Returns the register input signal for an index.

Parameters:

index – A value between 0 (inclusive) and the number of register inputs (exclusive).

uint32_t ci_index(node const &n) const

Returns the index of a combinational input node.

Parameters:

n – A combinational input node.

Returns:

A value between 0 and num_cis()-1.

uint32_t co_index(signal const &s) const

Returns the index of a combinational output signal.

Parameters:

n – A combinational output signal.

Returns:

A value between 0 and num_cos()-1.

uint32_t ro_index(node const &n) const

Returns the index of a register output node.

Parameters:

n – A register output node.

Returns:

A value between 0 and num_cis()-num_pis()-1.

uint32_t ri_index(signal const &s) const

Returns the index of a register input signal.

Parameters:

n – A register input signal.

Returns:

A value between 0 and num_cos()-num_pos()-1.

signal ro_to_ri(signal const &s) const

Returns the register input signal to a register output node.

Parameters:

signal – A signal of a register output.

node ri_to_ro(signal const &s) const

Returns the register output node for a register input signal.

Parameters:

signal – A node of a register input.

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

Calls fn on every combinational input node in the network.

The order is in the same order as combinational inputs have been created with create_pi or create_ro. The parameter fn is any callable that must have one of the following four signatures.

  • void(node const&)

  • void(node const&, uint32_t)

  • bool(node const&)

  • bool(node const&, uint32_t)

If fn has two parameters, the second parameter is an index starting from 0 and incremented in every iteration. If fn returns a bool, then it can interrupt the iteration by returning false.

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

Calls fn on every combinational output signal in the network.

The order is in the same order as combinational outputs have been created with create_po or create_ri. The function is called on the signal that is driving the output and may occur more than once in the iteration, if it drives more than one output. The parameter fn is any callable that must have one of the following four signatures.

  • void(signal const&)

  • void(signal const&, uint32_t)

  • bool(signal const&)

  • bool(signal const&, uint32_t)

If fn has two parameters, the second parameter is an index starting from 0 and incremented in every iteration. If fn returns a bool, then it can interrupt the iteration by returning false.

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

Calls fn on every register output node in the network.

The order is in the same order as register outputs have been created with create_ro. The parameter fn is any callable that must have one of the following four signatures.

  • void(node const&)

  • void(node const&, uint32_t)

  • bool(node const&)

  • bool(node const&, uint32_t)

If fn has two parameters, the second parameter is an index starting from 0 and incremented in every iteration. If fn returns a bool, then it can interrupt the iteration by returning false.

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

Calls fn on every register input signal in the network.

The order is in the same order as register inputs have been created with create_ri. The function is called on the signal that is driving the output and may occur more than once in the iteration, if it drives more than one output. The parameter fn is any callable that must have one of the following four signatures.

  • void(signal const&)

  • void(signal const&, uint32_t)

  • bool(signal const&)

  • bool(signal const&, uint32_t)

If fn has two parameters, the second parameter is an index starting from 0 and incremented in every iteration. If fn returns a bool, then it can interrupt the iteration by returning false.

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

Calls fn on every pair of register input signal and register output node in the network.

Calls each pair of a register input signal and the associated register output node. The parameter fn is any callable that must have one of the following four signatures.

  • void(std::pair<signal, node> const&)

  • void(std::pair<signal, node> const&, uint32_t)

  • bool(std::pair<signal, node> const&)

  • bool(std::pair<signal, node> const&, uint32_t)

If fn has two parameters, the second parameter is an index starting from 0 and incremented in every iteration. If fn returns a bool, then it can interrupt the iteration by returning false.

void set_register(uint32_t index, register_t reg)

Sets the register information for an index.

Parameters:
  • index – A value between 0 (inclusive) and the number of registers (exclusive).

  • reg – Register information to set.

register_t register_at(uint32_t index) const

Returns the register information for an index.

Parameters:

index – A value between 0 (inclusive) and the number of registers (exclusive).

Returns:

Register information (see register_t).