Skip to content

Commit

Permalink
Use SpecificationBuilder for creating specification
Browse files Browse the repository at this point in the history
Signed-off-by: bbrzyski <[email protected]>
  • Loading branch information
bbrzyski committed Aug 6, 2024
1 parent ece41c9 commit 41bb9ff
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 212 deletions.
2 changes: 1 addition & 1 deletion examples/user_repository/repo/interfaces/interface1.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: inter1
name: coreStream
port_prefix: inter1
signals:
required:
Expand Down
29 changes: 20 additions & 9 deletions topwrap/design_to_kpm_dataflow_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ class KPMDataflowNodeInterface:
KPM_DIR_OUTPUT = "output"
KPM_DIR_INOUT = "inout"

# will be used from subgraph merge
kpm_direction_extensions_dict = {
"in": KPM_DIR_INPUT,
"out": KPM_DIR_OUTPUT,
"inout": KPM_DIR_INOUT,
}

def __init__(self, name: str, direction: str, value: str = None):
if direction not in [
KPMDataflowNodeInterface.KPM_DIR_INPUT,
Expand Down Expand Up @@ -134,16 +141,20 @@ def __init__(self, **kwargs):


class KPMDataflowExternalMetanode(KPMDataflowMetanode):
@staticmethod
def valid_node_name(node_name: str) -> bool:
return node_name in [EXT_OUTPUT_NAME, EXT_INPUT_NAME, EXT_INOUT_NAME]

interface_dir_by_node_name = {
EXT_OUTPUT_NAME: KPMDataflowNodeInterface.KPM_DIR_INPUT,
EXT_INPUT_NAME: KPMDataflowNodeInterface.KPM_DIR_OUTPUT,
EXT_INOUT_NAME: KPMDataflowNodeInterface.KPM_DIR_INOUT,
}

def __init__(self, node_name: str, property_name: str):
if node_name not in [EXT_OUTPUT_NAME, EXT_INPUT_NAME, EXT_INOUT_NAME]:
if not self.valid_node_name(node_name):
raise ValueError(f"Invalid external node name: {node_name}")

interface_dir_by_node_name = {
EXT_OUTPUT_NAME: KPMDataflowNodeInterface.KPM_DIR_INPUT,
EXT_INPUT_NAME: KPMDataflowNodeInterface.KPM_DIR_OUTPUT,
EXT_INOUT_NAME: KPMDataflowNodeInterface.KPM_DIR_INOUT,
}

super().__init__(
name=node_name,
type=node_name,
Expand All @@ -155,7 +166,7 @@ def __init__(self, node_name: str, property_name: str):
interfaces=[
KPMDataflowMetanodeInterface(
KPMDataflowMetanodeInterface.EXT_IFACE_NAME,
interface_dir_by_node_name[node_name],
self.interface_dir_by_node_name[node_name],
)
],
)
Expand Down Expand Up @@ -246,7 +257,7 @@ def kpm_nodes_from_design_descr(design_descr: dict, specification: dict) -> List

kpm_properties = {
prop["name"]: KPMDataflowNodeProperty(prop["name"], prop["default"])
for prop in spec_node["properties"]
for prop in spec_node.get("properties", [])
}
if ip_name in parameters.keys():
for param_name, param_val in parameters[ip_name].items():
Expand Down
Loading

0 comments on commit 41bb9ff

Please sign in to comment.