mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
refactor(precheck): add missing types
This commit is contained in:
@@ -28,7 +28,12 @@ def parse_lyp_layers(lyp_file: str):
|
|||||||
if valid is not None and valid.text == "false":
|
if valid is not None and valid.text == "false":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if name is not None and source is not None:
|
if (
|
||||||
|
name is not None
|
||||||
|
and name.text is not None
|
||||||
|
and source is not None
|
||||||
|
and source.text is not None
|
||||||
|
):
|
||||||
name_key = name.text.split("-")[0].strip()
|
name_key = name.text.split("-")[0].strip()
|
||||||
layer, data_type = source.text.split("@")[0].split("/")
|
layer, data_type = source.text.split("@")[0].split("/")
|
||||||
# Add the 'source' text as the value in the dictionary
|
# Add the 'source' text as the value in the dictionary
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ PDK_NAME = os.getenv("PDK_NAME") or "sky130A"
|
|||||||
LYP_FILE = f"{PDK_ROOT}/{PDK_NAME}/libs.tech/klayout/tech/{PDK_NAME}.lyp"
|
LYP_FILE = f"{PDK_ROOT}/{PDK_NAME}/libs.tech/klayout/tech/{PDK_NAME}.lyp"
|
||||||
REPORTS_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "reports")
|
REPORTS_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "reports")
|
||||||
|
|
||||||
|
if not PDK_ROOT:
|
||||||
|
logging.error("PDK_ROOT environment variable not set")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
def magic_drc(gds: str, toplevel: str):
|
def magic_drc(gds: str, toplevel: str):
|
||||||
logging.info(f"Running magic DRC on {gds} (module={toplevel})")
|
logging.info(f"Running magic DRC on {gds} (module={toplevel})")
|
||||||
@@ -61,7 +65,8 @@ def klayout_drc(gds: str, check: str):
|
|||||||
logging.error(f"Klayout {check} failed")
|
logging.error(f"Klayout {check} failed")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
report = rdb.ReportDatabase().load(report_file)
|
report = rdb.ReportDatabase("DRC")
|
||||||
|
report.load(report_file)
|
||||||
|
|
||||||
if report.num_items() > 0:
|
if report.num_items() > 0:
|
||||||
logging.error(
|
logging.error(
|
||||||
|
|||||||
+12
-12
@@ -13,7 +13,7 @@ gds_layers = klayout_tools.parse_lyp_layers(LYP_FILE)
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def gds_empty(tmp_path_factory):
|
def gds_empty(tmp_path_factory: pytest.TempPathFactory):
|
||||||
"""Creates a GDS with an empty cell that should pass DRC."""
|
"""Creates a GDS with an empty cell that should pass DRC."""
|
||||||
gds_file = tmp_path_factory.mktemp("gds") / "gds_empty.gds"
|
gds_file = tmp_path_factory.mktemp("gds") / "gds_empty.gds"
|
||||||
layout = pya.Layout()
|
layout = pya.Layout()
|
||||||
@@ -23,7 +23,7 @@ def gds_empty(tmp_path_factory):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def gds_fail_met1_poly(tmp_path_factory):
|
def gds_fail_met1_poly(tmp_path_factory: pytest.TempPathFactory):
|
||||||
"""Creates a GDS that fails Magic DRC and BEOL because the met1 rect is too small."""
|
"""Creates a GDS that fails Magic DRC and BEOL because the met1 rect is too small."""
|
||||||
gds_file = tmp_path_factory.mktemp("gds") / "gds_met1_fail.gds"
|
gds_file = tmp_path_factory.mktemp("gds") / "gds_met1_fail.gds"
|
||||||
layout = pya.Layout()
|
layout = pya.Layout()
|
||||||
@@ -39,7 +39,7 @@ def gds_fail_met1_poly(tmp_path_factory):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def gds_fail_nwell_poly(tmp_path_factory):
|
def gds_fail_nwell_poly(tmp_path_factory: pytest.TempPathFactory):
|
||||||
"""Creates a GDS that fails FEOL because the nwell is too small."""
|
"""Creates a GDS that fails FEOL because the nwell is too small."""
|
||||||
gds_file = tmp_path_factory.mktemp("gds") / "gds_nwell_fail.gds"
|
gds_file = tmp_path_factory.mktemp("gds") / "gds_nwell_fail.gds"
|
||||||
layout = pya.Layout()
|
layout = pya.Layout()
|
||||||
@@ -54,7 +54,7 @@ def gds_fail_nwell_poly(tmp_path_factory):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def gds_fail_metal5_poly(tmp_path_factory):
|
def gds_fail_metal5_poly(tmp_path_factory: pytest.TempPathFactory):
|
||||||
"""Creates a GDS with drawings on layer5, should fail our precheck."""
|
"""Creates a GDS with drawings on layer5, should fail our precheck."""
|
||||||
gds_file = tmp_path_factory.mktemp("gds") / "gds_metal5_fail.gds"
|
gds_file = tmp_path_factory.mktemp("gds") / "gds_metal5_fail.gds"
|
||||||
layout = pya.Layout()
|
layout = pya.Layout()
|
||||||
@@ -67,41 +67,41 @@ def gds_fail_metal5_poly(tmp_path_factory):
|
|||||||
return str(gds_file)
|
return str(gds_file)
|
||||||
|
|
||||||
|
|
||||||
def test_magic_drc_pass(gds_empty):
|
def test_magic_drc_pass(gds_empty: str):
|
||||||
result = precheck.magic_drc(gds_empty, "TEST_empty")
|
result = precheck.magic_drc(gds_empty, "TEST_empty")
|
||||||
assert result is True
|
assert result is True
|
||||||
|
|
||||||
|
|
||||||
def test_magic_drc_fail(gds_fail_met1_poly):
|
def test_magic_drc_fail(gds_fail_met1_poly: str):
|
||||||
result = precheck.magic_drc(gds_fail_met1_poly, "TEST_met1_error")
|
result = precheck.magic_drc(gds_fail_met1_poly, "TEST_met1_error")
|
||||||
assert result is False
|
assert result is False
|
||||||
|
|
||||||
|
|
||||||
def test_klayout_feol_pass(gds_empty):
|
def test_klayout_feol_pass(gds_empty: str):
|
||||||
result = precheck.klayout_drc(gds_empty, "feol")
|
result = precheck.klayout_drc(gds_empty, "feol")
|
||||||
assert result is True
|
assert result is True
|
||||||
|
|
||||||
|
|
||||||
def test_klayout_feol_fail(gds_fail_nwell_poly):
|
def test_klayout_feol_fail(gds_fail_nwell_poly: str):
|
||||||
result = precheck.klayout_drc(gds_fail_nwell_poly, "feol")
|
result = precheck.klayout_drc(gds_fail_nwell_poly, "feol")
|
||||||
assert result is False
|
assert result is False
|
||||||
|
|
||||||
|
|
||||||
def test_klayout_beol_pass(gds_empty):
|
def test_klayout_beol_pass(gds_empty: str):
|
||||||
result = precheck.klayout_drc(gds_empty, "beol")
|
result = precheck.klayout_drc(gds_empty, "beol")
|
||||||
assert result is True
|
assert result is True
|
||||||
|
|
||||||
|
|
||||||
def test_klayout_beol_fail(gds_fail_met1_poly):
|
def test_klayout_beol_fail(gds_fail_met1_poly: str):
|
||||||
result = precheck.klayout_drc(gds_fail_met1_poly, "beol")
|
result = precheck.klayout_drc(gds_fail_met1_poly, "beol")
|
||||||
assert result is False
|
assert result is False
|
||||||
|
|
||||||
|
|
||||||
def test_klayout_checks_pass(gds_empty):
|
def test_klayout_checks_pass(gds_empty: str):
|
||||||
result = precheck.klayout_checks(gds_empty)
|
result = precheck.klayout_checks(gds_empty)
|
||||||
assert result is True
|
assert result is True
|
||||||
|
|
||||||
|
|
||||||
def test_klayout_checks_fail(gds_fail_metal5_poly):
|
def test_klayout_checks_fail(gds_fail_metal5_poly: str):
|
||||||
result = precheck.klayout_checks(gds_fail_metal5_poly)
|
result = precheck.klayout_checks(gds_fail_metal5_poly)
|
||||||
assert result is False
|
assert result is False
|
||||||
|
|||||||
Reference in New Issue
Block a user