Skip to content

Commit ba6ec6b

Browse files
committed
feat: draw isosub over the design
Signed-off-by: Kareem Farid <kareefardi@users.noreply.github.com>
1 parent 7582da7 commit ba6ec6b

File tree

6 files changed

+93
-2
lines changed

6 files changed

+93
-2
lines changed

openlane/config/pdk_compat.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,7 @@ def process_sta(key: str):
251251
elif new["PDK"].startswith("gf180mcu"):
252252
new["HEURISTIC_ANTENNA_THRESHOLD"] = 130
253253

254+
if new["PDK"].startswith("sky130"):
255+
new["ISOSUB_LAYER"] = (81, 53)
256+
254257
return new

openlane/scripts/klayout/stream_out.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@
7777
required=True,
7878
help="KLayout .map (LEF/DEF layer map) file",
7979
)
80+
@click.option(
81+
"--isosub",
82+
"isosub",
83+
)
8084
@click.option("-w", "--with-gds-file", "input_gds_files", multiple=True, default=[])
8185
@click.option("-s", "--seal-gds-file", "seal_gds", default=None)
8286
@click.option(
@@ -100,6 +104,7 @@ def stream_out(
100104
seal_gds: Optional[str],
101105
design_name: str,
102106
input: str,
107+
isosub: str,
103108
): # Load technology file
104109
try:
105110
tech = pya.Technology()
@@ -165,6 +170,13 @@ def stream_out(
165170

166171
# Write out the GDS
167172
print(f"[INFO] Writing out GDS '{output}'…")
173+
if isosub is not None:
174+
top_cell_bbox = top_only_layout.top_cell().bbox()
175+
isosub_layer = top_only_layout.layer(
176+
int(isosub.split(";")[0]), int(isosub.split(";")[1])
177+
)
178+
top_only_layout.top_cell().shapes(isosub_layer).insert(top_cell_bbox)
179+
print("[INFO] Added isosub")
168180
top_only_layout.write(output)
169181
print("[INFO] Done.")
170182
except Exception as e:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2024 Efabless Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
source $::env(SCRIPTS_DIR)/magic/common/read.tcl
15+
drc off
16+
read_pdk_gds
17+
gds noduplicates true
18+
gds read $::env(CURRENT_GDS)
19+
load $::env(DESIGN_NAME)
20+
select top cell
21+
paint isosub
22+
if { $::env(MAGIC_DISABLE_CIF_INFO) } {
23+
cif *hier write disable
24+
cif *array write disable
25+
}
26+
gds nodatestamp yes
27+
if { $::env(MAGIC_GDS_POLYGON_SUBCELLS) } {
28+
gds polygon subcells true
29+
}
30+
gds write $::env(SAVE_MAG_GDS)

openlane/scripts/magic/def/mag_gds.tcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ if { $::env(MAGIC_GDS_POLYGON_SUBCELLS) } {
7575
gds polygon subcells true
7676
}
7777

78+
if { $::env(MAGIC_ADD_ISOSUB) } {
79+
paint isosub
80+
}
81+
7882
gds write $::env(SAVE_MAG_GDS)
7983
puts "\[INFO\] GDS Write Complete"
8084

openlane/steps/klayout.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from .step import ViewsUpdate, MetricsUpdate, Step, StepError, StepException
2525

2626
from ..config import Variable
27-
from ..logging import info
27+
from ..logging import info, warn
2828
from ..state import DesignFormat, State
2929
from ..common import Path, get_script_dir, mkdirp, _get_process_limit
3030

@@ -185,6 +185,21 @@ class StreamOut(KLayoutStep):
185185
id = "KLayout.StreamOut"
186186
name = "GDSII Stream Out (KLayout)"
187187

188+
config_vars = KLayoutStep.config_vars + [
189+
Variable(
190+
"ISOSUB_LAYER",
191+
Optional[Tuple[int, int]],
192+
"Layer/datatype pair for subcut",
193+
pdk=True,
194+
),
195+
Variable(
196+
"KLAYOUT_ADD_ISOSUB",
197+
bool,
198+
default=False,
199+
description="Add isosub(subcut) drawing over the design. Useful when the design is getting integarated in a design with multiple power domains",
200+
),
201+
]
202+
188203
inputs = [DesignFormat.DEF]
189204
outputs = [DesignFormat.GDS, DesignFormat.KLAYOUT_GDS]
190205

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

215+
isosub_layer_arg = []
216+
if self.config.get("KLAYOUT_ADD_ISOSUB"):
217+
if isosub_layer := self.config.get("ISOSUB_LAYER"):
218+
isosub_layer_arg = ["--isosub", f"{isosub_layer[0]};{isosub_layer[1]}"]
219+
else:
220+
warn(
221+
"KLAYOUT_ADD_ISOSUB enabled but no ISOSUB_LAYER defined for the PDK. Not going to add isosub to the design"
222+
)
200223
self.run_pya_script(
201224
[
202225
sys.executable,
@@ -211,7 +234,8 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
211234
"--top",
212235
self.config["DESIGN_NAME"],
213236
]
214-
+ self.get_cli_args(include_lefs=True, include_gds=True),
237+
+ self.get_cli_args(include_lefs=True, include_gds=True)
238+
+ isosub_layer_arg,
215239
env=env,
216240
)
217241

openlane/steps/magic.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ class StreamOut(MagicStep):
274274
"A flag to move the layout such that it's origin in the lef generated by magic is 0,0.",
275275
default=False,
276276
),
277+
Variable(
278+
"MAGIC_ADD_ISOSUB",
279+
bool,
280+
"Add isosub(subcut) drawing over the design. Useful when the design is getting integarated in a design with multiple power domains",
281+
default=False,
282+
),
277283
Variable(
278284
"MAGIC_DISABLE_CIF_INFO",
279285
bool,
@@ -564,3 +570,15 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]:
564570
magic.send_signal(SIGKILL)
565571

566572
return {}, {}
573+
574+
575+
@Step.factory.register()
576+
class AddIsosub(MagicStep):
577+
id = "Magic.AddIsosub"
578+
name = "Add isosub(subcut) to the design"
579+
580+
outputs = [DesignFormat.GDS, DesignFormat.MAG_GDS]
581+
config_vars = StreamOut.config_vars
582+
583+
def get_script_path(self):
584+
return os.path.join(get_script_dir(), "magic", "add_subcut.tcl")

0 commit comments

Comments
 (0)