Some questions about writing DRC rules

Hi all, I am a postgraduate student, I am trying to write some rules, and I have some questions.

First, I wanna check the width, but I also wanna ensure the width is not affected by some polygons with the wrong angle, What should I do?

This is what I done , What should I add to achieve a more complete width check?

min_aa_w = 500.nm
r_aa_w = aa.width(min_aa_w )
r_aa_w.output("AA_W: AAwidth < 0.5 µm")

I used calibre for DRC inspection before. I also want to know what is the biggest difference between Klayout and Calibre for DRC?

Second,How to write a DRC script when checking the distance between different nets?
The specific requirement is Space between DNW and NW at different nets
I just write like this, but I do not know how to write "different net"

min_DNW__NW_s = 300.nm

r__DNW__NW_s = dnw.separation(nw, min_DNW__NW_s )
r__DNW__NW_s.output("DNW__NW_s: space to nw distance < #{'%.12g' % min_DNW__NW_s } µm")

Thanks in advance!

Best wishes!


  • Ok , i know how to write the rules to check the angle now, but I still confused on different nets problem..

  • @Shida I'm sorry, but KLayout currently can't check distances between different nets. Thats a development branch which is not yet addressed.

    Please don't expect you can easily substitute Calibre by KLayout. Mentor doesn't take the money for no reason.


  • @Matthias
    Thank for you reply!
    Ok, That makes sense..
    Where can I know the difference between Klayout and Calibre? I am very curious.
    Maybe the GDS design I made is not so complicated. I compared the two software myself, and I began to think that there was no difference between Klayout and Calibre.
    I really respect you very much. I think klayout really helps a lot of people who can't afford calibre to learn!
    Best wishes!


  • By the way,
    I am trying to check some polygons with 45-degree edge.

    min_edge_aa_fourfive = 0.45um
    edge_aa_fourfive = aa.with_angle(
    r_aa_width_fourfive = edge_aa_fourfive.width(min_edge_aa_fourfive )
    r_aa_width_fourfive .output("AA_W with 45 degree : AAwidth 45 degree < 0.45 µm")

    But it does not work

    Thanks in advance!

  • You can find many DRC examples here :

    For your 45 degree DRC :

    edge_aa_fourfive = aa.with_angle(0 .. 45)
    edge_aa_fourfive.output("AA_W with 45 degree : AAwidth 45 degree < 0.45 µm")

    or more simple :

    aa.with_angle(0 .. 45).output("AA_W with 45 degree : AAwidth 45 degree < 0.45 µm")


  • Thanks, @laurent_c , I still confused...
    In your code, it selects the 45 degrees, but what I wanna do is to check the width of 45 degrees of aa
    how can I do that?

  • Sorry, here is the way to check it :

    min_edge_aa_fourfive = 0.45um
    ((aa.edges.with_angle("AA_W with 45 degree : AAwidth 45 degree < 0.45 µm")


  • Thanks! @laurent_c
    You are so nice! It helps me a lot.

    I have already read all the code you upload in github, it is very Conciseness but useful, and I learn a lot!
    Wish you have a good day.

  • edited April 2021

    Hi @Matthias,

    Out of interest on one thing you said:

    KLayout currently can't check distances between different nets. Thats a development branch which is not yet addressed.

    ...which branch are you referring to, and do you currently have a specific release version in mind which should have this feature?

    I noticed for the upcoming 0.27 release, you noted the following in the Changelog

    NO "connected" feature yet. Sorry. Had to drop it to finish this release.

    So I'm not expecting it in 0.27, or is this a different feature?

    Thanks again for this great tool!

  • Just a thought B)
    You could use the netracer to save the needed nets to another GDS file
    then run your DRC against the traced nets

  • edited April 2021

    @tagger5896 : I imagine this to be feasible for layouts with a small number of nets. Say we have 3 nets, A, B and C. For the checks Shida referred to in the initial post - namely, checking the distance between different nets on layer NW, for example - I think this would mean implementing the following steps:

    1. Trace net A and collect all shapes on layer NW. Move these shapes to a different layer NWs (s for same-net).
    2. Apply the NW-same-net DRC rule to the NWs layer and
    3. apply the NW-different-net rule between layers NWs (net A) and NW (other nets).
    4. Move all NWs shapes back to NW and repeat the process for nets B and C.

    Is there a better way?

  • @cgelinek_radlogic

    There is always a way , some how, just have to think it through .
    Your concept is there .
    As Matthias has pointed out and it's true Klayout DRC is not Caliber

    Unfortunately there is not as I am aware an append option to the layout.write function.
    If so you could parse through the nets, with the nettrace then save as GDS file then run
    run the DRC .
    I have been down this rabbit hole in the past .
    I have code that extracts a net/path based on text label and saves to the GDS file.
    And am currently wrapping my head around how to solve this, another rabbit hole.

  • Could you save the traced-nets to a temp layout DB and then import to (a copy of) the original? Maybe use some vacant derived layer for the probed net to keep logic neat?
  • @dick_freebird

    yes that's another way .

  • Dear all,

    maybe a need to shed some light on that:

    The "connected" feature basically is quite simple if you can tag polygons with their net ID. You only need to check distances between polygons with a different net ID to implement CONNECTED.

    However, it's not trivial in the hierarchical case. There is not a single net ID. Instead, what may be different nets locally in a cell may be a single net when these nets are connected outside the cell. Furthermore, the same cell may be different nets in one instance and connected nets in another. Hence the cell instances need to be treated differently.

    The whole topic is related to merging. KLayout first merges all polygons before it does a space (or other) check. That's how isolated, notch and space checks are differentiated: "isolated" operates on separated (post-merge) polygons, "notch" operates on a single polygon and "space" on both. This already is close to "connected" (notch) or "not connected" (isolated), but without the connectivity across multiple layers.

    In that sense, net formation is just an extension of the merging step. Or: the merging step is a special case of connecting nets. As merging is a weak spot in the DRC implementation, my plan is to improve merge implementation following this scheme while introducing CONNECTED. But this is a major redesign of the DRC internals and it's not going to happen quickly.


Sign In or Register to comment.