Skip to content

Commit

Permalink
Move export_drc_report() into export_helper module
Browse files Browse the repository at this point in the history
to make it more easily reusable.
  • Loading branch information
iqmtestd committed Nov 13, 2023
1 parent f9a4c05 commit c3d975b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
23 changes: 3 additions & 20 deletions klayout_package/python/kqcircuits/masks/mask_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
"""Functions for exporting mask sets."""
import json
import os
import subprocess
from importlib import import_module
from math import pi

from autologging import logged

from kqcircuits.chips.chip import Chip
from kqcircuits.defaults import mask_bitmap_export_layers, chip_export_layer_clusters, default_layers, \
default_mask_parameters, default_drc_runset, DRC_PATH, STARTUPINFO
default_mask_parameters
from kqcircuits.elements.flip_chip_connectors.flip_chip_connector_dc import FlipChipConnectorDc
from kqcircuits.klayout_view import resolve_default_layer_info
from kqcircuits.pya_resolver import pya, klayout_executable_command
from kqcircuits.pya_resolver import pya
from kqcircuits.util.area import get_area_and_density
from kqcircuits.util.count_instances import count_instances_in_cell
from kqcircuits.util.geometry_helper import circle_polygon
from kqcircuits.util.geometry_json_encoder import GeometryJsonEncoder
from kqcircuits.util.netlist_extraction import export_cell_netlist
from kqcircuits.util.export_helper import export_drc_report


@logged
Expand Down Expand Up @@ -349,23 +349,6 @@ def export_bitmaps(mask_set, spec_layers=mask_bitmap_export_layers):
view.focus(mask_set.mask_layouts[0].top_cell)


@logged
def export_drc_report(name, path):
drc_runset_path = os.path.join(DRC_PATH, default_drc_runset)
input_file = os.path.join(path, f"{name}.oas")
output_file = os.path.join(path, f"{name}_drc_report.lyrdb")
export_drc_report._log.info("Exporting DRC report to %s", output_file)

try:
subprocess.run([klayout_executable_command(), "-b",
"-rm", drc_runset_path,
"-rd", f"input={input_file}",
"-rd", f"output={output_file}"
], check=True, startupinfo=STARTUPINFO)
except subprocess.CalledProcessError as e:
export_drc_report._log.error(e.output)


def _export_cell(path, cell=None, layers_to_export=None):
if cell is None:
error_text = "Cannot export nil cell."
Expand Down
22 changes: 21 additions & 1 deletion klayout_package/python/kqcircuits/util/export_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import subprocess
import platform
import sys
import os
import argparse
from sys import argv
from pathlib import Path
Expand All @@ -28,7 +29,7 @@

from kqcircuits.elements.element import get_refpoints
from kqcircuits.defaults import default_layers, TMP_PATH, STARTUPINFO, default_probe_types, default_probe_suffixes, \
VERSION_PATHS
VERSION_PATHS, default_drc_runset, DRC_PATH
from kqcircuits.klayout_view import KLayoutView, MissingUILibraryException
from kqcircuits.pya_resolver import pya, is_standalone_session, klayout_executable_command

Expand Down Expand Up @@ -206,3 +207,22 @@ def get_klayout_version():
return f"KLayout {importlib.metadata.version('klayout')}"
else:
return pya.Application.instance().version()


@logged
def export_drc_report(name, path, drc_script=default_drc_runset):
"""Run a DRC script on ``path/name.oas`` and export results in ``path/name_drc_report.lyrdb``."""

drc_runset_path = os.path.join(DRC_PATH, drc_script)
input_file = os.path.join(path, f"{name}.oas")
output_file = os.path.join(path, f"{name}_drc_report.lyrdb")
export_drc_report._log.info("Exporting DRC report to %s", output_file)

try:
subprocess.run([klayout_executable_command(), "-b", "-i",
"-r", drc_runset_path,
"-rd", f"output={output_file}",
input_file
], check=True, startupinfo=STARTUPINFO)
except subprocess.CalledProcessError as e:
export_drc_report._log.error(e.output)

0 comments on commit c3d975b

Please sign in to comment.