cell.bbox in DRC

edited December 2019 in KLayout Support

How to use the cell.bbox in a DRC file ?

nwell = input (1,0)
cellBulk = RBA::CellView::active.cell.bbox
pwell = cellBulk - nwell

But, the last command does not work, because I cannot mix a bbox with a polygon.
Here, I cannot use make_polygon : I need it for the extraction of NMOS in triple well.

Thank you,



  • Hi Laurent,

    the "extent" function will simply return the bounding box of the input layout:

    nwell = input(1,0)
    cellBulk = extent
    pwell = cellBulk - nwell

    (you just need to be careful not to define a layer with this name).

    Best regards,


  • Thank you Matthias.

    I tried it, but it is not compatible with deep (hierarchical) extraction. I works for a simple cell without hierarchy, but find different nets at higher level. The solution I use so far is a boundary layer for all cells including a device, and no boundary for the cells that only include cells.

    cellBulk = input(100,0)   # Boundary layer
    nwell = input(1,0)
    tpwell = input(2,0)   # Triple well layer
    #cellBulk = extent
    bulk    = cellBulk  - tpwell - nwell
    pwell  = (cellBulk - nwell) + (tpwell - nwell)

    I need to add (tpwell - nwell) because the tpwell is surrounded by nwell and then excluded from the cellBulk.


  • Hi Laurent,

    That's right, unfortunately :(

    Unfortunately, an hierarchical cell extension is difficult to do as you cannot easily tell what the cell's true boundary is and how it is to be distributed on parent and child cells. This might be a box - but that could be any shape shape too.

    The solution I have found for this issue is this: you might be interested in the "bulk" as such, but usually you would just need it to connect something to. That is probably some bulk contact. So let's say, you have a pplus layer which acts as the bulk contact within bulk, but not within tpwell or nwell, you would define a "bulk_diode" layer like this:

    bulk_diode = pplus - nwell - tpwell

    Later you'd connect these markers to the "BULK" global net, i.e.

    connect_global(bulk_diode, "BULK")

    So instead of creating a layer for bulk, you create a net for it.

    Would this solve your problem?

    Best regards,


Sign In or Register to comment.