Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

want to generate script to open up gds file, show as new top, and run drcs

new to klayout scripting
I am not finding much on how to generate a script to open klayout and a gds file from a command line and run a script
the script will need to change the new top to a certain file, it will be known before running the script and can be updated or passed into the script before running. I am not too concerned about that, but do not know how to "show the new top"
once the new top if set, I need to run drcs.
then exit klayout or keep it open, do not care at this point


  • Hi John,

    how about running the DRC in a separate step, i.e.

    klayout -b -r your.drc
    # or:
    strmrun -r your.drc

    And afterwards opening the layout plus the report:

    klayout your.gds -m your.lyrdb

    Here is a sample for "your.drc":

    report("My DRC", "your.lyrdb")
    l1 = input(1, 0)
    l1.width(0.5).output("Width < 0.5")

    If you don't want to put fixed paths in the scripts, use variables:

    klayout -b -r your.drc -rd input_file=your.gds -rd db_file=your.drc

    with this DRC script:

    report("My DRC", $db_file)
    l1 = input(1, 0)
    l1.width(0.5).output("Width < 0.5")


  • after much data manipulation on my end I have something I can go forward with. thanks. one thing is I am running this via windows and used c:\ when klayout expected c:/ forward slash like unix.

    what I think I will do is generate the bat file to run and open klayout -e gds file -r lydrc file and add a customized header for the drc like cat it on to define my source top cell and report file. ie I believe I will have to generate a specialized drc file for each gds file anyway.

    thanks and I am sure I will need more help in the future

  • edited November 29


    KLayout also accepts backslashes for file paths, but when you enter them in a script, you have to be careful to use a double-backslash, as Ruby uses it as escape character in double-quoted strings.


    report("My DRC", "c:\\users\\matthias\\test.gds")

    On the command line (in -rd variable=c:\users\matthias\test.gds) you should be able to use backlash characters as usual.


  • ok, i will consider that. but i am good since it appears to work and do not want to muck anything up right now.

    But I am still having issues with top_cell, the drcs run on the cell I list as top_cell and gives results as expected but it reports to the output file the original top cell thus renders the file useless unless modified to the top cell I specify. ie if I open the gds file and go to step through drcs it resets to topcellklayoutchooses instead of the top cell I want mytopcell

    in lydrc file
    source ("Z:/1234.gds", "mytopcell")

    in output stored text file

    while running the script it keeps topcellklayoutchooses highlighted instead of changing the physical top cell.

    I can and will do so modify my output file to the mytopcell, but it would have been nice to find a way to physically change the top cell to mytopcell before running drcs.

  • Hi,

    you can chose among different options when you use the marker browser (that's the "context"). Push the "Configure" button to edit the options. I guess if you choose "current cell" it won't switch the cell.

    I agree that writing the original top cell into the .lyrdb file does not make a lot of sense. Maybe there are internal reasons for this. I'll need to check this. Thanks for giving that feedback.



Sign In or Register to comment.