Skip to content

Commit 8da8c9e

Browse files
committed
[topgen,rtl] Fix param handling for AlertSkewCycles for alert_handler
Previously AlertSkewCycles is only set for modules that have alert_connections. However, the alert handler itself does not have alert_connections, so it was not getting the AlertSkewCycles parameter set. Thus the alert handler was using the default value of 1, causing an inconsistency if the parameter was set to a different value. This commit fixes this by adding AlertSkewCycles to the alert handler parameters. Signed-off-by: Robert Schilling <[email protected]>
1 parent 0dde10c commit 8da8c9e

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

hw/top_darjeeling/rtl/autogen/top_darjeeling.sv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,7 @@ module top_darjeeling #(
13491349
.rst_kmac_ni (rstmgr_aon_resets.rst_lc_n[rstmgr_pkg::Domain0Sel])
13501350
);
13511351
alert_handler #(
1352+
.AlertSkewCycles(top_pkg::AlertSkewCycles),
13521353
.RndCnstLfsrSeed(RndCnstAlertHandlerLfsrSeed),
13531354
.RndCnstLfsrPerm(RndCnstAlertHandlerLfsrPerm),
13541355
.EscNumSeverities(AlertHandlerEscNumSeverities),

hw/top_darjeeling/templates/toplevel.sv.tpl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -515,16 +515,13 @@ max_sigwidth = max(len(x.name) for x in port_list) if port_list else 0
515515
max_intrwidth = (max(len(x.name) for x in block.interrupts)
516516
if block.interrupts else 0)
517517
alert_info = top["alert_connections"].get("module_" + m["name"], {})
518+
has_params, param_items = lib.get_params(top, m)
518519
%>\
519-
% if m["param_list"] or alert_info or m.get("racl_mappings"):
520+
% if has_params:
520521
${m["type"]} #(
521522
<%include file="/toplevel_racl_parameters.tpl" args="module=m,top=top,block=block"/>\
522-
% if alert_info:
523-
.AlertAsyncOn(${alert_info["async_expr"]}),
524-
.AlertSkewCycles(top_pkg::AlertSkewCycles)${"," if m["param_list"] else ""}
525-
% endif
526-
% for i in m["param_list"]:
527-
.${i["name"]}(${i["name_top" if i.get("expose") == "true" or i.get("randtype", "none") != "none" else "default"]})${"," if not loop.last else ""}
523+
% for param_name, param_value in param_items:
524+
${param_name}(${param_value})${"," if not loop.last else ""}
528525
% endfor
529526
) u_${m["name"]} (
530527
% else:

hw/top_earlgrey/rtl/autogen/top_earlgrey.sv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,7 @@ module top_earlgrey #(
16931693
.rst_kmac_ni (rstmgr_aon_resets.rst_lc_n[rstmgr_pkg::Domain0Sel])
16941694
);
16951695
alert_handler #(
1696+
.AlertSkewCycles(top_pkg::AlertSkewCycles),
16961697
.RndCnstLfsrSeed(RndCnstAlertHandlerLfsrSeed),
16971698
.RndCnstLfsrPerm(RndCnstAlertHandlerLfsrPerm),
16981699
.EscNumSeverities(AlertHandlerEscNumSeverities),

hw/top_earlgrey/templates/toplevel.sv.tpl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,16 +488,13 @@ max_sigwidth = max(len(x.name) for x in port_list) if port_list else 0
488488
max_intrwidth = (max(len(x.name) for x in block.interrupts)
489489
if block.interrupts else 0)
490490
alert_info = top["alert_connections"].get("module_" + m["name"], {})
491+
has_params, param_items = lib.get_params(top, m)
491492
%>\
492-
% if m["param_list"] or alert_info or m.get("racl_mappings"):
493+
% if has_params:
493494
${m["type"]} #(
494495
<%include file="/toplevel_racl_parameters.tpl" args="module=m,top=top,block=block"/>\
495-
% if alert_info:
496-
.AlertAsyncOn(${alert_info["async_expr"]}),
497-
.AlertSkewCycles(top_pkg::AlertSkewCycles)${"," if m["param_list"] else ""}
498-
% endif
499-
% for i in m["param_list"]:
500-
.${i["name"]}(${i["name_top" if i.get("expose") == "true" or i.get("randtype", "none") != "none" else "default"]})${"," if not loop.last else ""}
496+
% for param_name, param_value in param_items:
497+
${param_name}(${param_value})${"," if not loop.last else ""}
501498
% endfor
502499
) u_${m["name"]} (
503500
% else:

util/topgen/lib.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from basegen.typing import ConfigT, ParamsT
1717
from mako.template import Template
1818
from reggen.ip_block import IpBlock
19+
from reggen.lib import check_bool
1920
from version_file import VersionInformation
2021

2122
# Ignore flake8 warning as the function is used in the template
@@ -760,6 +761,27 @@ def get_io_enum_literal(sig: Dict, prefix: str) -> str:
760761
return name.as_camel_case()
761762

762763

764+
def get_params(top: ConfigT, module: ConfigT) -> List[str]:
765+
"""Return the parameters for a given module including implicit parameters
766+
but excluding RACL parameters, which are handled in a separate template.
767+
"""
768+
param_items = []
769+
alert_info = top["alert_connections"].get("module_" + module["name"], {})
770+
has_racl_params = bool(module.get("racl_mappings"))
771+
if alert_info:
772+
param_items.append((".AlertAsyncOn", alert_info["async_expr"]))
773+
if alert_info or module.get("template_type") == "alert_handler":
774+
param_items.append((".AlertSkewCycles", "top_pkg::AlertSkewCycles"))
775+
for param in module["param_list"]:
776+
is_exposed = check_bool(param.get("expose", False), f"expose field of {param['name']}")
777+
has_random_type = param.get("randtype")
778+
param_key = "name_top" if (is_exposed or has_random_type) else "default"
779+
param_items.append((f".{param['name']}", param[param_key]))
780+
781+
has_params = has_racl_params or len(param_items) > 0
782+
return has_params, param_items
783+
784+
763785
def make_bit_concatenation(sig_name: str, indices: List[int],
764786
end_indent: int) -> str:
765787
'''Return SV code for concatenating certain indices from a signal

0 commit comments

Comments
 (0)