Please Help! How to Export DRC Results to a TXT File in KLayout for Python Integration?

I'm working on a reinforcement learning research project where the reward design relies on overlapping areas and spacing values calculated by a DRC checker. To achieve this, I need to integrate the KLayout tool into my workflow. However, I haven't figured out how to export the DRC results as a txt file using KLayout.

Specifically, I need to include the analyzed data in a Python script. Could any experts guide me on how to output the DRC results to a txt file and integrate it with Python? My professor is getting impatient, so I would greatly appreciate your help. Thank you!

I tried using the following code to export the DRC results to a TXT file:

report("MYTECH DRC runset", "MYTECH_DRC.txt")

It successfully generates a DRC.txt file, but the content is somewhat confusing. It includes numbers that seem to represent edge-pairs, possibly coordinates, but I'm not entirely sure what they signify.

Does anyone know how to interpret these results? Are these edge-pairs representing specific violations or geometries? Any guidance on how to parse this data for further use in Python would be greatly appreciated.


Comments

  • The result file is a "report database". The structure is explained here: https://www.klayout.de/rdb_format.html

    For analyzing this structure, there is an API. You can use the klayout Python module to include this into your project.

    The root object is "pya.ReportDatabase" which you can load the report file into. There are a number of methods to traverse the structure of the report database.

    If you are in control of the DRC deck, it is easier however to directly access the error shapes. In case of a simple check those are EdgePair objects. Depending on the nature of the check, these may be other objects as well. Usually they are edges, edge pairs or polygons.

    If you have such an error layer, you can iterate the shapes in it using "each". Here is one example:

    # "shapes" is some DRC layer
    
    # run a space check with 500nm space
    errors = shapes.space(0.5)
    
    # iterate over the error shapes
    errors.each do |ep|
      # ... do something with "ep" (a DEdgePair object)
    end
    

    This marker

    For example renders that DEdgePair object:

    For some details about edge pairs see here: https://www.klayout.de/doc-qt5/programming/geometry_api.html#k_24

    The DEdgePair class is described here: https://www.klayout.de/doc-qt5/code/class_DEdgePair.html

    Matthias

Sign In or Register to comment.