Hi Matthias,
could you help me with loading of yout marker database xlm file into KLayout?
I have gds with a single cell, and some xml file containing markers for that cell.
I want to add menu for some ruby script and then allow user to load markers with a single menu click.
Is that possible ?
Or may be there is some other means to load some custom geometry to display over existing layout ? (again, "in a single click")
Main goal is to display DRC and LVS errors, and due to performance limitation it would be nice to use ruby only as a pointing system, i.e. use ruby like "hey, KLayout, here is the big file with polygons, please load it and display as markers"
ps. I did some tests using c++ and ruby to load that data into KLayout. Ruby is 10 times slower :(
Comments
Hi Yaroslav,
is the XML file already in the format of KLayout's report database?
Then the solution is that:
Popping up the marker browser is not straightforward since the is no function for that yet. But you can trigger the menu action to open the marker browser:
BTW: I bet that Ruby is even 100x slower than C++. Ruby, like Python for example, is a dynamic language and comes with a lot of high level concepts quite different from C++. That generates some overhead but adopting Ruby thinking, you can write lean and efficient code as well. I'd never use Ruby for bulk data processing and Ruby was never meant for that. It's intended as a scripting solution to provide the "glue" between different applications which itself are coded efficiently in C++. Like "rdb.load" above and the menu function.
Regards,
Matthias
Now I can select markers from Tools->Marker Browser->Marker Database Browser dialog
But I want something different: I want not only to load markers, but also to display them instantly (just after loading, without showing Marker Database Browser dialog).
Something like
lv = RBA::Application::instance.main_window.current_view
rdb_index = lv.create_rdb("database_name")
rdb = lv.rdb(rdb_index)
rdb.load("your_xml_file")
RBA::Application::instance.main_window.current_view.show_markers()
ps. I am new with Ruby, but I have some exp with TCL and Perl, and for bulk processing I was using dll/so libraries containing all necessary routines. Actually I have now such library for KLayout scripting, I can load all my data (polygons) pretty fast, but I do not know how to pass data to the KLayout in a fast way. Passing data through the ruby polygon-by-polygon is sloooooow :(
I want something like "pass to KLayout a single array of polygons", so ruby will just send a single pointer - easy job for Ruby ;)
Hi,
if you want to display layout information as overlay over an existing layout, maybe you should consider writing a layout file from your data and displaying that in the same view than the original layout. That is by far the most efficient way and the ruby code is just a few lines that load your overlay layout into the same panel and maybe prepare some layer views for displaying the information properly.
If you don't want to bother with the binary GDS or OASIS format, you can write the text version of GDS. That creates a little overhead but still is quite efficient when reading.
Regarding interfacing of so/dll with KLayout: it is possible to write so/dll's and load them into KLayout at runtime. That provides a way to directly interface with KLayout's core and every functionality inside. But this means you have to compile your DLL's against the KLayout excutable using C++ which in general is not straightforward.
Regards,
Matthias
looks like I do not have any more choice - for small markers use Ruby, for large ones - GDS/OASIS.
Could you please direct me to the sample for loading of GDS into the same pane ?
Hi Yaroslav,
well, you basically have much more choices. KLayout is open source, so you could create you own interfaces. It is also possible to write C++ plugins in the form of shared objects/DLL which interface directly with the core code. That will be the most efficient way, but for displaying a huge number of markers (i.e. above a million or so), the only efficient way is to load a layout atop of an existing one.
Here is a code which does that:
The file can be GDS/Text which basically looks like this:
The "XY" records inside the BOUNDARY element list the vertices of your polygon. To represent multiple polygons, produce multiple BOUNDARY .. ENDEL blocks.
Regards,
Matthias
thanks again !
I think that with binary GDS it will be even faster )
But also I am curious about dll/so plugin usage: is it possible to load shared object through the Ruby interface or I definitely have to recompile KLayout, to add dll/so loading routines ?
Hallo,
you can load a shared object using the -p command line option. Such shared objects can register new functions inside KLayout. Many internal functions are implemented through interfaces that don't require recompilation. For example, it is possible to install readers for other layout formats that way. But such libraries have to be built with the same compiler than the original executable and they required some knowledge about the internal structure of KLayout (which of course is accessible since the source code is available).
That is a way quite different from Ruby extensions. This will give you access to almost every internal functionality. But that solution is not portable and it's likely that the internal API will change in new releases.
Hence I think the most efficient (and most portable) solution is to use layout data as a transfer format, implement bulk functionality in an external DLL/SO (or executable) and use Ruby code to glue the applications together (like discussed before).
Allow me one additional note: the API mechanism built into KLayout is not restricted to Ruby. It uses an abstract layer that could be interfaced to other scripting languages and even native C++ within another kind of DLL/SO. That would be a solution to mitigate Ruby's performance issues. I can't promise a time frame but basically that is my preferred solution for the future.
Regards,
Matthias
Thanks again for the thorough explanation !