Skip to content

Commit

Permalink
[topgen] Deepcopy parameter when mangeling
Browse files Browse the repository at this point in the history
Otherwise, the same parameter of a difference instance
would be overwritten

Signed-off-by: Robert Schilling <[email protected]>
  • Loading branch information
Razer6 committed Dec 14, 2024
1 parent 0f7d95f commit f4bd3f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 13 additions & 2 deletions util/topgen/intermodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,19 @@ def check_intermodule(topcfg: Dict, prefix: str) -> int:
err, rsp_struct = check_intermodule_field(rsp_struct)
error += err

total_width += rsp_struct["width"]
widths.append(rsp_struct["width"])
if isinstance(rsp_struct["width"], Parameter):
param = rsp_struct["width"]
if param.expose:
# If it's a top-level exposed parameter, we need to find definition from there
module = lib.get_module_by_name(topcfg, req_m)
width = int(module['param_decl'].get(param.name, rsp_struct["width"].default))
else:
width = int(req_struct["width"].default)
else:
width = rsp_struct["width"]

total_width += width
widths.append(width)

# Type check
# If no package was declared, it is declared with an empty string
Expand Down
5 changes: 5 additions & 0 deletions util/topgen/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ def elaborate_instance(instance, block: IpBlock):
if isinstance(s['width'], Parameter):
for p in instance["param_list"]:
if p['name'] == s['width'].name:
# When mangeling the name, we first need to deep copy the param. Otherwise, we
# reference always the same single parameter. If there are multiple instances
# having the same parameter, we would overwrite the previously mangled param
# of another instance
s['width'] = deepcopy(s['width'])
s['width'].name_top = p['name_top']

# An instance must either have a 'base_addr' address or a 'base_addrs'
Expand Down

0 comments on commit f4bd3f1

Please sign in to comment.