Running DRC on a file with multiple top cells

edited November 2017 in Ruby Scripting
Hello all,

I'm trying to write a very simple DRC check and run it in batch mode.
It is working just fine , but for cases that my gds file have multiple top cells in it.
Actually I know the name of the top cell I need to check, and tried to select it writing :


, but the DRC continues to fail with error message:
klayout -b -rd gds_file=my.gds -rd top_cell=mytop -r try.drc
*** ERROR: In try.drc: The layout has multiple top cells in Layout::top_cell
*** ERROR: The layout has multiple top cells in Layout::top_cell in MacroInterpreter::execute
try.drc:1:in `execute_drc'
:/built-in-macros/drc_interpreters.lym:94:in `execute'

It must be something very stupid I'm doing wrong, but still I could not figure out what is wrong.

Thanks in advance,


  • edited November 2017

    Hi Yulia,

    the solution is actually very simple:

    source($gds_file, $top_cell)

    should do the job.


  • edited 11:24PM
    Hi Mattias,

    Thank you very much. Did not think it's that simple

  • Hi @Matthias ,

    We tried to use the command above but we got the following:

    ERROR: In my.drc: 'connect': The layout has multiple top cells in Layout::top_cell
    ERROR: 'connect': The layout has multiple top cells in Layout::top_cell in Executable::execute
      my.drc:171:in `execute'
      :/built-in-macros/drc_interpreters.lym:27:in `instance_eval'
      :/built-in-macros/drc_interpreters.lym:27:in `execute'

    Not sure why?


  • Might start off with inspecting the (presumably) loaded DB
    and see whether it still contains multiple topcells.

    And be sure that those $args had predefined values that
    work; were there preceding error yips, about that?

  • Hi @atork,

    are you using the command properly?

    Here is an example taken from KLayout's test data repo:

    # Hierarchical antenna check
    source($drc_test_source, $drc_test_top)
    diff = input(2, 0)
    poly = input(3, 0)
    contact = input(4, 0)
    poly_cont = input(5, 0)
    metal1 = input(6, 0)
    via1 = input(7, 0)
    metal2 = input(8, 0)
    gate = diff & poly
    connect(gate, poly)
    connect(poly, poly_cont)
    connect(poly_cont, metal1)
    connect(metal1, via1)
    connect(via1, metal2)
    antenna_check(gate, metal2, 1.0).output(101)
    antenna_check(gate, metal2, 5.0).output(105)
    antenna_check(gate, metal2, 10.0).output(110)
    antenna_check(gate, metal2, 50.0).output(150)

    I run it with:

    klayout -b -r testdata/drc/drcSimpleTests_6.drc -rd drc_test_source=input.gds -rd drc_test_top=TOPCELL -rd drc_test_target=output.gds

    I tried with some input.gds containing other top cells beside "TOPCELL" and this sample works fine with me.


  • Hi @Matthias ,

    I'm still seeing issues with my layout. Is it possible that you share the example gds file that you are using above. I'll try to duplicate the issue for you on your design.


  • I have attached "input.gds" I used in the previous sample's test run.


Sign In or Register to comment.