Skip to content

Commit

Permalink
address pr feedback, remove DesignFormat.name
Browse files Browse the repository at this point in the history
  • Loading branch information
donn committed Dec 15, 2024
1 parent 9364c8c commit 04a97c0
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 62 deletions.
26 changes: 13 additions & 13 deletions openlane/scripts/openroad/common/io.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ proc read_current_netlist {args} {
flags {-powered}

if { [info exists flags(-powered)] } {
puts "Reading top-level powered netlist at '$::env(CURRENT_POWERED_NETLIST)'…"
if {[catch {read_verilog $::env(CURRENT_POWERED_NETLIST)} errmsg]} {
puts "Reading top-level powered netlist at '$::env(CURRENT_PNL)'…"
if {[catch {read_verilog $::env(CURRENT_PNL)} errmsg]} {
puts stderr $errmsg
exit 1
}
} else {
puts "Reading top-level netlist at '$::env(CURRENT_NETLIST)'…"
if {[catch {read_verilog $::env(CURRENT_NETLIST)} errmsg]} {
puts "Reading top-level netlist at '$::env(CURRENT_NL)'…"
if {[catch {read_verilog $::env(CURRENT_NL)} errmsg]} {
puts stderr $errmsg
exit 1
}
Expand Down Expand Up @@ -338,26 +338,26 @@ proc write_views {args} {
write_db $::env(SAVE_ODB)
}

if { [info exists ::env(SAVE_NETLIST)] } {
puts "Writing netlist to '$::env(SAVE_NETLIST)'…"
write_verilog $::env(SAVE_NETLIST)
if { [info exists ::env(SAVE_NL)] } {
puts "Writing netlist to '$::env(SAVE_NL)'…"
write_verilog $::env(SAVE_NL)
}

if { [info exists ::env(SAVE_POWERED_NETLIST)] } {
puts "Writing powered netlist to '$::env(SAVE_POWERED_NETLIST)'…"
write_verilog -include_pwr_gnd $::env(SAVE_POWERED_NETLIST)
if { [info exists ::env(SAVE_PNL)] } {
puts "Writing powered netlist to '$::env(SAVE_PNL)'…"
write_verilog -include_pwr_gnd $::env(SAVE_PNL)
}

if { [info exists ::env(SAVE_POWERED_NETLIST_SDF_FRIENDLY)] } {
if { [info exists ::env(SAVE_SDF_PNL)] } {
set exclude_cells "[join $::env(FILL_CELL)] [join $::env(DECAP_CELL)] [join $::env(WELLTAP_CELL)] [join $::env(ENDCAP_CELL)]"
puts "Writing nofill powered netlist to '$::env(SAVE_POWERED_NETLIST_SDF_FRIENDLY)'…"
puts "Writing nofill powered netlist to '$::env(SAVE_SDF_PNL)'…"
puts "Excluding $exclude_cells"
write_verilog -include_pwr_gnd \
-remove_cells "$exclude_cells"\
$::env(SAVE_POWERED_NETLIST_SDF_FRIENDLY)
}

if { [info exists ::env(SAVE_LOGICAL_POWERED_NETLIST)] } {
if { [info exists ::env(SAVE_LOGICAL_PNL)] } {
set exclude_cells "[join [lindex [split $::env(DIODE_CELL) "/"] 0]] [join $::env(FILL_CELL)] [join $::env(DECAP_CELL)] [join $::env(WELLTAP_CELL)] [join $::env(ENDCAP_CELL)]"
puts "Writing nofilldiode powered netlist to '$::env(SAVE_LOGICAL_POWERED_NETLIST)'…"
puts "Excluding $exclude_cells"
Expand Down
56 changes: 31 additions & 25 deletions openlane/state/design_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class DesignFormat(metaclass=DFMetaclass):
Metadata about the various possible text or binary representations (views)
of any design.
For example, ``DesignFormat.NETLIST.value`` has the metadata for Netlist
views.
For example, ``DesignFormat.nl`` has the metadata for Netlist views.
:param id: A lowercase alphanumeric identifier for the design format.
Some IDs in OpenLane 2.X use dashes. This is an inconsistency that will
be addressed in the next major version of OpenLane as it would be a
breaking change.
:param id: A lowercase alphanumeric/underscore identifier for the design
format.
:param extension: The file extension for designs saved in this format.
:param name: A human-readable name for this design format.
:param full_name: A human-readable name for this design format.
:param alts: A list of alternate ids used to access the DesignFormat by
the subscript operator. Includes its OpenLane <3.0.0 enumeration name
for limited backwards compatibility.
:param folder_override: The subdirectory when
:meth:`openlane.state.State.save_snapshot` is called on a state. If
unset, the value for ``id`` will be used.
Expand All @@ -53,7 +53,6 @@ class DesignFormat(metaclass=DFMetaclass):
id: str
extension: str
full_name: str
name: str
alts: List[str] = field(default_factory=list)
folder_override: Optional[str] = None
multiple: bool = False
Expand All @@ -71,6 +70,15 @@ def folder(self) -> str:
def value(self) -> DesignFormat:
return self

@property
@deprecated(
".name has been removed because it's redundant, use .id",
version="3.0.0",
action="once",
)
def name(self) -> str:
return self.id

def register(self):
self.__class__.factory.register(self)

Expand Down Expand Up @@ -108,7 +116,6 @@ def register(Self, df: DesignFormat) -> DesignFormat:
:attr:`DesignFormat.alts` attributes.
"""
Self._registry[df.id] = df
Self._registry[df.name] = df
for alt in df.alts:
Self._registry[alt] = df
return df
Expand Down Expand Up @@ -138,95 +145,94 @@ def list(Self) -> List[str]:
"nl",
"nl.v",
"Verilog Netlist",
"NETLIST",
alts=["NETLIST"],
).register()

DesignFormat(
"pnl",
"pnl.v",
"Powered Verilog Netlist",
"POWERED_NETLIST",
alts=["POWERED_NETLIST"],
).register()

DesignFormat(
"sdf_pnl",
"sdf_pnl.v",
"Powered Verilog Netlist for SDF Simulation (No Fills)",
"POWERED_NETLIST_SDF_FRIENDLY",
alts=["SDF_FRIENDLY_POWERED_NETLIST"],
folder_override="pnl",
alts=["pnl-sdf"],
).register()

DesignFormat(
"npc_pnl",
"npc_pnl.v",
"logical_pnl",
"logical_pnl.v",
"Logical cell-only Powered Verilog Netlist",
"LOGICAL_POWERED_NETLIST",
alts=["LOGICAL_POWERED_NETLIST"],
folder_override="pnl",
).register()

DesignFormat(
"def",
"def",
"Design Exchange Format",
"DEF",
alts=["def_", "DEF"],
).register()

DesignFormat(
"lef",
"lef",
"Library Exchange Format",
"LEF",
alts=["LEF"],
).register()

DesignFormat(
"sdc",
"sdc",
"Design Constraints",
"SDC",
alts=["SDC"],
).register()

DesignFormat(
"sdf",
"sdf",
"Standard Delay Format",
"SDF",
alts=["SDF"],
multiple=True,
).register()

DesignFormat(
"spef",
"spef",
"Standard Parasitics Extraction Format",
"SPEF",
alts=["SPEF"],
multiple=True, # nom, min, max, ...
).register()

DesignFormat(
"lib",
"lib",
"LIB Timing Library Format",
"LIB",
alts=["LIB"],
multiple=True,
).register()

DesignFormat(
"spice",
"spice",
"Simulation Program with Integrated Circuit Emphasis",
"SPICE",
alts=["SPICE"],
).register()

DesignFormat(
"gds",
"gds",
"GDSII Stream",
"GDS",
alts=["GDS"],
).register()

DesignFormat(
"vh",
"vh",
"Verilog Header",
"VERILOG_HEADER",
alts=["VERILOG_HEADER"],
).register()
2 changes: 0 additions & 2 deletions openlane/state/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ def __getitem__(self, key: Union[DesignFormat, str]) -> StateElement:
if isinstance(key, DesignFormat):
id: str = key.id
key = id
if key not in self:
return None
return super().__getitem__(key)

def __setitem__(self, key: Union[DesignFormat, str], item: StateElement):
Expand Down
4 changes: 2 additions & 2 deletions openlane/steps/klayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"klayout_gds",
"klayout.gds",
"GDSII Stream (KLayout)",
"KLAYOUT_GDS",
alts=["KLAYOUT_GDS"],
).register()


Expand Down Expand Up @@ -157,7 +157,7 @@ class Render(KLayoutStep):

def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
input_view = state_in[DesignFormat.DEF]
if gds := state_in[DesignFormat.GDS]:
if gds := state_in.get(DesignFormat.GDS):
input_view = gds

assert isinstance(input_view, Path)
Expand Down
6 changes: 3 additions & 3 deletions openlane/steps/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
"mag",
"mag",
"Magic VLSI View",
"MAG",
alts=["MAG"],
).register()


DesignFormat(
"mag_gds",
"magic.gds",
"GDSII Stream (Magic)",
"MAG_GDS",
alts=["MAG_GDS"],
).register()


Expand Down Expand Up @@ -211,7 +211,7 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
if output.multiple:
# Too step-specific.
continue
path = Path(env[f"SAVE_{output.name}"])
path = Path(env[f"SAVE_{output.id.upper()}"])
if not path.exists():
continue
views_updates[output] = path
Expand Down
2 changes: 1 addition & 1 deletion openlane/steps/odb.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def get_command(self) -> List[str]:
for lef in extra_lefs:
lefs.append("--input-lef")
lefs.append(lef)
if (design_lef := self.state_in.result()[DesignFormat.LEF]) and (
if (design_lef := self.state_in.result().get(DesignFormat.LEF)) and (
DesignFormat.LEF in self.inputs
):
lefs.append("--design-lef")
Expand Down
16 changes: 8 additions & 8 deletions openlane/steps/openroad.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ def pdn_macro_migrator(x):
"odb",
"odb",
"OpenDB Database",
"ODB",
alts=["ODB"],
).register()

DesignFormat(
"openroad_lef",
"ord.lef",
"Library Exchange Format Generated by OpenROAD",
"OPENROAD_LEF",
alts=["OPENROAD_LEF"],
folder_override="lef",
).register()

Expand Down Expand Up @@ -303,7 +303,7 @@ def run(self, state_in, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
if output.multiple:
# Too step-specific.
continue
path = Path(env[f"SAVE_{output.name}"])
path = Path(env[f"SAVE_{output.id.upper()}"])
if not path.exists():
continue
views_updates[output] = path
Expand Down Expand Up @@ -428,7 +428,7 @@ def _get_corner_files(

name = timing_corner
current_corner_spef = None
input_spef_dict = state_in[DesignFormat.SPEF]
input_spef_dict = state_in.get(DesignFormat.SPEF)
if input_spef_dict is not None:
if not isinstance(input_spef_dict, dict):
raise StepException(
Expand Down Expand Up @@ -745,7 +745,7 @@ def run_corner(
def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
views_updates, metrics_updates = super().run(state_in, **kwargs)

sdf_dict = state_in[DesignFormat.SDF] or {}
sdf_dict = state_in.get(DesignFormat.SDF, {})
if not isinstance(sdf_dict, dict):
raise StepException(
"Malformed input state: incoming value for SDF is not a dictionary."
Expand Down Expand Up @@ -879,7 +879,7 @@ def run_corner(

def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
views_updates, metrics_updates = super().run(state_in, **kwargs)
lib_dict = state_in[DesignFormat.LIB] or {}
lib_dict = state_in.get(DesignFormat.LIB, {})
if not isinstance(lib_dict, dict):
raise StepException(
"Malformed input state: value for LIB is not a dictionary."
Expand Down Expand Up @@ -1791,7 +1791,7 @@ def run_corner(corner: str):
views_updates: ViewsUpdate = {}
metrics_updates: MetricsUpdate = {}

spef_dict = state_in[DesignFormat.SPEF] or {}
spef_dict = state_in.get(DesignFormat.SPEF, {})
if not isinstance(spef_dict, dict):
raise StepException(
"Malformed input state: value for SPEF is not a dictionary."
Expand Down Expand Up @@ -1956,7 +1956,7 @@ class WriteViews(OpenROADStep):
id = "OpenROAD.WriteViews"
name = "OpenROAD Write Views"
outputs = OpenROADStep.outputs + [
DesignFormat.POWERED_NETLIST_SDF_FRIENDLY,
DesignFormat.SDF_FRIENDLY_POWERED_NETLIST,
DesignFormat.LOGICAL_POWERED_NETLIST,
DesignFormat.OPENROAD_LEF,
]
Expand Down
2 changes: 1 addition & 1 deletion openlane/steps/pyosys.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _parse_yosys_check(
"json_h",
"h.json",
"Design JSON Header File",
"JSON_HEADER",
alts=["JSON_HEADER"],
).register()


Expand Down
2 changes: 1 addition & 1 deletion openlane/steps/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ def start(
value = state_in_result[input]
if value is None:
raise StepException(
f"{type(self).__name__}: missing required input '{input.name}'"
f"{type(self).__name__}: missing required input '{input.id}'"
) from None

try:
Expand Down
6 changes: 3 additions & 3 deletions openlane/steps/tclstep.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ def prepare_env(self, env: dict, state: State) -> dict:
env[element] = TclStep.value_to_tcl(value)

for input in self.inputs:
key = f"CURRENT_{input.name}"
key = f"CURRENT_{input.id.upper()}"
env[key] = TclStep.value_to_tcl(state[input])

for output in self.outputs:
if output.multiple:
# Too step-specific.
continue
filename = f"{self.config['DESIGN_NAME']}.{output.extension}"
env[f"SAVE_{output.name}"] = os.path.join(self.step_dir, filename)
env[f"SAVE_{output.id.upper()}"] = os.path.join(self.step_dir, filename)

return env

Expand Down Expand Up @@ -213,7 +213,7 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
if output.multiple:
# Too step-specific.
continue
path = Path(env[f"SAVE_{output.name}"])
path = Path(env[f"SAVE_{output.id.upper()}"])
if not path.exists():
continue
overrides[output] = path
Expand Down
Loading

0 comments on commit 04a97c0

Please sign in to comment.