Skip to content

Commit

Permalink
[topgen] Merge find_module and find_module_by_type
Browse files Browse the repository at this point in the history
find_module takes a new parameter use_base_template_type. If
set to true, the base template type used for ipgen-based IPs.
If set to False, the uniquified type is used for matching.

Signed-off-by: Robert Schilling <[email protected]>
  • Loading branch information
Razer6 authored and vogelpi committed Jan 23, 2025
1 parent f1f2e13 commit f9e37da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
3 changes: 2 additions & 1 deletion util/topgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,8 @@ def _process_top(
# of as soon as we don't arbitrarily template IP description Hjson
# files any more.
if ip_name in ipgen_list and not ip_desc_file.is_file():
ipgen_module = lib.find_module_by_type(topcfg['module'], ip_name)
ipgen_module = lib.find_module(topcfg['module'], ip_name,
use_base_template_type=False)
template_type = ipgen_module['template_type']
log.info(
f"To-be-generated Hjson {ip_desc_file} does not yet exist. "
Expand Down
18 changes: 5 additions & 13 deletions util/topgen/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,12 +854,14 @@ def num_rom_ctrl(modules):
return num


def find_module(modules, type):
def find_module(modules, type, use_base_template_type=True):
'''Returns the first module of a given type
For ipgen modules the base template type is used for matching
If use_base_template_type is set to True, ipgen-based modules are
matched based on the base template type. If set to False, the
uniquified type is matched,
'''
for m in modules:
if m.get('attr') == 'ipgen':
if m.get('attr') == 'ipgen' and use_base_template_type:
if m['template_type'] == type:
return m
else:
Expand All @@ -869,16 +871,6 @@ def find_module(modules, type):
return None


def find_module_by_type(modules, type):
'''Returns the first module of a given type
'''
for m in modules:
if m['type'] == type:
return m

return None


def get_addr_space(top, addr_space_name):
"""Returns the address dict for a given address space name"""
for addr_space in top['addr_spaces']:
Expand Down

0 comments on commit f9e37da

Please sign in to comment.