Purposefully Exporting With Ghost Cells

I want to export a cell but I also want to purposefully create ghost cells for the first layer of hierarchy. I have not been able to do this with Python scripting so far. Do you have any tips of how I could do it?

We've reached a point where having all cells in a single file is not scalable, particularly with multiple team members trying to work on the a chip. So the plan is to write a KLayout Python script which will export each cell to a separate file in the design repository. Each cell layout will consist of the layout at that level and then ghost cells preserving the first layer of hierarchy below.

When someone wants to work on a cell they can run another script that will pull the latest cell layouts from the design repository and populate the ghost cells. They can work on the design before exporting.

The concept is to split the hierarchy into individual cells at save and pull it back together at load. In that way individual cells can be modified without having a single binary file.


  • Hi Thomas,

    This is actually very simple: there is an attribute called "ghost_cell" which you can set to "True". This will save a layout with two ghost cells:

    import pya
    ly = pya.Layout()
    top = ly.create_cell("TOP")
    macro1 = ly.create_cell("MACRO1")
    macro1.ghost_cell = True
    macro2 = ly.create_cell("MACRO2")
    macro2.ghost_cell = True
    top.insert(pya.DCellInstArray(macro1, pya.DTrans(pya.DVector(0, 0))))
    top.insert(pya.DCellInstArray(macro2, pya.DTrans(pya.DVector(0, 10.0))))

    Best regards,


  • Hi Matthias,

    Thanks a lot that, worked. I'm not sure how I missed that "ghost_cell" flag.

    For reference if someone is looking in the future, to make the cell a ghost I also had to clear the contents.
    So I tree_copy to a new layout, for each child cell to ghost and clear(), then save to new file.

  • Right, thanks for the hint!

    Maybe the writer could skip everything inside a ghost. I did not consider this use case so far. Usually ghosts happen when you read certain GDS files and the property mainly is there to maintain this state rather than treating the cell "empty".


Sign In or Register to comment.