Skip to content

Data Container

SJulianS edited this page Oct 26, 2020 · 6 revisions

The data container is used as a base class for gates, nets, and modules and provides a basic functionality to store any arbitrary data alongside those netlist components. Hence, all functions presented below are available for gates, nets, and modules.

Each data entry is composed of a data category, a data key, the data type, and the data value itself. The data category is, for example, used to distinguish between data parsed from generics and attributes within an HDL file and is rather irrelevant for the user. A data key uniquely addresses a data entry within its category. Hence, a key may be used once within each category. The data type specifies whether the entry contains an integer number, a float, a string, or something else. The data value finally gives the actual value of the data entry.

Accessing Data

Data can easily be added using the 'set_data' command. Additionally, all data associated with an entity can be retrieved as a dict using get_data. If only a specific data entry is desired, get_data_by_key may be used instead. For a list of all utilized data keys, the user may call get_data_keys.

gate = netlist.get_gate_by_id(3)                      # get gate with ID 3
gate.set_data("generic", "area", "float", "0.34")     # set data for area of gate
gate.set_data("generic", "delay", "float", "1.2")     # set data for delay time of gate
all_data = gate.get_data()                            # get a dict from tuple (category, key) to tuple (type, value)
area_data = gate.get_data_by_key("generic", "area")   # get a tuple (type, value) containing the area data entry
gate.delete_data("generic", "area")                   # delete the data entry containing the area
Clone this wiki locally