From d8600f48c63c0e932ec3ee4e39eb326a6ef4e455 Mon Sep 17 00:00:00 2001 From: Julian Frimmel Date: Thu, 13 Feb 2025 11:58:45 +0100 Subject: [PATCH] Support passing `vlogparam`s to Genus _Note_: this is written from the viewpoint of a FuseSoC user, but this applies to all usages of edalize itself. FuseSoC already accepts `vlogparam`s for the `genus` backend/tool, but does not write them to any TCL-file or other way to access it from the user-defined Genus script. Therefore one could not easily add parameters to the top-level module when synthesizing with Genus, effectively ren- dering them unusable. In order to resolve this issue, this commit creates new variable called `ELABORATE_PARAMETERS`, which is set unconditionally. Its value is constructed in such a way, that the value can be passed directly to the `elaborate`-command inside the user-supplied Genus TCL script like so: ```tcl elaborate -parameters "$ELABORATE_PARAMETERS" "$TOP_MODULE" ``` This way, the user-supplied TCL-script can be kept generic (without the need for special-casing parameter) and FuseSoC makes use of the defined parameters. --- edalize/genus.py | 5 +++++ edalize/templates/genus/genus-project.tcl.j2 | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/edalize/genus.py b/edalize/genus.py index 8bd757696..c284e85ec 100644 --- a/edalize/genus.py +++ b/edalize/genus.py @@ -86,6 +86,10 @@ def make_list(opt): jobs = self.tool_options.get("jobs", None) jobs = "$nproc" if "all" in jobs else jobs + # Build up parameters in the format that the `elaborate` command expects + parameters = [f"{{ {name} {value} }}" for name, value in self.vlogparam.items()] + elaborate_parameters = "{ " + " ".join(parameters) + " }" + template_vars = { "name": self.name, "src_files": src_files, @@ -95,6 +99,7 @@ def make_list(opt): "genus_script": make_list(self.tool_options.get("genus_script")), "report_dir": make_list(self.tool_options.get("report_dir")), "common_config": make_list(self.tool_options.get("common_config")), + "parameters": elaborate_parameters, "jobs": make_list(jobs), "toplevel": self.toplevel, } diff --git a/edalize/templates/genus/genus-project.tcl.j2 b/edalize/templates/genus/genus-project.tcl.j2 index a6aefa556..e3f1c88a1 100644 --- a/edalize/templates/genus/genus-project.tcl.j2 +++ b/edalize/templates/genus/genus-project.tcl.j2 @@ -28,6 +28,12 @@ set_multi_cpu_usage -local_cpu {{jobs}} set READ_SOURCES {{ name }}-read-sources +# A variable containing all top-module parameters passed by FuseSoC, ready to +# be passed on to the `elaborate`-command (within the `$GENUS_SCRIPT` like this: +# +# elaborate -parameters "$ELABORATE_PARAMETERS" "$TOP_MODULE" +set ELABORATE_PARAMETERS {{ parameters }} + {% if script_dir -%} set SCRIPT_DIR {{ script_dir }} {% else %}