Hi,
I'd like to implement a function which could replace (physically and hierarchicaly) an existing instance.
For exemple if i've an instance refered to AN2D0, i'd like to change the ref. to AN2D0_V1 and have the layout of its instead of previous one.
The flow is:
I read the layout to modify
I check if the new cell does not already exists in the original layout
i rename cells which i've to replace
i read gds of new cell (if needed i.e. the cell is not in the original lay.)
I write the result gds
But, i never obtain any changes i expect. The "rename" method of class "layout" just changes names but does not change the instance.
(the cell renamed is only the same as older one in term of layout, just a different name).
If i try to replace with a cell which already exists in the original GDS, i obtain my new cell named <cell>$1,and the instance is not modified in term of layout.
And as the previous trial, i've only changed the name of master but never changed the master ("refer" the instance to new one) itself.
Could you please help me to understand how to manipulate properly the DB to obtain my function.
I'm not very expert in Object codes and programming in general, i'm a microelectronics engineer with normal knowledge of programming but it is not my real job.
Thanks,
H.a.
Comments
It answers partially, and i can do what i wanted through GUI as explained in the message. But i'm unable to find how to change the parameter "reference" for an instance.
No method in the "instance" or "cell" classes helped me, i suppose i can obtain a pointer on a specific instance and access to the parameter "reference"...
How can i script this, i'm little lost.
Best regards.
Ha
Hi Ha,
well, renaming a cell does what it's supposed to ... It changes the name of the cell. Instances are not made by name, they are made by cell index.
If you want to make instances point to another cell, you have to use code like this
In the next version, you'll be able to simply modify the Instance object delivered by each_instances, i.e. inst.cell_index = new_cell_index.
Allow me one more note: if you load a layout into another to merge the contents of both layouts, you need to make sure, the layouts to not contain cells with the same name or the reader will merge the contents of both cells. That is also true for child cells, so if you load a layout called "AN2D0_V1" in the forth step of your flow and this layout contains a child cell called "VIA", it will be merged with and other cell called "VIA" in the original layout with potential side effects.
To avoid that, you can load the new cell into a separate layout and copy over the cell into the original layout (code for that see http://klayout.de/forum/comments.php?DiscussionID=103&page=1#Item_10 for example). That also gives you a chance to check for identical database units for example.
Matthias
Thanks a lot for yourt quick answer,it will be helpful, i'll fix my code following your advises and i think i've enough inforfomations now to succeed.
Have a good day and congratulations for your job, klayout is a great app.
Best Regards,
Ha.
I'm a little confused with the definition between "cell" and "instance" in klayout.
Is there any reference to explain it?
I can't understand why it is instance replaced in this example.
Thank you.
Regards,
Canny
I know I'm not Matthias :-) But just trying to make his job easier, as he has given us great software and it is the least I can do to return the favor..
Cell is a regular GDS 'cell', that is: it is sort of a container that holds shapes and other instances.
Instance is an instance of that cell. So, it is a cell with some associated information (which parent cell it is to be found inside, which xy translation inside that parent, whether it is rotated or mirrored, ...)
So, you may have this hierarchy in the hierarchy tree on the left of KL's main window: (CAPS names refer to cell names)
Even though "GRANDCHILD1" shows up three times in the list, it is just one cell (but instanced under three different parent cells, perhaps instanced differently (different xy location, different rotation/mirroring) in each CHILDx)
If unclear, or if I answered what was not your question, feel free to reply
David
Thanks, I get the clear image from the reply.
And I kown why it uses instance replace in this example.
I'd appreciate your explanation.
Regards,
Canny
Hi David,
many thanks for taking care of this and me :-)
Matthias