DRC: Measure distance corner to edge

edited August 29 in KLayout Support

Hello,

I need to set up a DRC check where one layer is inside another, and then one of the outer edges can be closer than the other edge of the corner.
To solve that, I thought on measuring the distance of each corner to the outer edges and only 1 shorter distance is to be allowed per corner.
That requires to measure the distance between corners and edges.

As per docs, corner(as_dots) generate a list of dot_like edges (I guess very short/infinitesimal edges), and primary.separation(secondary,value) can measure the separations between 2 sets of edges.

When assembling everything however, no separation returns an error (error count is 0 always, no matter what value is set):

M1.edges.separation(V1.corners(as_dots),value.um)

The usage of V1.corners(as_dots).raw or V1.raw.corners(as_dots) didn't help either.

I checked for M1.edges.separation(V1.edges,1.um) and it works as expected, so I'm wondering what's the way to measure point to edge distances.

Thank you.

Gerard

Comments

  • Hi @Tabra,

    A picture, the complete script and a sample would be extremely helpful to understand what you're trying to say.

    In general, I guess that dots don't count as real edges. I will check this.

    But you don't need corners, maybe. If I understand you correctly, you may be able to select shapes with more than two violations this way:

    enc_less_than_1um = m1.enclosing(v1, 1.um)
    # selects V1 with two or more error markers touching it
    errors = v1.interacting(enc_less_than_1um.edges, 2)
    

    As you are speaking of M1 and V1 maybe you can consider using the rectangle filters - i.e. "one_side_allowed".

    Matthias

  • edited September 1

    Hi @Matthias,

    Thank you for the reply.

    The brief explanation of my use case was just to give some context on how I came across the need to measure point-edge distances.
    Essentially, our foundry has a minimum metal-via perimeter margin, but at narrow metal ends this metal-via margin has to be a bit bigger due to rounding of corners upon fabrication. The thing is, the foundry considers all corners as potential ends, so the following is a valid design:

    Where absolute minimum metal-via would be 0.01, the end metal-via 0.06, and inter-via margin 0.26.

    As you can see, we're using polygons as vias (unconventional design requirement for our needs). But regardless, an end via can have up to 1 OR 2 violations of the rule if just the edge is checked: For the left-most edge, compare the 1 "violation" at top end against 2 "violations" at bottom end. A corner check wouldn't have this issue while being the most straightforward approach, and that's why I thought it'd be the solution.

    Lastly, having the capability of point-edge distance measurement would open a whole new level of depth for custom DRCs, specially for all-angle+narrow designs.

    Gerard

  • Hi Gerard,

    I have created a ticket to enable the corner-to-edge measurements. It's probably not difficult. The main reason it's not working is that points lack direction information, hence the edge relation cannot be identified as "opposite".

    The ticket is here: https://github.com/KLayout/klayout/issues/2141

    Matthias

  • Hi Matthias,

    That's awesome news, thanks!

    Gerard

  • Hello,

    I tested the script with the new 0.30.4 update.
    The underlying code now works, like for example:

    M1.edges.enclosing(V1.corners(as_dots), 0.06.um)
    

    But as specified in docs, this is still now available to be used with Universal "drc()" function since only polygons are allowed, and has limited filtering potential. Until then, a workaround would be:

    V1.corners.drc((enclosed(M1) < (0.06.um-1.dbu)).count > 1)
    

    It's not perfect, as some diagonal edges may wrongly flag it as violation, but for rectilinear cases it should work.

    Thank you very much, and for the update too!

    Gerard

Sign In or Register to comment.