Exemple #1
0
 def get_time(cls, v: core.Vertex) -> Optional[int]:
     if "time" in v.properties:
         return v.properties["time"]
     else:
         if v.has_trait(VertexTrait.WCET):
             return 0
         if v.has_trait(VertexTrait.WCCT):
             return 0
         else:
             return None
Exemple #2
0
 def get_max_memory_size_in_bytes(cls, v: core.Vertex) -> Optional[int]:
     if "max_memory_size_in_bytes" in v.properties:
         return v.properties["max_memory_size_in_bytes"]
     else:
         if v.has_trait(VertexTrait.InstrumentedFunction):
             return 1
         else:
             return None
Exemple #3
0
 def get_max_elem_count(cls, v: core.Vertex) -> Optional[int]:
     if "max_elem_count" in v.properties:
         return v.properties["max_elem_count"]
     else:
         if v.has_trait(VertexTrait.InstrumentedSignal):
             return 1
         else:
             return None
Exemple #4
0
 def get_can_be_explored(cls, v: core.Vertex) -> Optional[bool]:
     if "can_be_explored" in v.properties:
         return v.properties["can_be_explored"]
     else:
         if v.has_trait(VertexTrait.AbstractProcessingComponent):
             return True
         else:
             return None
Exemple #5
0
 def get_max_operations(cls, v: core.Vertex) -> Optional[Mapping[str, int]]:
     if "max_operations" in v.properties:
         return v.properties["max_operations"]
     else:
         if v.has_trait(VertexTrait.InstrumentedFunction):
             return {}
         else:
             return None
Exemple #6
0
 def get_trigger_time(cls, v: core.Vertex) -> Optional[Mapping[int, str]]:
     if "trigger_time" in v.properties:
         return v.properties["trigger_time"]
     else:
         if v.has_trait(VertexTrait.TimeTriggeredScheduler):
             return {}
         else:
             return None
Exemple #7
0
 def get_apriori_importance(cls, v: core.Vertex) -> Optional[int]:
     if "apriori_importance" in v.properties:
         return v.properties["apriori_importance"]
     else:
         if v.has_trait(VertexTrait.MinimumThroughput):
             return 1
         else:
             return None
Exemple #8
0
 def get_offset_denominator_per_sec(cls, v: core.Vertex) -> Optional[int]:
     if "offset_denominator_per_sec" in v.properties:
         return v.properties["offset_denominator_per_sec"]
     else:
         if v.has_trait(VertexTrait.ReactorTimer):
             return 1
         else:
             return None
Exemple #9
0
 def get_slots(cls, v: core.Vertex) -> Optional[int]:
     if "slots" in v.properties:
         return v.properties["slots"]
     else:
         if v.has_trait(VertexTrait.TimeDivisionMultiplexer):
             return 1
         else:
             return None
Exemple #10
0
 def get_configurations(cls, v: core.Vertex) -> Optional[Sequence[str]]:
     if "configurations" in v.properties:
         return v.properties["configurations"]
     else:
         if v.has_trait(VertexTrait.Instrumented):
             raise ValueError(
                 "Property configurations should exist in vertex '" +
                 v.identifier + "' with trait Instrumented, but does not.")
         else:
             return None
Exemple #11
0
 def get_production(cls, v: core.Vertex) -> Optional[Mapping[str, int]]:
     if "production" in v.properties:
         return v.properties["production"]
     else:
         if v.has_trait(VertexTrait.SDFComb):
             raise ValueError(
                 "Property production should exist in vertex '" +
                 v.identifier + "' with trait SDFComb, but does not.")
         else:
             return None
Exemple #12
0
 def get_max_memory_internal_bytes(cls, v: core.Vertex) -> Optional[int]:
     if "max_memory_internal_bytes" in v.properties:
         return v.properties["max_memory_internal_bytes"]
     else:
         if v.has_trait(VertexTrait.InstrumentedProcessorTile):
             raise ValueError(
                 "Property max_memory_internal_bytes should exist in vertex '"
                 + v.identifier +
                 "' with trait InstrumentedProcessorTile, but does not.")
         else:
             return None
Exemple #13
0
 def get_min_frequency_hz(cls, v: core.Vertex) -> Optional[int]:
     if "min_frequency_hz" in v.properties:
         return v.properties["min_frequency_hz"]
     else:
         if v.has_trait(VertexTrait.InstrumentedProcessorTile):
             raise ValueError(
                 "Property min_frequency_hz should exist in vertex '" +
                 v.identifier +
                 "' with trait InstrumentedProcessorTile, but does not.")
         else:
             return None
Exemple #14
0
 def get_provides(
         cls, v: core.Vertex) -> Optional[Mapping[str, Mapping[str, int]]]:
     if "provides" in v.properties:
         return v.properties["provides"]
     else:
         if v.has_trait(VertexTrait.Instrumented):
             raise ValueError("Property provides should exist in vertex '" +
                              v.identifier +
                              "' with trait Instrumented, but does not.")
         else:
             return None
Exemple #15
0
 def get_period_numerator_per_sec(cls, v: core.Vertex) -> Optional[int]:
     if "period_numerator_per_sec" in v.properties:
         return v.properties["period_numerator_per_sec"]
     else:
         if v.has_trait(VertexTrait.ReactorTimer):
             raise ValueError(
                 "Property period_numerator_per_sec should exist in vertex '"
                 + v.identifier +
                 "' with trait ReactorTimer, but does not.")
         else:
             return None
Exemple #16
0
 def get_max_bandwith_bytes_per_sec(cls, v: core.Vertex) -> Optional[int]:
     if "max_bandwith_bytes_per_sec" in v.properties:
         return v.properties["max_bandwith_bytes_per_sec"]
     else:
         if v.has_trait(VertexTrait.InstrumentedCommunicationInterconnect):
             raise ValueError(
                 "Property max_bandwith_bytes_per_sec should exist in vertex '"
                 + v.identifier +
                 "' with trait InstrumentedCommunicationInterconnect, but does not."
             )
         else:
             return None
Exemple #17
0
 def get_max_clock_cycles_per_op(
         cls, v: core.Vertex) -> Optional[Mapping[str, int]]:
     if "max_clock_cycles_per_op" in v.properties:
         return v.properties["max_clock_cycles_per_op"]
     else:
         if v.has_trait(VertexTrait.InstrumentedProcessorTile):
             raise ValueError(
                 "Property max_clock_cycles_per_op should exist in vertex '"
                 + v.identifier +
                 "' with trait InstrumentedProcessorTile, but does not.")
         else:
             return None
Exemple #18
0
 def read(
     self, source: str, other_model: Optional[ForSyDeModel] = None
 ) -> ForSyDeModel:
     xmlns = "{http://graphml.graphdrawing.org/xmlns}"
     model = ForSyDeModel() if not other_model else other_model
     with open(source, "r") as instream:
         tree = etree.parse(instream)
         for vnode in tree.findall(".//" + xmlns + "graph/" + xmlns + "node"):
             vertex = Vertex(identifier=vnode.get("id"))
             vertex.vertex_traits = set(
                 VertexTrait[trait_name]
                 for trait_name in vnode.get("traits", '').split(";")
             )
             model.add_node(vertex, label=vertex.identifier)
             for portnode in vnode.iterfind("./" + xmlns + "port"):
                 port = Port(identifier=portnode.get("name"))
                 vertex.ports.add(port)
             dataopen = [(vnode, vertex.properties)]
             while len(dataopen) > 0:
                 (parent, data) = dataopen.pop()
                 for datanode in parent.iterfind(xmlns + "data"):
                     dataname = datanode.get("attr.name")
                     datatype = self.str_to_type(datanode.get("attr.type"))
                     if datatype is str or datatype is int or datatype is float:
                         if isinstance(data, list):
                             data.append(datatype(datanode.text))
                         else:
                             data[dataname] = datatype(datanode.text)
                     else:
                         child = datatype()
                         if datatype is list:
                             data.append(child)
                         else:
                             data[dataname] = child
                         dataopen.append((datanode, child))
         for vedge in tree.iterfind(
             ".//" + xmlns + "graph/" + xmlns + "edge", namespaces=self.ns
         ):
             source_vertex = next(
                 (
                     n
                     for (n, nid) in model.nodes.data("label")
                     if nid == vedge.get("source")
                 ),
                 None,
             )
             if source_vertex is None:
                 raise ValueError(
                     f"Could not find source node {vedge.get('source')} to during edge building."
                 )
             target_vertex = next(
                 (
                     n
                     for (n, nid) in model.nodes.data("label")
                     if nid == vedge.get("target")
                 ),
                 None,
             )
             if target_vertex is None:
                 raise ValueError(
                     f"Could not find target node {vedge.get('target')} to during edge building."
                 )
             edge = Edge(
                 source=source_vertex,
                 target=target_vertex,
                 edge_traits=set(EdgeTrait[n] for n in vedge.get('traits', '').split(';'))
             )
             if vedge.get("sourceport"):
                 edge.source_port = source_vertex.get_port(
                     vedge.get("sourceport")
                 )
             if vedge.get("targetport"):
                 edge.target_port = target_vertex.get_port(
                     vedge.get("targetport")
                 )
             key = (
                 f"{vedge.get('source')}:{vedge.get('sourceport')}->"
                 + f"{vedge.get('target')}:{vedge.get('targetport')}"
             )
             model.add_edge(source_vertex, target_vertex, key=key, object=edge)
     return model