Skip to content

Commit

Permalink
Make KPM test setup more general
Browse files Browse the repository at this point in the history
  • Loading branch information
mszalkowski-ant committed Sep 23, 2024
1 parent 26008b1 commit a918cab
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 201 deletions.
144 changes: 35 additions & 109 deletions tests/data/data_kpm/conversions/complex/specification_complex.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,6 @@
"stopName": "Stop"
}
],
"navbarItems": [
{
"allowToRunInParallelWith": [
"dataflow_run",
"custom_lint_files"
],
"iconName": "Validate",
"name": "Validate",
"procedureName": "dataflow_validate",
"stopName": "Stop"
},
{
"allowToRunInParallelWith": [
"dataflow_validate",
"custom_lint_files"
],
"iconName": "Run",
"name": "Run",
"procedureName": "dataflow_run",
"stopName": "Stop"
}
],
"twoColumn": true
},
"nodes": [
Expand Down Expand Up @@ -92,38 +70,6 @@
}
]
},
{
"abstract": false,
"additionalData": "examples/hierarchy/repo/cores/c_mod_1/c_mod_1.yaml",
"category": "IPcore",
"interfaces": [
{
"direction": "input",
"maxConnectionsCount": -1,
"name": "c_mod_in_1",
"type": [
"port"
]
},
{
"direction": "output",
"maxConnectionsCount": -1,
"name": "c_int_out_1",
"type": [
"port"
]
}
],
"layer": "c_mod_1",
"name": "c_mod_1",
"properties": [
{
"default": "32",
"name": "MAX_VALUE",
"type": "text"
}
]
},
{
"abstract": false,
"additionalData": "examples/hierarchy/repo/cores/c_mod_2/c_mod_2.yaml",
Expand All @@ -132,7 +78,6 @@
{
"direction": "output",
"maxConnectionsCount": -1,
"maxConnectionsCount": -1,
"name": "c_int_out_2",
"type": [
"port"
Expand All @@ -141,7 +86,6 @@
{
"direction": "input",
"maxConnectionsCount": -1,
"maxConnectionsCount": -1,
"name": "c_mod_in_2",
"type": [
"port"
Expand All @@ -157,25 +101,33 @@
"category": "IPcore",
"interfaces": [
{
"direction": "input",
"direction": "output",
"maxConnectionsCount": -1,
"name": "c_int_in_1",
"name": "c_mod_out_1",
"type": [
"port"
]
},
{
"direction": "input",
"maxConnectionsCount": -1,
"name": "c_int_in_1",
"type": [
"port"
]
},
{
"direction": "output",
"name": "c_mod_out_1",
"direction": "input",
"maxConnectionsCount": -1,
"name": "c_int_const_in",
"type": [
"port"
]
},
{
"direction": "input",
"name": "c_int_in_1",
"maxConnectionsCount": -1,
"name": "c_int_in_2",
"type": [
"port"
]
Expand All @@ -190,8 +142,15 @@
"category": "IPcore",
"interfaces": [
{
"direction": "output",
"direction": "input",
"maxConnectionsCount": -1,
"name": "cs_s1_f_ext_const_in",
"type": [
"port"
]
},
{
"direction": "output",
"maxConnectionsCount": -1,
"name": "cs_s1_mint_out_1",
"type": [
Expand All @@ -201,7 +160,6 @@
{
"direction": "input",
"maxConnectionsCount": -1,
"maxConnectionsCount": -1,
"name": "cs_s1_f_mod_in_1",
"type": [
"port"
Expand All @@ -225,9 +183,6 @@
"category": "IPcore",
"interfaces": [
{
"direction": "output",
"maxConnectionsCount": -1,
"name": "cs_s1_f_int_out_1",
"direction": "output",
"maxConnectionsCount": -1,
"name": "cs_s1_f_int_out_1",
Expand All @@ -236,9 +191,6 @@
]
},
{
"direction": "input",
"maxConnectionsCount": -1,
"name": "cs_s1_mint_in_1",
"direction": "input",
"maxConnectionsCount": -1,
"name": "cs_s1_mint_in_1",
Expand All @@ -257,13 +209,15 @@
"interfaces": [
{
"direction": "output",
"maxConnectionsCount": -1,
"name": "cs_s1_f_int_out_2",
"type": [
"port"
]
},
{
"direction": "input",
"maxConnectionsCount": -1,
"name": "cs_s1_mint_in_2",
"type": [
"port"
Expand All @@ -287,7 +241,8 @@
"interfaces": [
{
"direction": "input",
"name": "cs_s2_f_int_in_1",
"maxConnectionsCount": -1,
"name": "cs_s2_f_int_in_2",
"type": [
"port"
]
Expand All @@ -296,22 +251,22 @@
"direction": "output",
"maxConnectionsCount": -1,
"name": "cs_s2_mint_out_2",
"maxConnectionsCount": -1,
"name": "cs_s2_mint_out_2",
"type": [
"port"
]
},
{
"direction": "input",
"name": "cs_s2_f_int_in_2",
"direction": "output",
"maxConnectionsCount": -1,
"name": "cs_s2_mint_out_1",
"type": [
"port"
]
},
{
"direction": "output",
"name": "cs_s2_mint_out_2",
"direction": "input",
"maxConnectionsCount": -1,
"name": "cs_s2_f_int_in_1",
"type": [
"port"
]
Expand All @@ -326,23 +281,22 @@
"category": "IPcore",
"interfaces": [
{
"direction": "input",
"name": "cs_s2_mint_in_1",
"direction": "output",
"maxConnectionsCount": -1,
"name": "cs_s2_f_mod_out_1",
"type": [
"port"
]
},
{
"direction": "input",
"maxConnectionsCount": -1,
"name": "cs_s2_mint_in_2",
"type": [
"port"
]
},
{
"direction": "input",
"maxConnectionsCount": -1,
"name": "cs_s2_mint_in_1",
"direction": "input",
"maxConnectionsCount": -1,
"name": "cs_s2_mint_in_1",
Expand All @@ -361,7 +315,6 @@
{
"direction": "input",
"maxConnectionsCount": -1,
"maxConnectionsCount": -1,
"name": "external",
"type": [
"port"
Expand All @@ -385,7 +338,6 @@
{
"direction": "output",
"maxConnectionsCount": -1,
"maxConnectionsCount": -1,
"name": "external",
"type": [
"port"
Expand All @@ -409,7 +361,6 @@
{
"direction": "inout",
"maxConnectionsCount": -1,
"maxConnectionsCount": -1,
"name": "external",
"type": [
"port"
Expand All @@ -433,7 +384,6 @@
{
"direction": "output",
"maxConnectionsCount": -1,
"maxConnectionsCount": -1,
"name": "constant",
"type": [
"port"
Expand All @@ -450,30 +400,6 @@
}
]
},
{
"abstract": false,
"category": "Metanode",
"interfaces": [
{
"direction": "output",
"maxConnectionsCount": -1,
"name": "subgraph out",
"type": [
"port"
]
},
{
"direction": "input",
"maxConnectionsCount": -1,
"name": "subgraph in",
"type": [
"port"
]
}
],
"layer": "Subgraph port",
"name": "Subgraph port"
},
{
"abstract": false,
"category": "Metanode",
Expand Down
20 changes: 4 additions & 16 deletions tests/tests_kpm/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,21 @@

import json
from pathlib import Path
from typing import Union

import yaml

from topwrap.design import DesignDescription
from topwrap.util import JsonType

AXI_NAME = "axi_bridge"
PS7_NAME = "ps7"
PWM_NAME = "litex_pwm_top"
TEST_DATA_PATH = "tests/data/data_kpm/examples/"
TEST_DATA_PATH = "tests/data/data_kpm/"


def read_json_file(json_file_path: Union[str, Path]) -> dict:
def read_json_file(json_file_path: Path) -> JsonType:
with open(json_file_path, "r") as json_file:
json_contents = json.load(json_file)
return json_contents


def read_yaml_file(yaml_file_path: Union[str, Path]) -> DesignDescription:
return DesignDescription.load(yaml_file_path)


def save_file_to_json(file_path: Path, file_name: str, file_content: dict):
def save_file_to_json(file_path: Path, file_name: str, file_content: JsonType):
with open(Path(file_path / file_name), "w") as json_file:
json.dump(file_content, json_file)


def save_file_to_yaml(file_path: Path, file_name: str, file_content: dict):
with open(Path(file_path / file_name), "w") as yaml_file:
yaml_file.write(yaml.safe_dump(file_content, sort_keys=True))
Loading

0 comments on commit a918cab

Please sign in to comment.