Fix hwif type name generation to properly handle parameterized component names. #70
This commit is contained in:
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@@ -23,6 +23,7 @@ jobs:
|
|||||||
- 3.9
|
- 3.9
|
||||||
- "3.10"
|
- "3.10"
|
||||||
- "3.11"
|
- "3.11"
|
||||||
|
- "3.12"
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
|
|
||||||
|
|||||||
@@ -13,3 +13,5 @@ sphinx:
|
|||||||
python:
|
python:
|
||||||
install:
|
install:
|
||||||
- requirements: docs/requirements.txt
|
- requirements: docs/requirements.txt
|
||||||
|
- method: pip
|
||||||
|
path: .
|
||||||
|
|||||||
3
setup.py
3
setup.py
@@ -24,7 +24,7 @@ setuptools.setup(
|
|||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
python_requires='>=3.6',
|
python_requires='>=3.6',
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"systemrdl-compiler >= 1.25.1, < 2",
|
"systemrdl-compiler >= 1.27.0, < 2",
|
||||||
"Jinja2>=2.11",
|
"Jinja2>=2.11",
|
||||||
],
|
],
|
||||||
entry_points = {
|
entry_points = {
|
||||||
@@ -43,6 +43,7 @@ setuptools.setup(
|
|||||||
"Programming Language :: Python :: 3.9",
|
"Programming Language :: Python :: 3.9",
|
||||||
"Programming Language :: Python :: 3.10",
|
"Programming Language :: Python :: 3.10",
|
||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.11",
|
||||||
|
"Programming Language :: Python :: 3.12",
|
||||||
"Programming Language :: Python :: 3 :: Only",
|
"Programming Language :: Python :: 3 :: Only",
|
||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
||||||
|
|||||||
@@ -230,41 +230,35 @@ class OutputStructGenerator_Hier(HWIFStructGenerator):
|
|||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
class InputStructGenerator_TypeScope(InputStructGenerator_Hier):
|
class InputStructGenerator_TypeScope(InputStructGenerator_Hier):
|
||||||
def get_typdef_name(self, node:'Node') -> str:
|
def get_typdef_name(self, node:'Node') -> str:
|
||||||
scope_path = node.inst.get_scope_path("__")
|
scope_path = node.get_global_type_name("__")
|
||||||
if scope_path is None:
|
if scope_path is None:
|
||||||
# Unable to determine a reusable type name. Fall back to hierarchical path
|
# Unable to determine a reusable type name. Fall back to hierarchical path
|
||||||
# Add prefix to prevent collision when mixing namespace methods
|
# Add prefix to prevent collision when mixing namespace methods
|
||||||
scope_path = "xtern__" + super().get_typdef_name(node)
|
scope_path = "xtern__" + super().get_typdef_name(node)
|
||||||
|
|
||||||
if isinstance(node, FieldNode):
|
if node.external:
|
||||||
extra_suffix = get_field_type_name_suffix(node)
|
# Node generates alternate external signals
|
||||||
|
extra_suffix = "__external"
|
||||||
else:
|
else:
|
||||||
extra_suffix = ""
|
extra_suffix = ""
|
||||||
|
|
||||||
if node.external:
|
return f'{scope_path}{extra_suffix}__in_t'
|
||||||
# Node generates alternate external signals
|
|
||||||
extra_suffix += "__external"
|
|
||||||
|
|
||||||
return f'{scope_path}__{node.type_name}{extra_suffix}__in_t'
|
|
||||||
|
|
||||||
class OutputStructGenerator_TypeScope(OutputStructGenerator_Hier):
|
class OutputStructGenerator_TypeScope(OutputStructGenerator_Hier):
|
||||||
def get_typdef_name(self, node:'Node') -> str:
|
def get_typdef_name(self, node:'Node') -> str:
|
||||||
scope_path = node.inst.get_scope_path("__")
|
scope_path = node.get_global_type_name("__")
|
||||||
if scope_path is None:
|
if scope_path is None:
|
||||||
# Unable to determine a reusable type name. Fall back to hierarchical path
|
# Unable to determine a reusable type name. Fall back to hierarchical path
|
||||||
# Add prefix to prevent collision when mixing namespace methods
|
# Add prefix to prevent collision when mixing namespace methods
|
||||||
scope_path = "xtern__" + super().get_typdef_name(node)
|
scope_path = "xtern__" + super().get_typdef_name(node)
|
||||||
|
|
||||||
if isinstance(node, FieldNode):
|
if node.external:
|
||||||
extra_suffix = get_field_type_name_suffix(node)
|
# Node generates alternate external signals
|
||||||
|
extra_suffix = "__external"
|
||||||
else:
|
else:
|
||||||
extra_suffix = ""
|
extra_suffix = ""
|
||||||
|
|
||||||
if node.external:
|
return f'{scope_path}{extra_suffix}__out_t'
|
||||||
# Node generates alternate external signals
|
|
||||||
extra_suffix += "__external"
|
|
||||||
|
|
||||||
return f'{scope_path}__{node.type_name}{extra_suffix}__out_t'
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
class EnumGenerator:
|
class EnumGenerator:
|
||||||
@@ -302,26 +296,3 @@ class EnumGenerator:
|
|||||||
+ ",\n".join(lines)
|
+ ",\n".join(lines)
|
||||||
+ f"\n}} {prefix}_e;"
|
+ f"\n}} {prefix}_e;"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_field_type_name_suffix(field: FieldNode) -> str:
|
|
||||||
"""
|
|
||||||
Fields may reuse the same type, but end up instantiating different widths
|
|
||||||
Uniquify the type name further if the field width was overridden when instantiating
|
|
||||||
"""
|
|
||||||
if field.inst.original_def is None:
|
|
||||||
return ""
|
|
||||||
|
|
||||||
if field.inst.original_def.type_name is None:
|
|
||||||
# is an anonymous definition. No extra suffix needed
|
|
||||||
return ""
|
|
||||||
|
|
||||||
if "fieldwidth" in field.list_properties():
|
|
||||||
# fieldwidth was explicitly set. This type name is already sufficiently distinct
|
|
||||||
return ""
|
|
||||||
|
|
||||||
if field.width == 1:
|
|
||||||
# field width is the default. Skip suffix
|
|
||||||
return ""
|
|
||||||
|
|
||||||
return f"_w{field.width}"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user