Tagged: cells, instantiate
- This topic has 2 replies, 2 voices, and was last updated 6 years, 4 months ago by
jgnedy.
-
AuthorPosts
-
31 October 2019 at 20:37 #5737
jgnedy
Member1. Is there a way to create temporary cells? For example, if I would like to layout a number of elements and then check the ending cp for calculation purposes only – the cell is not intended to be instantiated. Currently, every cell must be named (or renamed due to naming conflict, which is outputted to the console), and further processing of the many cells seems to add a lot of time.
2. How do you instantiate a cell then immediately flatten it, similar to the way nd.strt is implemented? Otherwise, I end up with a lot of unneeded cells.
Thanks,
Joe
31 October 2019 at 21:35 #5740Ronald
KeymasterDear Joe,
1. Cell creation and placing cells (the Nazca “put” method) in a layout are fundamentally two separate things and actually a core Nazca working principle. You can create a complete layout in a cell hierarchy, and as long as you do not instantiate the root cell of that hierarchy in a cell that is exported, it won’t be part of the exported layout. You can access all that cell’s information though and everything is calculated inside that root cell without ever putting it.
The cell renaming warning can always be resolved. Either by using the @hashme decorator, see https://nazca-design.org/hashme/ , or by assigning a cell to a variable instead of regenerating it multiple times in a function call.
Another way to reuse the cell name is to delete it from the cellnames dictionary, which also gets rid of the cell itself (via Python garbage collection if you don’t keep a reference to an object). I think that what you describe you want to do is to generate a cell definition multiple times with the same name, each time read something from it and delete it. Something like this?:
import nazca as nd def give_me_a_cell(i): with nd.Cell('name') as C: # stuff in the cell pass return C for i in range(100): A = give_me_a_cell(i=i) # read out stuff from cell A del nd.cfg.cellnames['name']2.
nd.Cell(instantiate=False)makes instances of this cell resolve in their parent(s) upon export. Interconnects, mask elements (like nd.strt) and stubs have instantiate=False by default. New user cells have instantiate=True by default.Ronald
25 November 2019 at 20:48 #5855jgnedy
MemberThanks! I was confused as to the purpose of the instantiate argument. I am now using both instantiate and nd.cfg.cellnames.
-
AuthorPosts
- You must be logged in to reply to this topic.