DRC: width error and reading .lyp files

I'm working on a DRC script and just have some questions.
Is there a way to integrate the foundry technologies (.lyp file) into the DRC script so that I don't have to actually have the gds open and click the technologies on the KLayout main screen. I also tried to use the source() function to specify which gds to run the DRC on but it has errors because there are multiple top cells.

As well as this, in doing a width check using
pad_width = layer.width(distance_min, projection)
I get this error shown but I'm not sure why there is an error from both sides at 90 degrees when it should be just looking straight across the pad.

Any help is welcome.
Thanks a lot.


  • @Tristian I'm afraid I don't understand the first question. It's possible to integrate DRC into a technology so you can run a technology-specific DRC, but you want the DRC to trigger a technology change?

    When you have multiple cells in a layout file, you need to tell "source" which cell to use:

    source("layout.gds", "CELL1")

    The width check should ignore 90 degree corners, specifically for "projection" metrics. I don't see any general issue in a small example I made myself, so could you please check if this isn't some other problem? Or if necessary, provide a testcase?



  • @Matthias apologies for the severally delayed response.
    An example is like the one shown below.
    Here I just made a Path that is horizontal, then one that is at an angle, then a Polygon that is also at an angle. All in the same layer.
    I am then trying to check the width of this to see if it less than 1um for example. If you know of a way to ignore these outputs that would be great.

    layer1 = input(1, 0)
    layer1.width(1.um, projection).output('error')


  • edited October 2021

    @Tristian When you rotate a path like this, the angles are never exactly 90 degree due to rounding of the corners to database units. KLayout will only check "opposing corners" which form edge pairs facing each other. The angle included by such edges is less than 90 degree. That's why the check hits for those corners for which rounding makes the corner into "opposing".

    The key to the solution is "angle_limit". This lets you set the limit below which KLayout assumes edges to form "opposing" edge pairs:

    layer1.width(1.um, projection, angle_limit(89.5)).output('error')

    which means only edges with an angle less than 89.5 degree (I made up this value as "somewhat smaller than 90 degree") are checked:


  • @Matthias thank you so much for this, it works how I want it!

    I do have one final thing that I need help with if you don't mind me asking.

    One of my last DRC rules is to check the orientation of a polygon. For this, the best solution that I have come up with is by checking the angle of the edges of the polygons to see if they have an angle that is not equal to 0 degrees +/- a small value. The issue I'm having is that although the overall polygon is facing in the x direction, the edges that are vertical show up as errors. Do you think there is a way to check the edges of a polygon, find the longest edge and then check the orientation of this edge to see if it is in the x direction, and if not, it should be output as an error.

    Greatly appreciated,

  • @Tristian The solution strongly depends how you define "orientation" and how your polygons are defined. If the bounding box is a good approximation, "with_bbox_height" or "with_bbox_width" may be useful for differentiating "tall" vs. "flat" shapes.

Sign In or Register to comment.