[topgen] Assign specified default to un-exposed parameters in top
With this commit, topgen drives un-exposed parameters with the default
value specified in the IP hjson, but still does not expose those
parameters to higher levels in the hierarchy.
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
diff --git a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
index ffd60f5..14510be 100644
--- a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
+++ b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
@@ -923,6 +923,14 @@
param_list:
[
{
+ name: AES192Enable
+ type: bit
+ default: 1'b1
+ local: "false"
+ expose: "false"
+ name_top: AesAES192Enable
+ }
+ {
name: Masking
type: bit
default: 1'b0
@@ -946,6 +954,14 @@
expose: "true"
name_top: SecAesStartTriggerDelay
}
+ {
+ name: AlertAsyncOn
+ type: logic [aes_reg_pkg::NumAlerts-1:0]
+ default: "{aes_reg_pkg::NumAlerts{1'b1}}"
+ local: "false"
+ expose: "false"
+ name_top: AesAlertAsyncOn
+ }
]
interrupt_list: []
alert_list:
diff --git a/hw/top_earlgrey/data/top_earlgrey.sv.tpl b/hw/top_earlgrey/data/top_earlgrey.sv.tpl
index d807efe..cabe033 100644
--- a/hw/top_earlgrey/data/top_earlgrey.sv.tpl
+++ b/hw/top_earlgrey/data/top_earlgrey.sv.tpl
@@ -32,8 +32,8 @@
module top_${top["name"]} #(
// Auto-inferred parameters
% for m in top["module"]:
- % for p in m["param_list"]:
- parameter ${p["type"]} ${p["name_top"]} = ${p["default"]},
+ % for p_exp in filter(lambda p: p["expose"] == "true", m["param_list"]):
+ parameter ${p_exp["type"]} ${p_exp["name_top"]} = ${p_exp["default"]},
% endfor
% endfor
@@ -488,7 +488,7 @@
% if m["param_list"]:
${m["type"]} #(
% for i in m["param_list"]:
- .${i["name"]}(${i["name_top"]})${"," if not loop.last else ""}
+ .${i["name"]}(${i["name_top" if i["expose"] == "true" else "default"]})${"," if not loop.last else ""}
% endfor
) u_${m["name"]} (
% else:
diff --git a/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv b/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv
index fced822..b423882 100644
--- a/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv
+++ b/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv
@@ -683,9 +683,11 @@
);
aes #(
+ .AES192Enable(1'b1),
.Masking(AesMasking),
.SBoxImpl(AesSBoxImpl),
- .SecStartTriggerDelay(SecAesStartTriggerDelay)
+ .SecStartTriggerDelay(SecAesStartTriggerDelay),
+ .AlertAsyncOn({aes_reg_pkg::NumAlerts{1'b1}})
) u_aes (
// [0]: ctrl_err_update
diff --git a/util/topgen/merge.py b/util/topgen/merge.py
index f736c44..acbaa92 100644
--- a/util/topgen/merge.py
+++ b/util/topgen/merge.py
@@ -93,18 +93,18 @@
# param_list
if "param_list" in ip:
ip_module["param_list"] = deepcopy(ip["param_list"])
- # Removing parameters that aren't exposed at the top level.
+ # Removing local parameters.
for i in ip["param_list"]:
- if i["expose"] == "false":
+ if i["local"] == "true":
ip_module["param_list"].remove(i)
- if i["name"].lower().startswith("sec"):
- log.warning(
- mod_name + " has security-critical" +
- " parameter " + i["name"] + " not exposed to top")
- # Removing descriptors and adding a top-level name.
+ # Removing descriptors, checking for security-relevant parameters
+ # that are not exposed, adding a top-level name.
for i in ip_module["param_list"]:
i.pop("desc", None)
par_name = i["name"]
+ if par_name.lower().startswith("sec"):
+ log.warning("{} has security-critical parameter {} "
+ "not exposed to top".format(mod_name, par_name))
i["name_top"] = ("Sec" + mod_name.capitalize() + par_name[3:]
if par_name.lower().startswith("sec")
else mod_name.capitalize() + par_name)