dftlib.storage.dft.Dft

class Dft(json: dict | None = None)

Bases: object

DFT data structure.

Methods

add

Add element.

check_valid

Checks that the DFT is valid, e.g. acyclic, has TLE, etc.

compare

Compare two DFT.

from_json

Initialize from JSON.

get_element

Get element by id.

get_element_by_name

Get element by name.

get_module

Compute module of module_repr.

has_parameter

Check whether the given parameter is known.

is_cyclic

Checks whether the DFT is cyclic.

json

Get JSON string for DFT.

next_id

number_of_be

Get number of BEs.

parametric

Return whether the DFT contains parameters.

remove

Remove element.

replace

Replace original element by new element.

set_top_level_element

Set top level element.

size

Get number of elements (gates + BEs) :return: Number of elements.

statistics

Get general statistics about DFT.

topological_sort

Return the elements in topological sorting from top to bottom.

update_bounds

Update position bounds by also including bounds of given element.

verbose_str

Get verbose string containing information about all elements.

add(element: DftElement) None

Add element. :param element: Element.

check_valid() None

Checks that the DFT is valid, e.g. acyclic, has TLE, etc. Otherwise, an assertion is raised.

compare(other: Dft, respect_ids: bool) bool

Compare two DFT. Note that the comparison currently performs redundant work as for each element comparison the complete subtree is checked. :param other: Other DFT. :param respect_ids: Whether the ids must be equal. :return: True iff all elements, the top-level element and the structure are equal between the two DFTs.

from_json(json: dict) None

Initialize from JSON. :param json: JSON object.

get_element(element_id: int) DftElement

Get element by id. :param element_id: Id. :return: Element.

get_element_by_name(name: str) DftElement

Get element by name. :param name: Name. :return: Element.

get_module(module_repr: DftElement) list[DftElement]

Compute module of module_repr. :param module_repr: Module representative. :return: List of element ids which form the module for module_repr.

has_parameter(name: str) bool

Check whether the given parameter is known. :param name: Name of the parameter. :return: True iff parameter was defined before.

is_cyclic() bool

Checks whether the DFT is cyclic. DFTs should be acyclic. :return: True iff the DFT has a cycle (excluding dependencies and restrictors).

json() dict

Get JSON string for DFT. :return: JSON string.

number_of_be() int

Get number of BEs. :return: Number of BEs.

parametric() bool

Return whether the DFT contains parameters. :return: True iff parameters are defined.

remove(element: DftElement) None

Remove element. :param element: Element.

replace(orig_element: DftElement, new_element: DftElement) None

Replace original element by new element. :param orig_element: Original element. :param new_element: New element.

set_top_level_element(element_id: int) None

Set top level element. :param element_id: Id.

size() int

Get number of elements (gates + BEs) :return: Number of elements.

statistics() tuple[int, int, int, int]

Get general statistics about DFT. :return: Tuple (number of BEs, number of static gates, number of dynamic gates, number of elements)

topological_sort() list[DftElement]

Return the elements in topological sorting from top to bottom. :return: List of elements.

update_bounds(element: DftElement) None

Update position bounds by also including bounds of given element. :param element: Element.

verbose_str() str

Get verbose string containing information about all elements. :return: Verbose string.