Skip to content

Commit

Permalink
Support passing vlogparams to Genus
Browse files Browse the repository at this point in the history
_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.
  • Loading branch information
jfrimmel committed Feb 13, 2025
1 parent e438f9f commit d8600f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions edalize/genus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
}
Expand Down
6 changes: 6 additions & 0 deletions edalize/templates/genus/genus-project.tcl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down

0 comments on commit d8600f4

Please sign in to comment.