Can DRC be called from a RUBY script ?

edited May 2016 in Ruby Scripting
I have created a variety of nice ruby scripts and pcell implementations - all nicely callable via
new menu items and new menu bar buttons. Now, I had dive deep into DRC, and I have created a nice
deck that fits our need. Does anyone know if and how a DRC file can be called to execute in the
DRC interpreter using a ruby script ? What I really would like to do is have another menu bar button
on the top that brings up a file selection dialog. After selecting the desired .lydrc file, I would
like to invoke the interpreter on it. I guess I dont like to use the menu TOOLS>DCR>MyDRC method :-)

Also, does anyone know which configuration would run DRC the fastest ? I tried to run the same lydrc on the
same GDS using the editor vs viewer mode, but that did not make a difference. Is the standalone feature
expected to run any faster than the viewer or editor ? (yes, I use tiles and threads).

any help would be greatly appreciated.

thanks.

thomas.

Comments

  • edited November -1
    Hi Matthias,
    I have to bombard you with more questions on DRC.

    (1) I cannot get the standalone version to run. is the drc file just a text file
    without the headers of the lydrc file ? Also, what happens to commands that do access
    layout_view ? Are they going to be ignored or do they crash the run ? Does the standalone
    version even run on Win7(64bit) or is this purely a unix thing?

    (2) The individual methods (size, isolated, etc.) produce a boatload of shapes. We are running
    it on a 8-core machine with 24GB of ram. Everything runs ok but at the end of the actions
    it has allocation errors if run on big data sets. The progress bar gets to 100% over
    a few hours, but then sits there forever before the allocation error. I am assuming that
    internally, there is some sort of shape collection into the output going on that outruns
    some limit ? Anything we can do there ?

    (3) to avoid creating soooo many shapes, I tried to add merge methods. Example:

    REoutsSE = RE.outside(SE); REoutsSEM = REoutsSE.merge; REoutsSEM.output(170201, 999, s)

    however, it does not merge anything, the shapes are still plentyfull, and abviously overlapping.
    I can manually merge them when it is done though. Am I doing something wrong here ?

    (4) the method .output appears to empty out the target layer every time the DRC is started, while
    inside a running DRC, it can append shapes in subsequent calls to the same layer. Because we
    cannot run the entire layout at once (allocation crash), I used clip(lv.box) to restrict it.
    However, we would like to move to a new clipped lv and run the same DRC, but without erasing
    the already collected shapes. I did not see any option that could specify that. If it is possible,
    can you point me to it ?

    (5) I tried to write a log file that shows how many shapes are in each violation. But the method .size only seems to work on some methods. There is an error that it needs a polygon layer or something like that.
    I think it has to do with it not being purely related to a single layer. Is there a way to count
    the shapes for the methods produced that do not take the .size ? I can obviously select the shapes
    in the output layer after the runset completes, and then the system counts the shapes for me.

    Thank you !!

    Thomas.
  • edited November -1

    Hi Thomas,

    A DRC script is basically Ruby, but it requires a special environment.

    You can run a DRC script like this:

    # "drc" is a string containing the DRC script
    drc = <<DRC
    # A sample DRC script
    l10 = input(10)
    l1 = input(1)
    (l10 ^ l1).sized(-0.002).output(100, 0)
    DRC
    
    # Execute the DRC script
    eng = DRC::DRCEngine::new
    eng.instance_eval(drc)
    eng._finish
    

    The real implementation is a bit more elaborate to support debugging, but the core code are exactly those three lines.

    Regarding your other questions:

    (1) Standalone version

    "DRC" is a plain text file version without the meta stuff of the "lydrc" XML version. But also without description, menu path etc.
    "klayout -b ..." is the standalone version without any GUI - hence no "File" menu and all. You can run DRC sets in this mode if you explicitly give it input file(s) using the "input" statements. The implicit way is to use the file loaded into the layout view and this won't work in "-b" mode.

    (2+3) Memory

    You are probably expecting too much of a freeware engine here. Real leading edge DRC engines are not cheap and there is a reason for that. KLayout does not come with a hierarchical engine, so memory is likely to become an issue.

    You can try to mitigate the problem by using "tiling" (see "tiles" instruction). This will also help utilizing multiple cores (see "threads").

    (4) Clipping

    Tiling does clipping internally, so this should basically provide a built-in solution for your problem.

    (5) Size

    "size" does polygon sizing. Use layer.data.size to get the number of polygons/edges/edge pairs.

    Matthias

  • edited May 2016

    Thomas,

    It is probably superfluous now that Matthias has given an example of running DRC from Ruby script, but you may want to look at "Quick DRC.lym" which is inside TRT. (Install it, then go to Layout > Quick DRC.)

    That can easily be modified to read DRC script from a .lydrc file rather than from the GUI. Perhaps it helps in some way.

    David

  • edited November -1
    Hi Matthias and David,
    as usual - many thanks for all the help!

    Regarding (4), I meant to ask if there is a way to keep the generated shapes of one DRC run during a
    second run. Right now, the shapes are removed when a new DRC starts. Yes, tiling collects all the shapes
    from all the tiles, but it never finishes on a large layout. We just
    want to test if we can navigate manually and use clip to finish a whole layout.

    Thanks guys !!

    Thomas.
  • edited November -1

    Hi Thomas,

    if you are about to produce data, a flat engine is not the best choice. It will always produce a big amount of data.

    If you combine all your steps into one DRC run and use tiling, the data is kept only for the tiles and this will reduce your memory requirements. If you want to clip, you can use the DRC's "clip" function to reduce the layout window to the desired one.

    Matthias

  • edited November -1
    Hi Matthias,
    I am trying to run the standalone version, but klayout.exe always throws an error about entry point not found.

    the procedure entry point
    ?translate@tl@@YAAEBV?$basic_string$DV?$char_traites@D@stl
    p_std@@V?$allocator@D@2@@stlp@@AEBV23@@Z could
    not be located in the dynamic link library klayout.dll.

    this is even if the drc file is empty. I tried to run

    klayout.exe -b -r mydrc.drc

    Any clue what I could be doing wrong ? I have Win7, 64bit.

    Thanks.

    thomas.
  • edited May 2016

    Hi Thomas,

    Maybe something is wrong with your %PATH%? I guess it locates some old klayout.dll or something like that.

    You can use the dependency walker from http://www.dependencywalker.com/ to check where the system draws the DLL's from.

    You are able to run KLayout from the start menu are you? This basically does nothing else than running klayout.exe. "-b" is just an option for the executable which makes it not access the GUI system. This is not related to the error you see.

    Matthias

  • edited November -1
    Hi Matthias,
    the start menu calls "klayout_app.exe". Would that have anything to do with that ?
    Thomas
  • edited November -1

    Hi Thomas,

    yes, that's what I meant. Maybe "klayout.exe" is left over from an old installation?

    Does "klayout_app.exe" work?

    Matthias

  • edited November -1
    Hi Matthias,
    no errors with klayout_app.exe. It does not complain about anything, but it also does not do anything either.
    Is there a debug capability ? Any text output ?
    The exe just loads into the memory, and then is gone after a second.

    Thanks.

    Thomas.
  • edited November -1
    hi Matthias,
    I had an old Linux machine I tried KLayout on (12.04) and I was
    pleasantly surprised at its memory management and overall snappiness. DRC also ran nicely, similar speed as Win.

    Therefore , I wanted to try on the latest Ubuntu version (16.04). However, there I cannot complete the installation because of the dependence on the obsolete package libruby1.9.3.
    Have you come across this yet ? Any idea on what to do ?

    Thanks.

    Thomas.
  • edited November -1

    Hi Thomas,

    I have not tried Ubuntu 16 myself. I assume that you can build it from source, but I have not tried myself.

    I have only limited computing resources available and cannot support all distributions. I am focusing on Ubuntu 14 currently.

    Matthias

Sign In or Register to comment.