Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: draw isosub over the design #583

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions openlane/config/pdk_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,7 @@ def process_sta(key: str):
elif new["PDK"].startswith("gf180mcu"):
new["HEURISTIC_ANTENNA_THRESHOLD"] = 130

if new["PDK"].startswith("sky130"):
new["ISOSUB_LAYER"] = (81, 53)

return new
12 changes: 12 additions & 0 deletions openlane/scripts/klayout/stream_out.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
required=True,
help="KLayout .map (LEF/DEF layer map) file",
)
@click.option(
"--isosub",
"isosub",
)
@click.option("-w", "--with-gds-file", "input_gds_files", multiple=True, default=[])
@click.option("-s", "--seal-gds-file", "seal_gds", default=None)
@click.option(
Expand All @@ -100,6 +104,7 @@ def stream_out(
seal_gds: Optional[str],
design_name: str,
input: str,
isosub: str,
): # Load technology file
try:
tech = pya.Technology()
Expand Down Expand Up @@ -165,6 +170,13 @@ def stream_out(

# Write out the GDS
print(f"[INFO] Writing out GDS '{output}'…")
if isosub is not None:
top_cell_bbox = top_only_layout.top_cell().bbox()
isosub_layer = top_only_layout.layer(
int(isosub.split(";")[0]), int(isosub.split(";")[1])
)
top_only_layout.top_cell().shapes(isosub_layer).insert(top_cell_bbox)
print("[INFO] Added isosub")
top_only_layout.write(output)
print("[INFO] Done.")
except Exception as e:
Expand Down
30 changes: 30 additions & 0 deletions openlane/scripts/magic/add_subcut.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2024 Efabless Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source $::env(SCRIPTS_DIR)/magic/common/read.tcl
drc off
read_pdk_gds
gds noduplicates true
gds read $::env(CURRENT_GDS)
load $::env(DESIGN_NAME)
select top cell
paint isosub
if { $::env(MAGIC_DISABLE_CIF_INFO) } {
cif *hier write disable
cif *array write disable
}
gds nodatestamp yes
if { $::env(MAGIC_GDS_POLYGON_SUBCELLS) } {
gds polygon subcells true
}
gds write $::env(SAVE_MAG_GDS)
4 changes: 4 additions & 0 deletions openlane/scripts/magic/def/mag_gds.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ if { $::env(MAGIC_GDS_POLYGON_SUBCELLS) } {
gds polygon subcells true
}

if { $::env(MAGIC_ADD_ISOSUB) } {
paint isosub
}

gds write $::env(SAVE_MAG_GDS)
puts "\[INFO\] GDS Write Complete"

Expand Down
28 changes: 26 additions & 2 deletions openlane/steps/klayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .step import ViewsUpdate, MetricsUpdate, Step, StepError, StepException

from ..config import Variable
from ..logging import info
from ..logging import info, warn
from ..state import DesignFormat, State
from ..common import Path, get_script_dir, mkdirp, _get_process_limit

Expand Down Expand Up @@ -185,6 +185,21 @@ class StreamOut(KLayoutStep):
id = "KLayout.StreamOut"
name = "GDSII Stream Out (KLayout)"

config_vars = KLayoutStep.config_vars + [
Variable(
"ISOSUB_LAYER",
Optional[Tuple[int, int]],
"Layer/datatype pair for subcut",
pdk=True,
),
Variable(
"KLAYOUT_ADD_ISOSUB",
bool,
default=False,
description="Add isosub(subcut) drawing over the design. Useful when the design is getting integarated in a design with multiple power domains",
),
]

inputs = [DesignFormat.DEF]
outputs = [DesignFormat.GDS, DesignFormat.KLAYOUT_GDS]

Expand All @@ -197,6 +212,14 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
)
kwargs, env = self.extract_env(kwargs)

isosub_layer_arg = []
if self.config.get("KLAYOUT_ADD_ISOSUB"):
if isosub_layer := self.config.get("ISOSUB_LAYER"):
isosub_layer_arg = ["--isosub", f"{isosub_layer[0]};{isosub_layer[1]}"]
else:
warn(
"KLAYOUT_ADD_ISOSUB enabled but no ISOSUB_LAYER defined for the PDK. Not going to add isosub to the design"
)
self.run_pya_script(
[
sys.executable,
Expand All @@ -211,7 +234,8 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
"--top",
self.config["DESIGN_NAME"],
]
+ self.get_cli_args(include_lefs=True, include_gds=True),
+ self.get_cli_args(include_lefs=True, include_gds=True)
+ isosub_layer_arg,
env=env,
)

Expand Down
18 changes: 18 additions & 0 deletions openlane/steps/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ class StreamOut(MagicStep):
"A flag to move the layout such that it's origin in the lef generated by magic is 0,0.",
default=False,
),
Variable(
"MAGIC_ADD_ISOSUB",
bool,
"Add isosub(subcut) drawing over the design. Useful when the design is getting integarated in a design with multiple power domains",
default=False,
),
Variable(
"MAGIC_DISABLE_CIF_INFO",
bool,
Expand Down Expand Up @@ -564,3 +570,15 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
magic.send_signal(SIGKILL)

return {}, {}


@Step.factory.register()
class AddIsosub(MagicStep):
id = "Magic.AddIsosub"
name = "Add isosub(subcut) to the design"

outputs = [DesignFormat.GDS, DesignFormat.MAG_GDS]
config_vars = StreamOut.config_vars

def get_script_path(self):
return os.path.join(get_script_dir(), "magic", "add_subcut.tcl")
Loading