DRC Reference: Source Object

The layer object represents a collection of polygons, edges or edge pairs. A source specifies where to take layout from. That includes the actual layout, the top cell and options such as clip/query boxes, cell filters etc.

"cell" - Specifies input from a specific cell

Usage:

  • source.cell(name)

This method will create a new source that delivers shapes from the specified cell.

"cell_name" - Returns the name of the currently selected cell

Usage:

  • cell_name

"cell_obj" - Returns the Cell object of the currently selected cell

Usage:

  • cell_obj

"clip" - Specifies clipped input

Usage:

  • source.clip(box)
  • source.clip(p1, p2)
  • source.clip(l, b, r, t)

Creates a source which represents a rectangular part of the original input. Three ways are provided to specify the rectangular region: a single DBox object (micron units), two DPoint objects (lower/left and upper/right coordinate in micron units) or four coordinates: left, bottom, right and top coordinate.

This method will create a new source which delivers the shapes from that region clipped to the rectangle. A method doing the same but without clipping is touching or overlapping.

"extent" - Returns a layer with the bounding box of the selected layout

Usage:

  • source.extent

The extent function is useful to invert a layer:

inverse_1 = extent.sized(100.0) - input(1, 0)

"input" - Specifies input from a source

Usage:

  • source.input(layer)
  • source.input(layer, datatype)
  • source.input(layer_into)
  • source.input(filter, ...)

Creates a layer with the shapes from the given layer of the source. The layer can be specified by layer and optionally datatype, by a LayerInfo object or by a sequence of filters. Filters are expressions describing ranges of layers and/or datatype numbers or layer names. Multiple filters can be given and all layers matching at least one of these filter expressions are joined to render the input layer for the DRC engine.

Some filter expressions are:

  • 1/0-255 : Datatypes 0 to 255 for layer 1
  • 1-10 : Layers 1 to 10, datatype 0
  • METAL : A layer named "METAL"
  • METAL (17/0) : A layer named "METAL" or layer 17, datatype 0 (for GDS, which does not have names)

"labels" - Gets the labels (texts) from an input layer

Usage:

  • source.labels(layer)
  • source.labels(layer, datatype)
  • source.labels(layer_into)
  • source.labels(filter, ...)

Creates a layer with the labels from the given layer of the source. The layer can be specified by layer and optionally datatype, by a LayerInfo object or by a sequence of filters. Filters are expressions describing ranges of layers and/or datatype numbers or layer names. Multiple filters can be given and all layers matching at least one of these filter expressions are joined to render the label collection. See "input" for more details about the input layer specification.

Label layers currently can only be passed to an output layer. Processing of labels is not supported. See "texts" for a way to filter texts and use the text locations in geometrical operations.

labels(1, 0).output(100, 0)

"layers" - Gets the layers the source contains

Usage:

  • source.layers

Delivers a list of LayerInfo objects representing the layers inside the source.

One application is to read all layers from a source. In the following example, the "and" operation is used to perform a clip with the given rectangle. Note that this solution is not efficient - it's provided as an example only:

output_cell("Clipped")

clip_box = polygon_layer
clip_box.insert(box(0.um, -4.um, 4.um, 0.um))

layers.each { |l| (input(l) & clip_box).output(l) }

"layout" - Returns the Layout object associated with this source

Usage:

  • layout

"overlapping" - Specifies input selected from a region in overlapping mode

Usage:

  • source.overlapping(...)

Like clip, this method will create a new source delivering shapes from a specified rectangular region. In contrast to clip, all shapes overlapping the region with their bounding boxes are delivered as a whole and are not clipped. Hence shapes may extent beyond the limits of the specified rectangle.

touching is a similar method which delivers shapes touching the search region with their bounding box (without the requirement to overlap)

"select" - Adds cell name expressions to the cell filters

Usage:

  • source.select(filter1, filter2, ...)

This method will construct a new source object with the given cell filters applied. Cell filters will enable or disable cells plus their subtree. Cells can be switched on and off, which makes the hierarchy traversal stop or begin delivering shapes at the given cell. The arguments of the select method form a sequence of enabling or disabling instructions using cell name pattern in the glob notation ("*" as the wildcard, like shell). Disabling instructions start with a "-", enabling instructions with a "+" or no specification.

The following options are available:

  • +name_filter : Cells matching the name filter will be enabled
  • name_filter : Same as "+name_filter"
  • -name_filter : Cells matching the name filter will be disabled

To disable the TOP cell but enabled a hypothetical cell B below the top cell, use that code:

layout_with_selection = layout.select("-TOP", "+B")
l1 = layout_with_selection.input(1, 0)
...

Please note that the sample above will deliver the children of "B" because there is nothing said about how to proceed with cells other than "TOP" or "B". The following code will just select "B" without it's children, because in the first "-*" selection, all cells including the children of "B" are disabled:

layout_with_selection = layout.select("-*", "+B")
l1 = layout_with_selection.input(1, 0)
...

"touching" - Specifies input selected from a region in touching mode

Usage:

  • source.touching(box)
  • source.touching(p1, p2)
  • source.touching(l, b, r, t)

Like clip, this method will create a new source delivering shapes from a specified rectangular region. In contrast to clip, all shapes touching the region with their bounding boxes are delivered as a whole and are not clipped. Hence shapes may extent beyond the limits of the specified rectangle.

overlapping is a similar method which delivers shapes overlapping the search region with their bounding box (and not just touching)