Skip to content
Merged
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
2 changes: 2 additions & 0 deletions flow/platforms/gt2n/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# GT2N PDK

> **Source:** copied verbatim from [azadnaeemi/GT2N](https://github.com/azadnaeemi/GT2N) at commit [`308b221`](https://github.com/azadnaeemi/GT2N/commit/308b221b82e19199a9691f2f78cbc7ce981481ca) (2026-06-09). This release splits the original `gt2_6t_tap_w*_*` cell into a frontside-PDN variant (`gt2_6t_tapfspdn_w*_*`, M1 + BPR pins, full width) and a backside-PDN variant (`gt2_6t_tapbspdn_w*_*`, BPR-only pins, half width) in both the LEF and the GDS, resolving the LEF / GDS mismatch we filed as [azadnaeemi/GT2N#16](https://github.com/azadnaeemi/GT2N/issues/16). The platform `TAP_CELL_NAME` points at the backside-PDN variant since the PDN here is backside-only. Also incorporates the BPR `OBS` → `PORT` fix from [azadnaeemi/GT2N#12](https://github.com/azadnaeemi/GT2N/issues/12).
>
> **Local modification:** the LEFs carry Vt implant layers that upstream does not. `add_vt_implant.py` declares `ELVT`/`ULVT`/`LVT`/`SVT`/`HVT` `IMPLANT` layers in `gt2_tech.lef` and adds a full-cell `OBS` rectangle on the matching layer to every macro, mirroring the per-cell Vt rectangle in the GDS (`LVT` is the base device and is LEF-only). OpenROAD's resizer identifies a cell's Vt from these implant obstructions; without them every W/Vt flavor looks like the same Vt and Vt swapping does nothing. Rerun `python3 add_vt_implant.py` after re-syncing the LEFs from upstream.

<img src="./VirtualFabricationDemo.gif" alt="VirtualFabricationDemo" width="400">

Expand Down
111 changes: 111 additions & 0 deletions flow/platforms/gt2n/add_vt_implant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/usr/bin/env python3
"""Add Vt implant layers to the gt2n LEFs.

The upstream GT2N LEFs carry no threshold-voltage information, so
OpenROAD sees every W/Vt flavor of a cell as the same Vt and the
resizer's Vt-aware moves (vt_swap, keep_sizing_vt, Vt-aware buffer
selection) do nothing. As in asap7, the resizer identifies a cell's Vt
from IMPLANT-layer obstructions in its LEF macro.

This script:
- declares one IMPLANT layer per Vt (ELVT ULVT LVT SVT HVT) in the
tech LEF, after the front-end MASTERSLICE layers;
- adds a full-cell OBS rectangle on the matching layer to every macro
in each gt2_6t_<W>_<Vt>.lef, creating the OBS block where a macro
has none.

The rectangles mirror the GDS, where every elvt/ulvt/svt/hvt cell has a
single Vt-layer rectangle (layers 94/95/96/97 in gt2.layermap) from the
origin to the cell SIZE. LVT is the base device and has no GDS layer;
it gets an LEF-only layer so every flavor is explicit. LEF obstructions
are not streamed to GDS, so the layout is unchanged.

The script is idempotent; rerun it after re-syncing the LEFs from
upstream:
python3 add_vt_implant.py
"""

import pathlib
import re
import sys

PLATFORM_DIR = pathlib.Path(__file__).resolve().parent
LEF_DIR = PLATFORM_DIR / "lef"
TECH_LEF = LEF_DIR / "gt2_tech.lef"

VTS = ["elvt", "ulvt", "lvt", "svt", "hvt"]

# Implant layers go after the last front-end MASTERSLICE layer.
TECH_ANCHOR = "END SDCON\n"


def add_tech_layers(path):
text = path.read_text()
if re.search(r"^LAYER ELVT\b", text, re.MULTILINE):
return False
if TECH_ANCHOR not in text:
sys.exit(f"{path}: anchor {TECH_ANCHOR.strip()!r} not found")
layers = "".join(
f"\nLAYER {vt.upper()}\n TYPE IMPLANT ;\nEND {vt.upper()}\n" for vt in VTS
)
path.write_text(text.replace(TECH_ANCHOR, TECH_ANCHOR + layers, 1))
return True
Comment thread
maliberty marked this conversation as resolved.
Resolved


def add_macro_obs(path, layer):
lines = path.read_text().splitlines(keepends=True)
Comment on lines +55 to +56

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Specify encoding="utf-8" when reading the macro LEF files to prevent platform-dependent encoding issues.

Suggested change
def add_macro_obs(path, layer):
lines = path.read_text().splitlines(keepends=True)
def add_macro_obs(path, layer):
lines = path.read_text(encoding="utf-8").splitlines(keepends=True)

out = []
macro = None
size = None
in_obs = False
has_obs = False
has_layer = False
changed = False
for line in lines:
stripped = line.strip()
if m := re.match(r"MACRO\s+(\S+)", stripped):
macro = m.group(1)
size = None
in_obs = has_obs = has_layer = False
elif macro and (m := re.match(r"SIZE\s+(\S+)\s+BY\s+(\S+)\s*;", stripped)):
size = (m.group(1), m.group(2))
elif macro and stripped == "OBS":
in_obs = has_obs = True
elif in_obs and stripped == f"LAYER {layer} ;":
has_layer = True
elif in_obs and stripped == "END":
if not has_layer:
out.append(implant_rect(layer, size, macro, path))
changed = True
in_obs = False
elif macro and stripped == f"END {macro}":
if not has_obs:
out.append(" OBS\n")
out.append(implant_rect(layer, size, macro, path))
out.append(" END\n")
changed = True
macro = None
out.append(line)
if changed:
path.write_text("".join(out))
return changed
Comment thread
maliberty marked this conversation as resolved.
Resolved


def implant_rect(layer, size, macro, path):
if size is None:
sys.exit(f"{path}: macro {macro} has no SIZE before its OBS")
width, height = size
return f" LAYER {layer} ;\n RECT 0 0 {width} {height} ;\n"


def main():
if add_tech_layers(TECH_LEF):
print(f"updated {TECH_LEF.name}")
for vt in VTS:
for path in sorted(LEF_DIR.glob(f"gt2_6t_w*_{vt}.lef")):
if add_macro_obs(path, vt.upper()):
print(f"updated {path.name}")
Comment thread
maliberty marked this conversation as resolved.
Resolved


if __name__ == "__main__":
main()
Loading
Loading