diff --git a/hw/ip_templates/clkmgr/data/clkmgr.tpldesc.hjson b/hw/ip_templates/clkmgr/data/clkmgr.tpldesc.hjson index 804e71ee7dad7..e105c99a88c09 100644 --- a/hw/ip_templates/clkmgr/data/clkmgr.tpldesc.hjson +++ b/hw/ip_templates/clkmgr/data/clkmgr.tpldesc.hjson @@ -104,5 +104,11 @@ type: "string" default: "lowrisc:constants:top_pkg" } + { + name: "module_instance_name" + desc: "instance name in case there are multiple clkmgr instances. Not yet implemented." + type: "string" + default: "clkmgr" + } ] } diff --git a/hw/ip_templates/flash_ctrl/data/flash_ctrl.tpldesc.hjson b/hw/ip_templates/flash_ctrl/data/flash_ctrl.tpldesc.hjson index 809b1910c0a0c..3ffe98447ef1b 100644 --- a/hw/ip_templates/flash_ctrl/data/flash_ctrl.tpldesc.hjson +++ b/hw/ip_templates/flash_ctrl/data/flash_ctrl.tpldesc.hjson @@ -99,5 +99,11 @@ type: "string" default: "lowrisc:constants:top_pkg" } + { + name: "module_instance_name" + desc: "instance name in case there are multiple flash_ctrl instances. Not yet implemented." + type: "string" + default: "flash_ctrl" + } ] } diff --git a/hw/ip_templates/otp_ctrl/data/otp_ctrl.tpldesc.hjson b/hw/ip_templates/otp_ctrl/data/otp_ctrl.tpldesc.hjson index e0ff61c40848c..bad1445ec4271 100644 --- a/hw/ip_templates/otp_ctrl/data/otp_ctrl.tpldesc.hjson +++ b/hw/ip_templates/otp_ctrl/data/otp_ctrl.tpldesc.hjson @@ -15,5 +15,11 @@ type: "object" default: {} } + { + name: "module_instance_name" + desc: "instance name in case there are multiple otp_ctrl instances. Not yet implemented." + type: "string" + default: "otp_ctrl" + } ] } diff --git a/hw/ip_templates/pinmux/data/pinmux.tpldesc.hjson b/hw/ip_templates/pinmux/data/pinmux.tpldesc.hjson index 22c122c2a03f6..e9f1e5b503016 100644 --- a/hw/ip_templates/pinmux/data/pinmux.tpldesc.hjson +++ b/hw/ip_templates/pinmux/data/pinmux.tpldesc.hjson @@ -81,5 +81,11 @@ type: "string" default: "lowrisc:systems:scan_role_pkg" } + { + name: "module_instance_name" + desc: "instance name in case there are multiple pinmux instances. Not yet implemented." + type: "string" + default: "pinmux" + } ] } diff --git a/hw/ip_templates/pwrmgr/data/pwrmgr.tpldesc.hjson b/hw/ip_templates/pwrmgr/data/pwrmgr.tpldesc.hjson index 6ecd13331e956..80c9314168d6f 100644 --- a/hw/ip_templates/pwrmgr/data/pwrmgr.tpldesc.hjson +++ b/hw/ip_templates/pwrmgr/data/pwrmgr.tpldesc.hjson @@ -70,5 +70,11 @@ type: "string" default: "lowrisc:constants:top_pkg" } + { + name: "module_instance_name" + desc: "instance name in case there are multiple pwrmgr instances. Not yet implemented." + type: "string" + default: "pwrmgr" + } ] } diff --git a/hw/ip_templates/rstmgr/data/rstmgr.tpldesc.hjson b/hw/ip_templates/rstmgr/data/rstmgr.tpldesc.hjson index 31e6f7fe55ef3..c7ca4bc30ed7c 100644 --- a/hw/ip_templates/rstmgr/data/rstmgr.tpldesc.hjson +++ b/hw/ip_templates/rstmgr/data/rstmgr.tpldesc.hjson @@ -135,5 +135,11 @@ type: "string" default: "lowrisc:constants:top_pkg" } + { + name: "module_instance_name" + desc: "instance name in case there are multiple pwrmgr instances. Not yet implemented." + type: "string" + default: "pwrmgr" + } ] } diff --git a/hw/top_darjeeling/data/autogen/top_darjeeling.gen.hjson b/hw/top_darjeeling/data/autogen/top_darjeeling.gen.hjson index 9a0d2e4753f0b..16a106b53bd80 100644 --- a/hw/top_darjeeling/data/autogen/top_darjeeling.gen.hjson +++ b/hw/top_darjeeling/data/autogen/top_darjeeling.gen.hjson @@ -1020,6 +1020,7 @@ { name: otp_ctrl type: otp_ctrl + template_type: otp_ctrl clock_srcs: { clk_i: io_div4 @@ -2127,6 +2128,7 @@ { name: alert_handler type: alert_handler + template_type: alert_handler clock_srcs: { clk_i: io_div4 @@ -2357,6 +2359,7 @@ { name: pwrmgr_aon type: pwrmgr + template_type: pwrmgr clock_group: powerup clock_srcs: { @@ -2721,6 +2724,7 @@ { name: rstmgr_aon type: rstmgr + template_type: rstmgr clock_srcs: { clk_i: @@ -2925,6 +2929,7 @@ { name: clkmgr_aon type: clkmgr + template_type: clkmgr clock_srcs: { clk_i: io_div4 @@ -3260,6 +3265,7 @@ { name: pinmux_aon type: pinmux + template_type: pinmux clock_srcs: { clk_i: io_div4 @@ -4553,6 +4559,7 @@ { name: rv_plic type: rv_plic + template_type: rv_plic clock_srcs: { clk_i: main diff --git a/hw/top_darjeeling/data/top_darjeeling.hjson b/hw/top_darjeeling/data/top_darjeeling.hjson index 1853a35388671..fc167648973dd 100644 --- a/hw/top_darjeeling/data/top_darjeeling.hjson +++ b/hw/top_darjeeling/data/top_darjeeling.hjson @@ -313,6 +313,7 @@ }, { name: "otp_ctrl", type: "otp_ctrl", + template_type: "otp_ctrl", clock_srcs: {clk_i: "io_div4", clk_edn_i: "main"}, clock_group: "secure", reset_connections: {rst_ni: "lc_io_div4", rst_edn_ni: "lc"}, @@ -349,6 +350,7 @@ }, { name: "alert_handler", type: "alert_handler", + template_type: "alert_handler", clock_srcs: {clk_i: "io_div4", clk_edn_i: "main"}, clock_group: "secure", reset_connections: {rst_ni: "lc_io_div4", rst_edn_ni: "lc"}, @@ -368,6 +370,7 @@ }, { name: "pwrmgr_aon", type: "pwrmgr", + template_type: "pwrmgr", // TODO: RS, fix after pwrmgr fix is merged // param_decl: { // PwrFsmWaitForExtRst: "1" @@ -413,6 +416,7 @@ }, { name: "rstmgr_aon", type: "rstmgr", + template_type: "rstmgr", clock_srcs: { clk_i: { clock: "io_div4", @@ -440,6 +444,7 @@ }, { name: "clkmgr_aon", type: "clkmgr", + template_type: "clkmgr", clock_srcs: { clk_i: "io_div4", clk_main_i: { @@ -482,6 +487,7 @@ }, { name: "pinmux_aon", type: "pinmux", + template_type: "pinmux", clock_srcs: {clk_i: "io_div4", clk_aon_i: "aon"}, clock_group: "powerup", reset_connections: {rst_ni: "lc_io_div4", @@ -646,6 +652,7 @@ }, { name: "rv_plic", type: "rv_plic", + template_type: "rv_plic", clock_srcs: {clk_i: "main"}, clock_group: "secure", reset_connections: {rst_ni: "lc"}, diff --git a/hw/top_darjeeling/ip_autogen/rv_plic/data/top_darjeeling_rv_plic.ipconfig.hjson b/hw/top_darjeeling/ip_autogen/rv_plic/data/top_darjeeling_rv_plic.ipconfig.hjson index e5d1b0f7f5875..e2fb869e650b3 100644 --- a/hw/top_darjeeling/ip_autogen/rv_plic/data/top_darjeeling_rv_plic.ipconfig.hjson +++ b/hw/top_darjeeling/ip_autogen/rv_plic/data/top_darjeeling_rv_plic.ipconfig.hjson @@ -8,6 +8,7 @@ src: 158 target: 1 prio: 3 + module_instance_name: rv_plic topname: darjeeling } } diff --git a/hw/top_darjeeling/templates/toplevel.sv.tpl b/hw/top_darjeeling/templates/toplevel.sv.tpl index d709609bbb677..4d95b582c6290 100644 --- a/hw/top_darjeeling/templates/toplevel.sv.tpl +++ b/hw/top_darjeeling/templates/toplevel.sv.tpl @@ -329,7 +329,7 @@ module top_${top["name"]} #( ## Inter-module signal collection % for m in top["module"]: - % if m["type"] == "otp_ctrl": + % if m.get("template_type") == "otp_ctrl": // OTP HW_CFG Broadcast signals. // TODO(#6713): The actual struct breakout and mapping currently needs to // be performed by hand. @@ -562,10 +562,10 @@ slice = f"{lo+w-1}:{lo}" % endif % endfor % endif - % if m["type"] == "rv_plic": + % if m.get("template_type") == "rv_plic": .intr_src_i (intr_vector), % endif - % if m["type"] == "pinmux": + % if m.get("template_type") == "pinmux": .periph_to_mio_i (mio_d2p ), .periph_to_mio_oe_i (mio_en_d2p ), @@ -586,7 +586,7 @@ slice = f"{lo+w-1}:{lo}" .dio_in_i, % endif - % if m["type"] == "alert_handler": + % if m.get("template_type") == "alert_handler": // alert signals .alert_rx_o ( alert_rx ), .alert_tx_i ( alert_tx ), diff --git a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson index 0eec4ff0ceac8..764decea9a211 100644 --- a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson +++ b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson @@ -1505,6 +1505,7 @@ { name: otp_ctrl type: otp_ctrl + template_type: otp_ctrl clock_srcs: { clk_i: io_div4 @@ -2613,6 +2614,7 @@ { name: alert_handler type: alert_handler + template_type: alert_handler clock_srcs: { clk_i: io_div4 @@ -3252,6 +3254,7 @@ { name: pwrmgr_aon type: pwrmgr + template_type: pwrmgr clock_group: powerup clock_srcs: { @@ -3602,6 +3605,7 @@ { name: rstmgr_aon type: rstmgr + template_type: rstmgr clock_srcs: { clk_i: @@ -3806,6 +3810,7 @@ { name: clkmgr_aon type: clkmgr + template_type: clkmgr clock_srcs: { clk_i: io_div4 @@ -4365,6 +4370,7 @@ { name: pinmux_aon type: pinmux + template_type: pinmux clock_srcs: { clk_i: io_div4 @@ -5458,6 +5464,7 @@ { name: flash_ctrl type: flash_ctrl + template_type: flash_ctrl clock_srcs: { clk_i: main @@ -6269,6 +6276,7 @@ { name: rv_plic type: rv_plic + template_type: rv_plic clock_srcs: { clk_i: main diff --git a/hw/top_earlgrey/data/top_earlgrey.hjson b/hw/top_earlgrey/data/top_earlgrey.hjson index b7b85ee89586c..b71b5c0fc1336 100644 --- a/hw/top_earlgrey/data/top_earlgrey.hjson +++ b/hw/top_earlgrey/data/top_earlgrey.hjson @@ -394,6 +394,7 @@ }, { name: "otp_ctrl", type: "otp_ctrl", + template_type: "otp_ctrl", clock_srcs: {clk_i: "io_div4", clk_edn_i: "main"}, clock_group: "secure", reset_connections: {rst_ni: "lc_io_div4", rst_edn_ni: "lc"}, @@ -427,6 +428,7 @@ }, { name: "alert_handler", type: "alert_handler", + template_type: "alert_handler", clock_srcs: {clk_i: "io_div4", clk_edn_i: "main"}, clock_group: "secure", reset_connections: {rst_ni: "lc_io_div4", rst_edn_ni: "lc"}, @@ -467,6 +469,7 @@ }, { name: "pwrmgr_aon", type: "pwrmgr", + template_type: "pwrmgr", clock_group: "powerup", clock_srcs: { clk_i: "io_div4", @@ -507,6 +510,7 @@ }, { name: "rstmgr_aon", type: "rstmgr", + template_type: "rstmgr", clock_srcs: { clk_i: { clock: "io_div4", @@ -534,6 +538,7 @@ }, { name: "clkmgr_aon", type: "clkmgr", + template_type: "clkmgr", clock_srcs: { clk_i: "io_div4", clk_main_i: { @@ -606,6 +611,7 @@ }, { name: "pinmux_aon", type: "pinmux", + template_type: "pinmux", clock_srcs: {clk_i: "io_div4", clk_aon_i: "aon"}, clock_group: "powerup", reset_connections: {rst_ni: "lc_io_div4", @@ -735,6 +741,7 @@ }, { name: "flash_ctrl", type: "flash_ctrl", + template_type: "flash_ctrl", clock_srcs: {clk_i: "main", clk_otp_i: "io_div4"}, clock_group: "infra", reset_connections: {rst_ni: "lc", rst_otp_ni: "lc_io_div4"}, @@ -781,6 +788,7 @@ }, { name: "rv_plic", type: "rv_plic", + template_type: "rv_plic", clock_srcs: {clk_i: "main"}, clock_group: "secure", reset_connections: {rst_ni: "lc"}, diff --git a/hw/top_earlgrey/ip_autogen/rv_plic/data/top_earlgrey_rv_plic.ipconfig.hjson b/hw/top_earlgrey/ip_autogen/rv_plic/data/top_earlgrey_rv_plic.ipconfig.hjson index a820acf1b8b76..e0a315793c183 100644 --- a/hw/top_earlgrey/ip_autogen/rv_plic/data/top_earlgrey_rv_plic.ipconfig.hjson +++ b/hw/top_earlgrey/ip_autogen/rv_plic/data/top_earlgrey_rv_plic.ipconfig.hjson @@ -8,6 +8,7 @@ src: 186 target: 1 prio: 3 + module_instance_name: rv_plic topname: earlgrey } } diff --git a/hw/top_earlgrey/templates/toplevel.sv.tpl b/hw/top_earlgrey/templates/toplevel.sv.tpl index 1de7bb9ee2b3f..1dd9ed3e854c8 100644 --- a/hw/top_earlgrey/templates/toplevel.sv.tpl +++ b/hw/top_earlgrey/templates/toplevel.sv.tpl @@ -328,7 +328,7 @@ module top_${top["name"]} #( ## Inter-module signal collection % for m in top["module"]: - % if m["type"] == "otp_ctrl": + % if m.get("template_type") == "otp_ctrl": // OTP HW_CFG* Broadcast signals. // TODO(#6713): The actual struct breakout and mapping currently needs to // be performed by hand. @@ -581,10 +581,10 @@ slice = f"{lo+w-1}:{lo}" % endif % endfor % endif - % if m["type"] == "rv_plic": + % if m.get("template_type") == "rv_plic": .intr_src_i (intr_vector), % endif - % if m["type"] == "pinmux": + % if m.get("template_type") == "pinmux": .periph_to_mio_i (mio_d2p ), .periph_to_mio_oe_i (mio_en_d2p ), @@ -605,7 +605,7 @@ slice = f"{lo+w-1}:{lo}" .dio_in_i, % endif - % if m["type"] == "alert_handler": + % if m.get("template_type") == "alert_handler": // alert signals .alert_rx_o ( alert_rx ), .alert_tx_i ( alert_tx ), diff --git a/hw/top_englishbreakfast/data/autogen/top_englishbreakfast.gen.hjson b/hw/top_englishbreakfast/data/autogen/top_englishbreakfast.gen.hjson index 04f4382e438c3..20bbed911ad86 100644 --- a/hw/top_englishbreakfast/data/autogen/top_englishbreakfast.gen.hjson +++ b/hw/top_englishbreakfast/data/autogen/top_englishbreakfast.gen.hjson @@ -1282,6 +1282,7 @@ { name: pwrmgr_aon type: pwrmgr + template_type: pwrmgr clock_srcs: { clk_i: io_div4 @@ -1609,6 +1610,7 @@ { name: rstmgr_aon type: rstmgr + template_type: rstmgr clock_srcs: { clk_i: io_div4 @@ -1809,6 +1811,7 @@ { name: clkmgr_aon type: clkmgr + template_type: clkmgr clock_srcs: { clk_i: io_div4 @@ -2135,6 +2138,7 @@ { name: pinmux_aon type: pinmux + template_type: pinmux clock_srcs: { clk_i: io_div4 @@ -2771,6 +2775,7 @@ { name: flash_ctrl type: flash_ctrl + template_type: flash_ctrl clock_srcs: { clk_i: main @@ -3187,6 +3192,7 @@ { name: rv_plic type: rv_plic + template_type: rv_plic clock_srcs: { clk_i: main diff --git a/hw/top_englishbreakfast/data/top_englishbreakfast.hjson b/hw/top_englishbreakfast/data/top_englishbreakfast.hjson index f6f7b37c36314..65d2ad112c70b 100644 --- a/hw/top_englishbreakfast/data/top_englishbreakfast.hjson +++ b/hw/top_englishbreakfast/data/top_englishbreakfast.hjson @@ -316,6 +316,7 @@ }, { name: "pwrmgr_aon", type: "pwrmgr", + template_type: "pwrmgr", clock_srcs: {clk_i: "io_div4", clk_slow_i: "aon", clk_lc_i: "io_div4", clk_esc_i: "io_div4"}, clock_group: "powerup", reset_connections: { @@ -334,6 +335,7 @@ }, { name: "rstmgr_aon", type: "rstmgr", + template_type: "rstmgr", clock_srcs: {clk_i: "io_div4", clk_por_i: "io_div4", clk_aon_i: "aon", clk_main_i: "main", clk_io_i: "io", clk_usb_i: "usb", clk_io_div2_i: "io_div2", clk_io_div4_i: "io_div4"}, clock_group: "powerup", @@ -349,6 +351,7 @@ }, { name: "clkmgr_aon", type: "clkmgr", + template_type: "clkmgr", clock_srcs: { clk_i: "io_div4", clk_main_i: { @@ -391,6 +394,7 @@ }, { name: "pinmux_aon", type: "pinmux", + template_type: "pinmux", clock_srcs: {clk_i: "io_div4", clk_aon_i: "aon"}, clock_group: "powerup", reset_connections: {rst_ni: "lc_io_div4", @@ -442,6 +446,7 @@ }, { name: "flash_ctrl", type: "flash_ctrl", + template_type: "flash_ctrl", clock_srcs: {clk_i: "main", clk_otp_i: "io_div4"}, clock_group: "infra", reset_connections: {rst_ni: "lc", rst_otp_ni: "lc_io_div4"}, @@ -471,6 +476,7 @@ }, { name: "rv_plic", type: "rv_plic", + template_type: "rv_plic", clock_srcs: {clk_i: "main"}, clock_group: "secure", reset_connections: {rst_ni: "sys"}, diff --git a/hw/top_englishbreakfast/ip_autogen/rv_plic/data/top_englishbreakfast_rv_plic.ipconfig.hjson b/hw/top_englishbreakfast/ip_autogen/rv_plic/data/top_englishbreakfast_rv_plic.ipconfig.hjson index 98e41fca2ed07..bc75bb8b6b087 100644 --- a/hw/top_englishbreakfast/ip_autogen/rv_plic/data/top_englishbreakfast_rv_plic.ipconfig.hjson +++ b/hw/top_englishbreakfast/ip_autogen/rv_plic/data/top_englishbreakfast_rv_plic.ipconfig.hjson @@ -8,6 +8,7 @@ src: 88 target: 1 prio: 3 + module_instance_name: rv_plic topname: englishbreakfast } } diff --git a/util/topgen.py b/util/topgen.py index cfe394c0b4047..97b2b90172670 100755 --- a/util/topgen.py +++ b/util/topgen.py @@ -258,6 +258,9 @@ def generate_plic(top: Dict[str, object], out_path: Path) -> None: topname = top["name"] params = {} + # Get the PLIC instance + plic = lib.find_module(top['module'], 'rv_plic') + # Count number of interrupts # Interrupt source 0 is tied to 0 to conform RISC-V PLIC spec. # So, total number of interrupts are the number of entries in the list + 1 @@ -267,6 +270,7 @@ def generate_plic(top: Dict[str, object], out_path: Path) -> None: # Target and priority: Currently fixed params["target"] = int(top["num_cores"], 0) if "num_cores" in top else 1 params["prio"] = 3 + params["module_instance_name"] = plic['type'] ipgen_render("rv_plic", topname, params, out_path) @@ -565,8 +569,11 @@ def generate_ac_range_check(topcfg: Dict[str, object], out_path: Path) -> None: log.info('Generating ac_range_check with ipgen') topname = topcfg['name'] + # Get the AC Range Check instance + ac_ranges = lib.find_module(topcfg['module'], 'ac_range_check') params = { - "num_ranges": topcfg['ac_range_check']['num_ranges'] + "num_ranges": topcfg['ac_range_check']['num_ranges'], + "module_instance_name": ac_ranges['type'] } ipgen_render("ac_range_check", topname, params, out_path) @@ -583,30 +590,26 @@ def generate_racl(topcfg: Dict[str, object], out_path: Path) -> None: log.info('Generating RACL Control IP with ipgen') topname = topcfg['name'] - for racl_group, policies in topcfg['racl']['policies'].items(): - params = { - "nr_role_bits": 4, - "nr_ctn_uid_bits": 8, - "nr_policies": len(policies), - "policies": policies - } - - # If we have more RACL policy groups, uniquify the control IP - # if len(topcfg['racl']['policies']) > 1: - # params['module_instance_name'] = f'racl_ctrl_{racl_group}' - - # # Only render the RACL groups that are really instantiated in that top - # for m in topcfg['module']: - # if m['name'] == params['module_instance_name']: - # ipgen_render("racl_ctrl", topname, params, out_path) - # break - # TODO(#25673): The obove code, would be the correct if ipgen correctly supports rendering - # multiple instances and allow topgen to instantiate right now. This support is not yet - # implemented properly. Therefore, simply render the first RACL group to the RACL control - # IP. - ipgen_render("racl_ctrl", topname, params, out_path) - break + # Get the AC Range Check instance + racl_ctrl = lib.find_module(topcfg['module'], 'racl_ctrl') + + if len(topcfg['racl']['policies']) == 1: + # If there is only one set of policies, take the first one + policies = list(topcfg['racl']['policies'].values())[0] + else: + # More than one policy, we need to find the matching set of policies + policies = topcfg['racl']['policies'][racl_group] + + params = { + "module_instance_name": racl_ctrl["type"], + "nr_role_bits": 4, + "nr_ctn_uid_bits": 5, + "nr_policies": len(policies), + "policies": policies + } + ipgen_render("racl_ctrl", topname, params, out_path) + def generate_top_only(top_only_dict: Dict[str, bool], out_path: Path, top_name: str, alt_hjson_path: str) -> None: @@ -846,17 +849,20 @@ 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) + template_type = ipgen_module['template_type'] log.info( f"To-be-generated Hjson {ip_desc_file} does not yet exist. " "Falling back to the default configuration of template " - f"{ip_name} for initial validation.") + f"{template_type} for initial validation.") log.info(f"Dealing with {ip_name} ipgen") - if ip_name == "otp_ctrl": + if template_type == "otp_ctrl": params = {"otp_mmap": get_params_for_otp_ctrl(cfg_path)} else: params = {} - tpl_path = IP_TEMPLATES_PATH / ip_name + params['module_instance_name'] = ip_name + tpl_path = IP_TEMPLATES_PATH / template_type ip_template = IpTemplate.from_template_path(tpl_path) ip_config = IpConfig(ip_template.params, f"{top_name}_{ip_name}", params) @@ -874,7 +880,7 @@ def _process_top( name_to_hjson[ip_name] = ip_desc_file ip_objs.append(IpBlock.from_path(str(ip_desc_file), [])) else: - log.error(f"Descrition file not found: {ip_desc_file}") + log.error(f"Description file not found: {ip_desc_file}") raise SystemExit(sys.exc_info()[1]) except ValueError: diff --git a/util/topgen/lib.py b/util/topgen/lib.py index 2a7906e42f604..133f495620269 100644 --- a/util/topgen/lib.py +++ b/util/topgen/lib.py @@ -855,6 +855,21 @@ def num_rom_ctrl(modules): def find_module(modules, type): + '''Returns the first module of a given type + For ipgen modules the base template type is used for matching + ''' + for m in modules: + if m.get('attr') == 'ipgen': + if m['template_type'] == type: + return m + else: + if m['type'] == type: + return m + + return None + + +def find_module_by_type(modules, type): '''Returns the first module of a given type ''' for m in modules: diff --git a/util/topgen/validate.py b/util/topgen/validate.py index da76461412ff0..c48f7a9403a8c 100644 --- a/util/topgen/validate.py +++ b/util/topgen/validate.py @@ -218,6 +218,9 @@ 'incoming_alert': ['l', 'optional list of paths to incoming alert configurations for the ' 'alert_handler'], 'incoming_interrupt': ['g', 'Parsed incoming interrupts (generated)'], + 'template_type': ['s', 'Base template type of ipgen IPs'], + 'racl_group': ['s', 'Only valid for racl_ctrl IPs. Defines the RACL group this control IP is ' + 'associated to'], } module_added = {