From 18c67d9a7e1a163bfd8f35420cb4fcd5cd1016e4 Mon Sep 17 00:00:00 2001 From: htamas Date: Mon, 26 Feb 2024 03:59:29 +0100 Subject: [PATCH] feat(precheck): add warning for flattened cells Flattened sky130 devices in analog layouts can lead to DRC errors. They are difficult to test for, so as a heuristic we add a warning when magic DRC fails and there are no unflattened sky130 cells. --- precheck/precheck.py | 10 ++++++++++ precheck/requirements.txt | 1 + 2 files changed, 11 insertions(+) diff --git a/precheck/precheck.py b/precheck/precheck.py index 3e5cf13..366d3bc 100644 --- a/precheck/precheck.py +++ b/precheck/precheck.py @@ -7,6 +7,7 @@ import time import traceback import xml.etree.ElementTree as ET +import gdstk import klayout.db as pya import klayout.rdb as rdb from klayout_tools import parse_lyp_layers @@ -25,6 +26,13 @@ class PrecheckFailure(Exception): pass +def has_sky130_devices(gds: str): + for cell_name in gdstk.read_rawcells(gds): + if cell_name.startswith("sky130_fd_"): + return True + return False + + def magic_drc(gds: str, toplevel: str): logging.info(f"Running magic DRC on {gds} (module={toplevel})") @@ -45,6 +53,8 @@ def magic_drc(gds: str, toplevel: str): ) if magic.returncode != 0: + if not has_sky130_devices(gds): + logging.warning("No sky130 devices present - was the design flattened?") raise PrecheckFailure("Magic DRC failed") diff --git a/precheck/requirements.txt b/precheck/requirements.txt index 8ec6d50..49b91b5 100644 --- a/precheck/requirements.txt +++ b/precheck/requirements.txt @@ -1,2 +1,3 @@ klayout==0.28.12 +gdstk==0.9.50 pytest==7.4.3