Get the output GDS with same hierarchy of original GDS

edited May 20 in KLayout Support

I would like to generate contact with size up and add 0.02 spacing between contact-to-contact (keep the same hierarchy of original GDS), my code as below:
The problem is the output is in flatten mode. How can I get the output with the same hierarchy of original GDS. Thanks.

contact size: 0.14 um
contact space: 0.16 um

contact size: 0.16 um
contact space: 0.18 um

source ("ori.gds", "TOP")
target ("out.gds")

cont = input(1,0)
diffusion = input(2,0)

cont_size = 0.16
cont_space = 0.18
cont_size_half = cont_size/2

cheat ("*") {
cont_marged = cont.sized(cont_size_half ).clean                          # size and marge all contact
cont_find_mid = cont_marged .middle(as_dots)                            # find the mid point of layer
cont_find_mid_ex = cont_find_mid .extents(cont_size_half )       # layer sizing
cont_2_cont_space = cont_find_mid_ex .sized(cont_space +cont_size_half )
cont_gen_lc = cont_2_cont_space.extent_refs(:left_center).sized(cont_size_half -1.dbu).inside(cont_marged)

cont_find_mid_ex .output(1,0)
cont_gen_lc .output(1,0)


  • edited May 18


    Please format your code using Markdown ... a line with three backticks before and after your code.

    By "marged" you mean "merged"?

    The "extents" for computing "cont_find_mid_ex" from a dot-like layer (edge layer) isn't deep-enabled yet, hence this problem (I created a ticket for this:

    You can use this code instead:

    source("ori.gds", "TOP")
    cont = input(1,0)
    diffusion = input(2,0)
    cont_size = 0.16
    cont_space = 0.18
    cont_size_half = cont_size/2
    cont_find_mid_ex = nil
    cont_gen_lc = nil
    cheat("*") {
      cont_merged = cont.sized(cont_size_half) # size and merged all contact
      cont_find_mid_ex = cont_merged.middle.sized(cont_size_half - 1.dbu) # find the mid point of layer
      cont_2_cont_space = cont_find_mid_ex.sized(cont_space + cont_size_half)
      cont_gen_lc = cont_2_cont_space.extent_refs(:left_center).sized(cont_size_half -1.dbu).inside(cont_merged)

    Note that by declaring the layer variable before the cheat-block makes it possible to export it from there. Don't put "output" inside "cheat".

    But I don't get how the code creates spaced contacts. There must be something I don't know about your layout.


  • Many thanks Matthias. You're always give me a hand.
    The contact space created here:
    cont_2_cont_space = cont_find_mid_ex.sized(cont_space+ cont_size_half) <-- cont_space

Sign In or Register to comment.