Skip to content

Commit

Permalink
bugfix: allow unsetting variables in configuration files (#593)
Browse files Browse the repository at this point in the history
## Misc. Enhancements/Bugfixes

* Fixed undefining variables in configuration files being ignored.
* Restored `VERILOG_POWER_DEFINE` as an optional variable.

## Steps

* `Yosys.JsonHeader`, `Verilator.Lint`, `Odb.WriteVerilogHeader`

  * Handled undefined `VERILOG_POWER_DEFINE`.

---------

Signed-off-by: Kareem Farid <[email protected]>
Co-authored-by: Mohamed Gaber <[email protected]>
  • Loading branch information
kareefardi and donn authored Nov 10, 2024
1 parent ee52af1 commit 771a73e
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 29 deletions.
29 changes: 24 additions & 5 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,55 @@
## Documentation
-->

# 2.2.4
# 2.2.5

## Steps

* `Yosys.JsonHeader`, `Verilator.Lint`, `Odb.WriteVerilogHeader`

* Fixed `VERILOG_POWER_DEFINE` not being optional which was an unintentional
break from OpenLane 1.

* Default value is still `USE_POWER_PINS`, but it can be explicitly unset.

## Misc. Enhancements/Bugfixes

* `openlane.config`: Fixed issue where preprocessor would ignore explicitly-set
null values in configuration files.

# 2.2.4

## Tool Updates

* `yosys-sby`: Overlaid new hash for `yosys-0.46` tag because of a tag update
upstream.

# 2.2.3

## Misc. Enhancements/Bugfixes

* Fixed incorrect error message when subtituting a step with one that has a nonexistent ID.
* Fixed incorrect error message when subtituting a step with one that has a
nonexistent ID.

# 2.2.2

## Steps

* `Odb.*`

* Fixed OpenROAD dropping user-set `PYTHONPATH` values.

## Tool Updates

* Use `NIX_PYTHONPATH` instead of `PYTHONPATH` in Docker and devshells
to avoid collisions with user-set `PYTHONPATH` variables.
* Use `NIX_PYTHONPATH` instead of `PYTHONPATH` in Docker and devshells to avoid
collisions with user-set `PYTHONPATH` variables.

# 2.2.1

This patch has no functional changes to OpenLane proper.

## Tool Updates

* `flake.createOpenLaneShell` now gets OpenLane from `python3.pkgs`.
* Fixed issue with `flake.createOpenLaneShell` where plugins would not get
included due to an operator precedence issue.
Expand Down
2 changes: 1 addition & 1 deletion openlane/config/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def process_dict_recursive(
else:
processed = value

if processed is not None:
if not key.startswith(PDK_PREFIX) and not key.startswith(SCL_PREFIX):
ref[key] = processed
symbols[current_key_path] = processed

Expand Down
17 changes: 9 additions & 8 deletions openlane/scripts/odbpy/power_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,13 @@ def set_power_connections(input_json, reader: OdbReader):
@click.option(
"--power-define",
type=str,
required=True,
required=False,
)
@click_odb
def write_verilog_header(
output_vh: str,
input_json: str,
power_define: str,
power_define: Optional[str],
reader: OdbReader,
):
input_dict = json.load(open(input_json))
Expand Down Expand Up @@ -373,13 +373,14 @@ def write_verilog_header(
# Write module
print("// Auto-generated by OpenLane", file=f)
print(f"module {design_name}(", file=f)
print(f"`ifdef {power_define}", file=f)
last_pos = f.tell()
for decl in pg_decls:
print(f" {decl}", file=f, end="")
last_pos = f.tell()
print(",", file=f)
print("`endif", file=f)
if power_define is not None:
print(f"`ifdef {power_define}", file=f)
for decl in pg_decls:
print(f" {decl}", file=f, end="")
last_pos = f.tell()
print(",", file=f)
print("`endif", file=f)
for decl in signal_decls:
print(f" {decl}", file=f, end="")
last_pos = f.tell()
Expand Down
21 changes: 14 additions & 7 deletions openlane/scripts/pyosys/json_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,20 @@ def json_header(
blackbox_models = extra["blackbox_models"]

includes = config["VERILOG_INCLUDE_DIRS"] or []
defines = (config["VERILOG_DEFINES"] or []) + [
f"PDK_{config['PDK']}",
f"SCL_{config['STD_CELL_LIBRARY']}",
"__openlane__",
"__pnr__",
config["VERILOG_POWER_DEFINE"],
]
defines = (
(config["VERILOG_DEFINES"] or [])
+ [
f"PDK_{config['PDK']}",
f"SCL_{config['STD_CELL_LIBRARY']}",
"__openlane__",
"__pnr__",
]
+ (
[]
if config.get("VERILOG_POWER_DEFINE") is None
else [config.get("VERILOG_POWER_DEFINE")]
)
)

d = ys.Design()
d.add_blackbox_models(
Expand Down
14 changes: 10 additions & 4 deletions openlane/steps/odb.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class WriteVerilogHeader(OdbpyStep):
config_vars = OdbpyStep.config_vars + [
Variable(
"VERILOG_POWER_DEFINE",
str,
Optional[str],
"Specifies the name of the define used to guard power and ground connections in the output Verilog header.",
deprecated_names=["SYNTH_USE_PG_PINS_DEFINES", "SYNTH_POWER_DEFINE"],
default="USE_POWER_PINS",
Expand All @@ -324,14 +324,20 @@ def get_subcommand(self) -> List[str]:

def get_command(self) -> List[str]:
state_in = self.state_in.result()
return super().get_command() + [
command = super().get_command() + [
"--output-vh",
os.path.join(self.step_dir, f"{self.config['DESIGN_NAME']}.vh"),
"--input-json",
str(state_in[DesignFormat.JSON_HEADER]),
"--power-define",
self.config["VERILOG_POWER_DEFINE"],
]
if self.config.get("VERILOG_POWER_DEFINE") is not None:
command += ["--power-define", self.config["VERILOG_POWER_DEFINE"]]
else:
self.warn(
"VERILOG_POWER_DEFINE undefined. Verilog Header will not include power ports."
)

return command

def run(self, state_in, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
views_updates, metrics_updates = super().run(state_in, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions openlane/steps/pyosys.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
),
Variable(
"VERILOG_POWER_DEFINE",
str,
Optional[str],
"Specifies the name of the define used to guard power and ground connections in the input RTL.",
deprecated_names=["SYNTH_USE_PG_PINS_DEFINES", "SYNTH_POWER_DEFINE"],
default="USE_POWER_PINS",
Expand Down Expand Up @@ -142,7 +142,7 @@ def _parse_yosys_check(
),
Variable(
"VERILOG_POWER_DEFINE",
str,
Optional[str],
"Specifies the name of the define used to guard power and ground connections in the input RTL.",
deprecated_names=["SYNTH_USE_PG_PINS_DEFINES", "SYNTH_POWER_DEFINE"],
default="USE_POWER_PINS",
Expand Down
6 changes: 4 additions & 2 deletions openlane/steps/verilator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Lint(Step):
),
Variable(
"VERILOG_POWER_DEFINE",
str,
Optional[str],
"Specifies the name of the define used to guard power and ground connections in the input RTL.",
deprecated_names=["SYNTH_USE_PG_PINS_DEFINES", "SYNTH_POWER_DEFINE"],
default="USE_POWER_PINS",
Expand Down Expand Up @@ -124,12 +124,14 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
model_set.add(str_model)
model_list.append(str_model)
defines = [
self.config["VERILOG_POWER_DEFINE"],
f"PDK_{self.config['PDK']}",
f"SCL_{self.config['STD_CELL_LIBRARY']}",
"__openlane__",
"__pnr__",
]
if verilog_power_define := self.config.get("VERILOG_POWER_DEFINE"):
defines += [verilog_power_define]

defines += self.config["LINTER_DEFINES"] or self.config["VERILOG_DEFINES"] or []

if len(model_list):
Expand Down

0 comments on commit 771a73e

Please sign in to comment.