Home Forums Nazca How to pass down pcell arguments in the replaceCells function ? Reply To: How to pass down pcell arguments in the replaceCells function ?


Dear Cecil,

Your approach is correct. What is missing is that you need to fill the cell’s ‘parameter’ attribute with a dict like {parametername : value}. The parametername is expressed as a string.

This parameter attribute is automatically filled by the @hashme decorator, which I added in the example below to your ‘blackbox’ in combination with an autobbox=True. To give the autobbox dimension in your case with only two pins, I added the userbbox. The autobbox finds the boundaries and calls the correct put_boundingbox() function internally, so that explicit call can be deleted.

In all it adds a boundingbox and all the blackbox function parameters as annotation to the gds. Those parameters are read back in during the pcell replacement to generate the parametric white cell. I also added some keywords to your calls to make the code more robust. Additionally, I added version info to your cell via the ‘version’ attribute of the cell, which adds a extra information to the black cell, again as annotation.

This pcell flow can be used for IP protection and there are several more elements to this flow to make this pcell IP-replacement work in basically any situation. If you know your pcell names you can simply look for them in the gds, but Nazca can also detect “unknown” pcells, as well as tempering with black boxes to make the whole process 100% reliable. All these features require a somewhat longer tutorial.

import nazca as nd
version = {'owner': 'cecil'}

def some_calculation(offset, radius):
    return 2.0 + offset + 0.5*radius

def blackbox(width_wg, offset, radius):
    with nd.Cell() as C:
        C.version = version
        length = some_calculation(offset, radius)
        C.userbbox = [(0, -1.5*offset), (length, -1.5*offset), (length, 1.5*offset), (0, 1.5*offset)]
        C.autobbox = True
        nd.Pin('a0').put(0, 0, 180)
        nd.Pin('b0').put(length, offset)
    return C

def white_pcell(width_wg=2, offset=100, radius=500, layer=1):
    with nd.Cell(name='white_pcell', cnt=True) as C:
        length = some_calculation(offset, radius)
        nd.strt(length=length, width=width_wg).put(0)
        # do some stuff to create the pattern
        # same pin placement as above
    return C

nd.strt(width=2, length=200, layer=1).put(0)
blackbox(width_wg=2, offset=150, radius=1000).put()
blackbox(width_wg=2, offset=20, radius=500).put()

# Import and conversion black to white:
d = {'blackbox': white_pcell}
nd.replaceCells(gdsin='test.gds', gdsout='testwhite.gds', PcellFunctionMap=d)