Moving Region Contents to Different Layer

Hello,

I need to move only the contents of a rectangular region on one layer to another layer for additional operations. I'm currently using the AND function of ShapeProcessor:

pya.ShapeProcessor().boolean(layout,cell,layer_tile,layout,topcell,layer_in,shapes_temp,pya.EdgeProcessor.ModeAnd,True,True,True)

Here I have a layer "layer_tile" that contains a shape defining the region. Then I copy the intersection (AND) between this and "layer_in" (the circuit layout) onto "shapes_temp".

However, this operation is much slower than I would have expected. For vague reference, my layout is about 100x the area of the desired region, and this operation takes over a minute to complete, while a bias on the region takes half a second.

Is there a way to speed up this operation? Or a different operation entirely (with the same result)? Why is this so slow?

Thanks,
Adam

Comments

  • Hi Adam,

    I can't tell why it's so slow if you don't give me more details. And I don't know what you mean by "bias". "size" after merging? That should not be faster than AND.

    In general, AND is the worst choice for your application.

    1. In general, you should use the "Region" class for boolean operations. The class is more generic, richer in features, better optimized etc. ShapeProcessor is a basic algorithm with little optimization.
    2. When you use Region, create one from a RecursiveShapeIterator confined to your target area (Cell#begin_shapes_overlapping). This will reduce the input to the area you actually want to process.
    3. AND on regions can be done with the "&" operator.
    4. A side effect of AND is merging and flattening. If you don't need this, you can use "clip" which is much faster and works hierarchically by creating clip variants of cells.

    Matthias

  • Hi Matthias,

    Thanks for the explanation. "clip" seems to be exactly what I was looking for. Although I noticed in the documentation it says it might not work for instances which are rotated arbitrary angles. Is this still an issue and will then not work for an arbitrary layout?

    PS. By "bias" I am performing the following operation.
    pya.ShapeProcessor().size(layout,clip_cell,layer_in,shapes_temp,bias_val,pya.EdgeProcessor.ModeOr,True,True,True)
    I imagine AND as I used it before looks over the entire layout, as opposed to searching the extents of the smaller of the two shapes. So while per area, AND may be faster, AND was applied to a much larger and more complex pattern.

    Thanks,
    Adam

  • AND doesn't look inside the extents of the smaller layer. As I said, the ShapeProcessor is the basic algorithm. No optimization.

    Maybe for the things you seem to be doing you should consider the DRC feature. DRC works on a much higher level and even supports hierarchical operations and a tiled operation mode. When it comes to the ability to handle bigger layouts, the basic ShapeProcessor approach is bound to fail.

    Matthias

Sign In or Register to comment.