Home Forums Nazca Caching non-parametric cells

Tagged: , ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5531
    Dima
    Participant

    is based in Eindhoven

    Dear Nazca Design authors,

    Thanks for developing this great tool!

    I have a question regarding the possibility of caching the non-parametric BBs in the PDK. Currently, I have a function

    # pdk.py
    sh_to_dp():
        """ Create a transition cell"""
        with nd.Cell(name='s2d') as c:
        ...
        return c

    In the user code, one has to do:

    # main.py
    from pdk import sh_to_dp
        sh_to_dp().put()

    This creates a new cell every time the sh_to_dp() is called. Although essentially it is the same cell every time, they all are assigned new name by adding a hash tag, and stored in the GDS as separate cells. A solution to that could be adding a code that creates a cell to pdk.py:

    # pdk.py
    ...
    sh_to_dp_cell = sh_to_dp()

    and changing the user code to:

    
    # main.py
    from pdk import sh_to_dp_cell
        sh_to_dp_cell.put()

    The drawback of this solution is that it creates an overhead of cell creating before being imported or used. In case of multiple cells, this might increase the time needed to load the library.

    Is there a better way to do this: to create a non-parametric cell only once and only when it is actually used in the design?

    #5535
    Ronald
    Keymaster

    Dear Dima,

    There are two ways around the renaming.
    (Note the renaming by default guarantees that cells are always unique.)

    1) Nazca can recognize if cells (parametric or not) have been called before by applying the hashme decorator:

    import nazca as nd
    
    @nd.bb_util.hashme('cellname')
    def sh_to_dp():
        with nd.Cell(hashme=True) as C:
            nd.strt(length=10).put(0)
        return C
    
    for i in range(10):
        sh_to_dp().put(0, 10*i)
    
    nd.export_gds()

    2) Assign the cell in the first call to a variable name and avoid the extra function calls all together:

    C = sh_to_dp()
    for i in range(10):
        C.put(0, 10*i)

    Ronald

    #5536
    Dima
    Participant

    is based in Eindhoven

    Ok, It seems I solved it with hashme() decorator.

    Now the code is smth like this following:

    # pdk.py
    
    def sh_to_dp_generic(l, w, name):
        with Cell(name=name, instantiate=False) as cell:
            ...
        return cell
    
    @hashme('sh_to_dp')
    def sh_to_dp():
        with Cell(name='sh_to_dp', hashme=True) as cell:
           c = sh_to_dp_generic(100, 20, 'sh_to_dp').put()
           c.raise_pins()
        return cell
    
    @hashme('sh_to_dp_long')
    def sh_to_dp_long():
        with Cell(name='sh_to_dp_long', hashme=True) as cell:
           c = sh_to_dp_generic(100, 20, 'sh_to_dp_long').put()
           c.raise_pins()
        return cell
    #5537
    Dima
    Participant

    is based in Eindhoven

    Dear Ronald,

    Thank you for the reply, and sorry for poor formatting of the examples… Could not figure out how to do it properly.

    #5538
    Ronald
    Keymaster

    Dear Dima,

    You indeed already found the hashme.
    Note that nd.Cell(hashme=True) is sufficient. The cellname is taken from the first hashme argument.

    The use of hashme=True of coarse assumes that the hashme decorator is applied to the function your cell definition resides in in the first place, as shown in the examples.

    Regards,
    Ronald

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