Write into file formats

Write into AIGER files

Header: mockturtle/io/write_aiger.hpp

template<typename Ntk>
inline void mockturtle::write_aiger(Ntk const &aig, std::string const &filename)

Writes an AIG network in binary AIGER format into a file.

This function should be only called on “clean” aig_networks, e.g., immediately after cleanup_dangling.

Sequential networks (e.g., sequential<aig_network>) are supported: their registers are emitted as AIGER latches. See the std::ostream overload for the requirements this places on the order in which the network was built.

Required network functions:

  • num_cis

  • num_cos

  • foreach_gate

  • foreach_fanin

  • foreach_po

  • get_node

  • is_complemented

  • node_to_index

Optional network functions (enable sequential support):

  • num_registers

  • foreach_ri

  • register_at

Parameters:
  • aig – AIG network

  • filename – Filename

template<typename Ntk>
inline void mockturtle::write_aiger(Ntk const &aig, std::ostream &os)

Writes an AIG network in binary AIGER format into a file.

This function should be only called on “clean” aig_networks, e.g., immediately after cleanup_dangling.

Sequential networks (e.g., sequential<aig_network>) are supported: their registers are emitted as AIGER latches. For a network type that does not implement foreach_ri/num_registers, a latch count of 0 is written and the network is asserted to be combinational.

The binary AIGER format encodes the primary inputs and the register outputs implicitly, by requiring that variables 1..I are the primary inputs and variables I+1..I+L are the register outputs. Networks must therefore be built by creating all primary inputs first, then all register outputs, before any gate. This matches the order in which aiger_reader constructs a network and is checked by an assertion.

Required network functions:

  • num_cis

  • num_cos

  • foreach_gate

  • foreach_fanin

  • foreach_po

  • get_node

  • is_complemented

  • node_to_index

Optional network functions (enable sequential support):

  • num_registers

  • foreach_ri

  • register_at

Parameters:
  • aig – AIG network

  • os – Output stream

Write into BENCH files

Header: mockturtle/io/write_bench.hpp

template<class Ntk>
void mockturtle::write_bench(Ntk const &ntk, std::string const &filename)

Writes network in BENCH format into a file.

Required network functions:

  • is_constant

  • is_pi

  • is_complemented

  • get_node

  • num_pos

  • node_to_index

  • node_function

Parameters:
  • ntk – Network

  • filename – Filename

template<class Ntk>
void mockturtle::write_bench(Ntk const &ntk, std::ostream &os)

Writes network in BENCH format into output stream.

An overloaded variant exists that writes the network into a file.

Required network functions:

  • is_constant

  • is_pi

  • is_complemented

  • get_node

  • num_pos

  • node_to_index

  • node_function

Parameters:
  • ntk – Network

  • os – Output stream

Write into BLIF files

Header: mockturtle/io/write_blif.hpp

template<class Ntk>
void mockturtle::write_blif(Ntk const &ntk, std::string const &filename, write_blif_params const &ps = {})

Writes network in BLIF format into a file.

Required network functions:

  • fanin_size

  • foreach_fanin

  • foreach_pi

  • foreach_po

  • get_node

  • is_constant

  • is_pi

  • node_function

  • node_to_index

  • num_pis

  • num_pos

Parameters:
  • ntk – Network

  • filename – Filename

template<class Ntk>
void mockturtle::write_blif(Ntk const &ntk, std::ostream &os, write_blif_params const &ps = {})

Writes network in BLIF format into output stream.

An overloaded variant exists that writes the network into a file.

Required network functions:

  • fanin_size

  • foreach_fanin

  • foreach_pi

  • foreach_po

  • get_node

  • is_constant

  • is_pi

  • node_function

  • node_to_index

  • num_pis

  • num_pos

Parameters:
  • ntk – Network

  • os – Output stream

Write into structural Verilog files

Header: mockturtle/io/write_verilog.hpp

template<class Ntk>
void mockturtle::write_verilog(Ntk const &ntk, std::string const &filename, write_verilog_params const &ps = {})

Writes network in structural Verilog format into a file.

Required network functions:

  • num_pis

  • num_pos

  • foreach_pi

  • foreach_node

  • foreach_fanin

  • get_node

  • get_constant

  • is_constant

  • is_pi

  • is_and

  • is_or

  • is_xor

  • is_xor3

  • is_maj

  • node_to_index

Parameters:
  • ntk – Network

  • filename – Filename

template<class Ntk>
void mockturtle::write_verilog(Ntk const &ntk, std::ostream &os, write_verilog_params const &ps = {})

Writes network in structural Verilog format into output stream.

An overloaded variant exists that writes the network into a file.

Required network functions:

  • num_pis

  • num_pos

  • foreach_pi

  • foreach_node

  • foreach_fanin

  • get_node

  • get_constant

  • is_constant

  • is_pi

  • is_and

  • is_or

  • is_xor

  • is_xor3

  • is_maj

  • is_ite

  • node_to_index

Parameters:
  • ntk – Network

  • os – Output stream

template<class Ntk>
void mockturtle::write_verilog_with_binding(Ntk const &ntk, std::string const &filename, write_verilog_params const &ps = {})

Writes mapped network in structural Verilog format into a file.

Required network functions:

  • num_pis

  • num_pos

  • foreach_pi

  • foreach_node

  • foreach_fanin

  • get_node

  • get_constant

  • is_constant

  • is_pi

  • node_to_index

  • has_binding

  • get_binding_index

Parameters:
template<class Ntk>
void mockturtle::write_verilog_with_binding(Ntk const &ntk, std::ostream &os, write_verilog_params const &ps = {})

Writes mapped network in structural Verilog format into output stream.

Required network functions:

  • num_pis

  • num_pos

  • foreach_pi

  • foreach_node

  • foreach_fanin

  • get_node

  • get_constant

  • is_constant

  • is_pi

  • node_to_index

  • has_binding

  • get_binding_index

Parameters:
  • ntk – Mapped network

  • os – Output stream

  • ps – Verilog parameters

template<class Ntk>
void mockturtle::write_verilog_with_cell(Ntk const &ntk, std::string const &filename, write_verilog_params const &ps = {})

Writes mapped network in structural Verilog format into a file.

Required network functions:

  • num_pis

  • num_pos

  • foreach_pi

  • foreach_node

  • foreach_fanin

  • get_node

  • get_constant

  • is_constant

  • is_pi

  • node_to_index

  • has_cell

  • get_cell_index

Parameters:
  • ntk – Network (cell_view)

  • filename – Filename

template<class Ntk>
void mockturtle::write_verilog_with_cell(Ntk const &ntk, std::ostream &os, write_verilog_params const &ps = {})

Writes mapped network in structural Verilog format into output stream.

Required network functions:

  • num_pis

  • num_pos

  • foreach_pi

  • foreach_node

  • foreach_fanin

  • get_node

  • get_constant

  • is_constant

  • is_pi

  • node_to_index

  • has_cell

  • get_cell_index

Parameters:
  • ntk – Mapped network

  • os – Output stream

  • ps – Verilog parameters

Write into DIMACS files (CNF)

Header: mockturtle/io/write_cnf.hpp

template<class Ntk>
void mockturtle::write_dimacs(Ntk const &ntk, std::string const &filename)

Writes network into CNF DIMACS format.

It also adds unit clauses for the outputs. Therefore a satisfying solution is one that makes all outputs 1.

Parameters:
  • ntk – Logic network

  • filename – Filename

template<class Ntk>
void mockturtle::write_dimacs(Ntk const &ntk, std::ostream &out = std::cout)

Writes network into CNF DIMACS format.

It also adds unit clauses for the outputs. Therefore a satisfying solution is one that makes all outputs 1.

Parameters:
  • ntk – Logic network

  • out – Output stream

Write into DOT files (Graphviz)

Header: mockturtle/io/write_dot.hpp

template<class Ntk, class Drawer = default_dot_drawer<Ntk>>
void mockturtle::write_dot(Ntk const &ntk, std::string const &filename, Drawer const &drawer = {})

Writes network in DOT format into a file.

Required network functions:

  • is_constant

  • is_ci

  • foreach_node

  • foreach_fanin

  • foreach_po

Parameters:
  • ntk – Network

  • filename – Filename

template<class Ntk, class Drawer = default_dot_drawer<Ntk>>
void mockturtle::write_dot(Ntk const &ntk, std::ostream &os, Drawer const &drawer = {})

Writes network in DOT format into output stream.

An overloaded variant exists that writes the network into a file.

Required network functions:

  • is_constant

  • is_ci

  • foreach_node

  • foreach_fanin

  • foreach_po

Parameters:
  • ntk – Network

  • os – Output stream

Write simulation patterns into file

Header: mockturtle/io/write_patterns.hpp

template<class Simulator>
void mockturtle::write_patterns(Simulator const &sim, std::string const &filename)

Writes simulation patterns.

The output contains num_pis() lines, each line contains a stream of simulation values of a primary input, represented in hexadecimal.

Parameters:
  • sim – The partial_simulator or bit_packed_simulator object containing simulation patterns

  • filename – Filename

template<class Simulator>
void mockturtle::write_patterns(Simulator const &sim, std::ostream &out = std::cout)

Writes simulation patterns.

The output contains num_pis() lines, each line contains a stream of simulation values of a primary input, represented in hexadecimal.

Parameters:
  • sim – The partial_simulator or bit_packed_simulator object containing simulation patterns

  • out – Output stream

Write library into GENLIB file

Header: mockturtle/io/write_genlib.hpp

void mockturtle::write_genlib(std::vector<gate> const &gates, std::string const &filename)

Write library of gates into a GENLIB file.

Parameters:
  • gates – List of gates

  • filename – Filename

void mockturtle::write_genlib(std::vector<gate> const &gates, std::ostream &os)

Writes library of gates to GENLIB format.

An overloaded variant exists that writes the network into a file.

Parameters:
  • gates – List of gates

  • os – Output stream