Hi,
Great tool by the way, very fast and reliable.
I want to use the clip utility to extract a small section of the design for further analysis. When I tried this on a small design, the "clipped" design that I saved out is 200x bigger than the source gds, despite only representing about 5% of the design.
Any ideas why this is?
Comments
It seems that if I flatten the hierarchy before running clip, then I see this issue. However, if I don't flatten the hierarchy then the resulting clipped gds is still bigger, but only by a fraction of a %, not 200x.
Is klayout saving the original gds + the clipped section?
regards,
Rich
Hi Rich,
yes, you are right, by default KLayout is saving both the clip and the original.
What KLayout actually does is do create a new top cell (by default called CLIP) containing the clip. The original top cell will still exist and show the whole layout (that way, another clip can still be made). KLayout will do the clip hierarchically by creating cell variants with just the subset required. Where a cell is completely inside the clip region, the original cell is used.
In the cell tree you will find the clip cell and the original one. Both are top cells, i.e. appear as root level nodes in the tree.
You can save just the clip by selecting the clip cell in the cell tree and choose "Save Current Cell As" from the context menu (right mouse click). Then just this cell is saved which is usually just a fraction of the original layout.
If you want a flat clip, I would recommend to flatten just the clip cell (after the clip) using "Flatten" from the context menu. That produces a much smaller data volume as you have noticed ... :-)
Best regards,
Matthias
Thanks for your help and advice, that's exactly what I needed. I was only using the "show current cell as top" not "save current cell as".
Best regards,
Rich
I need to modify the clip tool so that it automatically cuts the whole gds into various smaller square (of desired size) gds and save them as separate gds files. Can you please guide me on how to proceed for this ?
Hi,
I would suggest to create a ruby script that does that - however, right now, the clip function is not provided as a ruby method and it's pretty tedious to emulate it. I'll consider that as a suggestion for the next release (which hopefully will come soon).
Right now, you would have to modify the code - the place to look for is layClipDialog.cc, around line 200. The basic function is db::clip_layout which does the work. It already provides a way to create multiple clips in separate cells. You'll need to save the cells in separate files using db::Writer (dbWriter.h) and provide a individual cell in the db::SaveLayoutOptions (method add_cell).
There is also a manual solution. The clip tool already allows to build multiple clips into separate cells. A separate cell is not the same than a separate GDS file, but maybe you flow allows to use the same file with a different top cell, so you can extract the clip from a single GDS file, provided each clip is contained in it's own cell.
The manual procedure is that: create a regular arrangement of boxes covering your layout on a new layer. I did so by creating a new cell with a single box and changing the boxes properties to (0,0) for the lower left and (100,100) for the upper right corner for example. This box now represents one clip tile. You can create a regular arrangement of boxes easily by placing a array instance of that cell over your layout: place an instance and check the "array instance" box, enter the desired box size as displacement vectors - i.e. (0,100) and (100,0).
Now your layout is prepared to be clipped into pieces. Just select the clip tool and choose "Shapes on layer .." for the clip box specification. Enter the layer that you placed the boxes on previously.
After having ran the clip tool, you will see a new cell called "CLIP" containing a sub-hierarchy of individual clips. If the original cell for called "TOP" for example, the clip cells will be called "TOP$1" for the lower left clip, "TOP$2" for the next clip right of that one and so on.
Maybe this information is helpful.
Best regards,
Matthias
Thanks a lot and I tried the manual selection method, its pretty useful. I was also interested in using Klayout in a batch ( non-interactive) mode so that the cutting of gds can be done through a script. Can you suggest me ways for this ?
Regards
Acku
Hi Acku,
With the next release (0.21) it will be possible to write a ruby script that creates the desired clips and saves them to individual GDS files using the integrated ruby interpreter (RBA).
This will be far easier than modifying the C++ code and more flexible.
This is basically how the script might look like in upcoming version 0.21:
Best regards,
Matthias
The code above would be very helpful to me in writing ruby scripts.
Thanks a lot
Regards
Acku
I saw in release notes that version 0.21.1 is out, so is the clip method now available through a ruby method ?
Hi,
Sorry for not mentioning that here. Yes it is. I changed to code above so it is a full Ruby module. Copy the code into some file, i.e. "multiclip.rbm" and run KLayout (version 0.21.1) like this:
If you copy multiclip.rbm to the installation folder on Windows or to a folder pointed to be $KLAYOUTPATH on Linux, it will be loaded automatically without needing the -rm option.
Please adapt the script as you require. It provides a new entry in the toolsbar called "Multiclip", which creates the clips.
For all users familiar with the RBA scheme, this script also employs a new feature (events) which simplify binding of code to actions.
Best regards,
Matthias
sure i'll try to do it. Probably I want to use this multi clip feature in a non interactive mode so that things could be automated. So as it is a ruby method, I can do some experiments :)
Thanks
Acku
Updating these instructions, thanks for the nice clipping utility Matthias (please correct any mistakes here).
If you have saved a small clip it should be done in less than a second.
HTH,
Rajan