Input Parsing

Read logic networks, truth tables, or FCN layouts from file into data types.

Logic Networks

Header: fiction/io/network_reader.hpp

template<typename NtkPtr>
class network_reader

Helper class to read directories of mockturtle networks of certain types.

Template Parameters:

NtkPtr – Pointer type to a logic network.

Public Functions

inline network_reader(const std::string_view &filename, std::ostream &o)

Standard constructor. Reads and constructs logic networks. May throw.

Parameters:
  • filename – Path to the file or folder of files to read.

  • out – Output stream to write status updates into.

inline const std::vector<NtkPtr> &get_networks(bool sorted = false)

Getter for networks generated from given files.

Parameters:

sorted – Flag to indicate that the networks are to be returned in ascending order of their vertex count.

Returns:

Vector of read and constructed logic networks.

Truth Tables

Header: fiction/io/tt_reader.hpp

template<typename TT = kitty::dynamic_truth_table>
class tt_reader

Simple reader to parse truth tables from files. The files must be organized as follows: Each line consists of a truth table in hexadecimal form plus its corresponding Boolean expression. The two are separated by a space.

This format is used by, e.g., Alan Mishchenko for his DSD functions: https://people.eecs.berkeley.edu/~alanmi/temp5/

Public Functions

inline explicit tt_reader(std::istream &stream)

Standard constructor. Reads the given stream into a vector of lines.

Parameters:

stream – Stream to parse.

inline explicit tt_reader(const std::string &filename)

Standard constructor. Reads the given file into a vector of lines.

Parameters:

filename – File to parse.

inline std::optional<TT> next()

Returns the next truth table parsed from the file or std::nullopt if no further truth tables are available.

Returns:

Next truth table from the file.

Gate-level Layouts

Can be used to read gate-level layout files (.fgl) as offered by MNT Bench.

Header: fiction/io/read_fgl_layout.hpp

template<typename Lyt>
Lyt fiction::read_fgl_layout(std::istream &is, const std::string_view &name = "")

Reads a gate-level layout from an FGL file provided as an input stream.

May throw an fgl_parsing_exception if the FGL file is malformed.

Template Parameters:

Lyt – The layout type to be created from an input.

Parameters:
  • is – The input stream to read from.

  • name – The name to give to the generated layout.

template<typename Lyt>
void fiction::read_fgl_layout(Lyt &lyt, std::istream &is)

Reads a gate-level layout from an FGL file provided as an input stream.

May throw an fgl_parsing_exception if the FGL file is malformed.

This is an in-place version of read_fgl_layout that utilizes the given layout as a target to write to.

Template Parameters:

Lyt – The layout type to be used as input.

Parameters:
  • lyt – The layout to write to.

  • is – The input stream to read from.

template<typename Lyt>
Lyt fiction::read_fgl_layout(const std::string_view &filename, const std::string_view &name = "")

Reads a gate-level layout from an FGL file provided as a file name.

May throw an fgl_parsing_exception if the FGL file is malformed.

Template Parameters:

Lyt – The layout type to be created from an input.

Parameters:
  • filename – The file name to open and read from.

  • name – The name to give to the generated layout.

template<typename Lyt>
void fiction::read_fgl_layout(Lyt &lyt, const std::string_view &filename)

Reads a gate-level layout from an FGL file provided as a file name.

May throw an fgl_parsing_exception if the FGL file is malformed.

This is an in-place version of read_fgl_layout that utilizes the given layout as a target to write to.

Template Parameters:

Lyt – The layout type to be used as input.

Parameters:
  • lyt – The layout to write to.

  • filename – The file name to open and read from.

class fgl_parsing_error : public std::runtime_error

Exception thrown when an error occurs during parsing of a .fgl file containing a gate-level layout.

Cell-level Layouts

Header: fiction/io/read_sqd_layout.hpp

template<typename Lyt>
Lyt fiction::read_sqd_layout(std::istream &is, const std::string_view &name = "")

Reads a cell-level SiDB layout from an sqd file provided as an input stream. The format is used by SiQAD (https://github.com/siqad/siqad).

If The provided cell-level layout type can represent SiDB defects, they will be parsed from the sqd file as well.

May throw an sqd_parsing_exception if the sqd file is malformed.

Template Parameters:

Lyt – The layout type to be created from an input. Must be a cell-level SiDB layout.

Parameters:
  • is – The input stream to read from.

  • name – The name to give to the generated layout.

template<typename Lyt>
void fiction::read_sqd_layout(Lyt &lyt, std::istream &is)

Reads a cell-level SiDB layout from an sqd file provided as an input stream. The format is used by SiQAD (https://github.com/siqad/siqad).

If The provided cell-level layout type can represent SiDB defects, they will be parsed from the sqd file as well.

May throw an sqd_parsing_exception if the sqd file is malformed.

This is an in-place version of read_sqd_layout that utilizes the given layout as a target to write to.

Template Parameters:

Lyt – The layout type to be used as input. Must be a cell-level SiDB layout.

Parameters:
  • lyt – The layout to write to.

  • is – The input stream to read from.

template<typename Lyt>
Lyt fiction::read_sqd_layout(const std::string_view &filename, const std::string_view &name = "")

Reads a cell-level SiDB layout from an sqd file provided as a file name. The format is used by SiQAD (https://github.com/siqad/siqad).

If The provided cell-level layout type can represent SiDB defects, they will be parsed from the sqd file as well.

May throw an sqd_parsing_exception if the sqd file is malformed.

Template Parameters:

Lyt – The layout type to be created from an input. Must be a cell-level SiDB layout.

Parameters:
  • filename – The file name to open and read from.

  • name – The name to give to the generated layout.

template<typename Lyt>
void fiction::read_sqd_layout(Lyt &lyt, const std::string_view &filename)

Reads a cell-level SiDB layout from an sqd file provided as a file name. The format is used by SiQAD (https://github.com/siqad/siqad).

If The provided cell-level layout type can represent SiDB defects, they will be parsed from the sqd file as well.

May throw an sqd_parsing_exception if the sqd file is malformed.

This is an in-place version of read_sqd_layout that utilizes the given layout as a target to write to.

Template Parameters:

Lyt – The layout type to be used as input. Must be a cell-level SiDB layout.

Parameters:
  • lyt – The layout to write to.

  • filename – The file name to open and read from.

class sqd_parsing_error : public std::runtime_error

Exception thrown when an error occurs during parsing of an SQD file.

Header: fiction/io/read_fqca_layout.hpp

template<typename Lyt>
Lyt fiction::read_fqca_layout(std::istream &is, const std::string_view &name = "")

Reads a cell-level QCA layout from an fqca file provided as an input stream. The format is used by QCA-STACK by Willem Lambooy (https://github.com/wlambooy/QCA-STACK).

May throw an unsupported_character_exception, undefined_cell_label_exception, or unrecognized_cell_definition_exception.

Template Parameters:

Lyt – The layout type to be created from an input. Must be a clocked cell-level QCA layout.

Parameters:
  • is – The input stream to read from.

  • name – The name to give to the generated layout.

template<typename Lyt>
Lyt fiction::read_fqca_layout(const std::string_view &filename, const std::string_view &name = "")

Reads a cell-level QCA layout from an fqca file provided as a file name. The format is used by QCA-STACK by Willem Lambooy (https://github.com/wlambooy/QCA-STACK).

May throw an unsupported_character_exception, undefined_cell_label_exception, or unrecognized_cell_definition_exception.

Template Parameters:

Lyt – The layout type to be created from an input. Must be a clocked cell-level QCA layout.

Parameters:
  • filename – The file name to open and read from.

  • name – The name to give to the generated layout.

class unsupported_character_exception : public std::exception
class undefined_cell_label_exception : public std::exception
class unrecognized_cell_definition_exception : public std::exception

SiDB Surface Defects

Header: fiction/io/read_sidb_surface_defects.hpp

template<typename Lyt>
sidb_surface<Lyt> fiction::read_sidb_surface_defects(std::istream &is, const std::string_view &name = "")

Reads a defective SiDB surface from a text file provided as an input stream. The format is rudimentary and consists of a simple 2D array of integers representing defect indices printed by Python.

May throw a missing_sidb_position_exception or an unsupported_defect_index_exception.

Note

For testing purposes, a Python script that generates defective surfaces is provided in the experiments/defect_aware_physical_design directory.

Template Parameters:

Lyt – The layout type underlying the SiDB surface. Must be a cell-level SiDB layout.

Parameters:
  • is – The input stream to read from.

  • name – The name to give to the generated layout.

template<typename Lyt>
sidb_surface<Lyt> fiction::read_sidb_surface_defects(const std::string_view &filename, const std::string_view &name = "")

Reads a defective SiDB surface from a text file provided as a file name. The format is rudimentary and consists of a simple 2D array of integers representing defect indices printed by Python.

May throw a missing_sidb_position_exception or an unsupported_defect_index_exception.

Note

For testing purposes, a Python script that generates defective surfaces is provided in the experiments/defect_aware_physical_design directory.

Template Parameters:

Lyt – The layout type underlying the SiDB surface. Must be a cell-level SiDB layout.

Parameters:
  • filename – The file name to open and read from.

  • name – The name to give to the generated layout.

class unsupported_defect_index_exception : public std::exception

Exception thrown when an unsupported defect index is encountered in the parsed file.

class missing_sidb_position_exception : public std::exception

Exception thrown when a missing SiDB position is encountered in the parsed file.