Home Forums Nazca MMI cell

Viewing 2 posts - 1 through 2 (of 2 total)
• Author
Posts
• #5403
JFaneca
Participant

is based in Exeter

Dear Nazca design creators,

I have a doubt, I am creating two different building blocks, two cells with their pins, how can I merge the two different cells using the pin of one and the pin of the other one.

Find attached the script. I know is not really difficult, but i am struggling with the notation.

Thanks for considering the email.

Joaquin

```import nazca as nd
import nazca.geometries as geom

L_mmi=1000;
W_mmi=1000;
W_arm=100;
L_arm=200;

with nd.Cell('MMI') as mmi1x2:
base = geom.box(length=L_mmi,width=W_mmi)
BASE = nd.Polygon(layer=3, points=base)
BASE.put()
nd.Pin('a0').put(0,0,180)
nd.Pin('b0').put(L_mmi,W_mmi/3,0)
nd.Pin('c0').put(L_mmi,-W_mmi/3,0)
nd.put_stub()

with nd.Cell('MMB') as mmb:
arm = geom.box(length=L_arm,width=W_arm)
ARM = nd.Polygon(layer=3, points=arm)
ARM.put()
nd.Pin('d0').put(0,0,180)
nd.Pin('e0').put(L_arm,0,180)

mmi1x2.put()
mmb.put(mmi1x2.pin['a0'])

nd.export_gds(filename='mmi.gds')
```
#5410
Ronald
Keymaster

Dear Joaquin,

This touches upon the core idea behind Nazca: “Make a cell, put a cell”.

Creating a cell and putting it zero or more times in a layout (in other words: instantiating it zero or more times in a parent cell) are two distinct activities.

As soon as you finish creating a cell, you can by definition not add anything new to it anymore; The cell is closed. It may feel like a restriction, but actually it is not and it guarantees a consistent cell hierarchy. Hence, anything you put in a cell just has to be done before it is closed.

Your example attempts to instantiate cell ‘mmb’ to a pin inside the already closed cell ‘mmi1x2’, i.e. it tries to add ‘mmb’ into ‘mmi1x2’:

`mmb.put(mmi1x2.pin['a0'])`

However, you don’t want to connect ‘mmb’ to the cell ‘mmi1x2’ but to the ‘copy’ of mmi1x2, i.e. its instance. More precise ‘mmi1x2().put()’ instantiates cell ‘mmi1x2’ in the “active cell”, i.e the open cell you are constructing. Note that you are always in an active layout cell one way or another, e.g. Nazca automatically creates a cell named ‘nazca’ for you at the start.

Solution to connect mmb to mmi1x2:

``````A = mmi1x2.put()
mmb.put(A.pin['a0'])``````

The put() method returns a reference to the instance, here assigned to ‘A’, of the cell it puts, here ‘mmi1x2’. It’s like using a stamp to make prints: ‘mmi1x2’ is the stamp and ‘A’ is its print in the layout. You can reuse stamp ‘mmi1x2’ as much as you like, and each print it creates is an instance (a reference to the stamp).

In order to connect to the print/instance, or any number of prints/instances in scope in the active cell, just keep a reference of it when putting it. It looks something like this:

``````
A = mmi1x2.put(0)    # place mmi1x2 at x=0 and call the resulting instance A
B = mmi1x2.put(100)  # place a 2nd mmi1x2 at x=100 and call the resulting instance B
mmb.put(A.pin['a0']) # place mmb connected pin 'a0' of A
mmb.put(A.pin['b0']) # place a 2nd mmb connected pin 'b0' of A
mmb.put(B.pin['a0']) # place a 3rd mmb connected to pin 'a0' of B``````

Nazca gives the following message when connecting to closed cell
(which is a compressed version of the story above):

Exception: You are trying to connect to a closed Cell object:
The construction found is similar to
\$ foo.put(cell.pin[‘a0’])
Connect not to the Cell but to an instance of the cell instead
\$ instance = cell.put()
\$ foo.put(instance.pin[‘a0’])

Ronald

Viewing 2 posts - 1 through 2 (of 2 total)
• You must be logged in to reply to this topic.