DRC expression objects represent abstract recipes for the Layer#drc universal DRC function. For example, when using a universal DRC expression like this:
out = in.drc(width < 2.0)
"width < 2.0" forms a DRC expression object. DRC expression objects have methods which manipulate or evaluate the results of this expression. In addition, DRC expressions have a result type, which is either polygon, edge or edge pair. The result type is defined by the expression generating it. In the example above, "width < 2.0" is a DRC width check which renders edge pairs. To obtain polygons from these edge pairs, use the "polygons" method:
out = in.drc((width < 2.0).polygons)
The following global functions are relevant for the DRC expressions:
The following documentation will list the methods available for DRC expression objects.
Usage:
This operator will evaluate the expression after. If this expression renders an empty result, the operator will return the primary shape. Otherwise it will return an empty result.
This operator can be used together with predicates such a "rectangles" to invert their meaning. For example, this code selects all primary shapes which are not rectangles:
out = in.drc(! rectangles) out = in.drc(! primary.rectangles) # equivalent
Usage:
The & operator will compute the boolean AND between the results of two expressions. The expression types need to be edge or polygon.
The following example computes the partial edges where width is less than 0.3 micrometers and space is less than 0.2 micrometers:
out = in.drc((width < 0.3).edges & (space < 0.2).edges)
Usage:
The + operator will join the results of two expressions.
Usage:
The - operator will compute the difference between the results of two expressions. The NOT operation is defined for polygons, edges and polygons subtracted from edges (first argument edge, second argument polygon).
CAUTION: be careful not to take secondary input for the first argument. This will not render the desired results. Remember that the "drc" function will walk over all primary shapes and present single primaries to the NOT operation together with the secondaries of that single shape. So when you use secondary shapes as the first argument, they will not see all all the primaries required to compute the correct result. That's also why a XOR operation cannot be provided in the context of a generic DRC function.
The following example will produce edge markers where the width of is less then 0.3 micron but not inside polygons on the "waive" layer:
out = in.drc((width < 0.3).edges - secondary(waive))
Usage:
This operation selects edges by their angle, measured against the horizontal axis in the mathematical sense.
For this measurement edges are considered without their direction. A horizontal edge has an angle of zero degree. A vertical one has an angle of 90 degrees. The angle range is from -90 (exclusive) to 90 degree (inclusive).
If the input shapes are not polygons or edge pairs, they are converted to edges before the angle test is made.
For example, the following code selects all edges from the primary shape which are 45 degree (up) or -45 degree (down). The "+" operator will join the results:
out = in.drc((angle == 45) + (angle == -45)) out = in.drc((primary.angle == 45) + (primary.angle == -45)) # equivalent
You can avoid using both 45 and -45 degree checks with the 'absolute' option. With this option, angles are not signed and the value is the absolute angle the edge encloses with the x axis:
out = in.drc(angle(absolute) == 45)
Note that angle checks usually imply the need for rotation variant formation as cells which are placed non-rotated and rotated by 90 degree cannot be considered identical. This imposes a performance penalty in hierarchical mode. If possible, consider using DRC#rectilinear for example to detect shapes with non-manhattan geometry instead of using angle checks.
The "angle" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to the method call "primary.angle".
Usage:
This operation is used in conditions to select shapes based on their area. It is applicable on polygon expressions. The result will be the input polygons if the area condition is met.
See Layer#drc for more details about comparison specs.
The following example will select all polygons with an area less than 2.0 square micrometers:
out = in.drc(area < 2.0) out = in.drc(primary.area < 2.0) # equivalent
The area method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.area".
Usage:
This operation is used in conditions to select shapes based on their area ratio. The area ratio is the ratio of bounding box vs. polygon area. It's a measure how "sparse" the polygons are and how good an approximation the bounding box is. The value is always larger or equal than 1. Boxes have a value of 1.
This filter is applicable on polygon expressions. The result will be the input polygon if the condition is met.
See Layer#drc for more details about comparison specs.
The following example will select all polygons whose area ratio is larger than 3:
out = in.drc(area_ratio > 3) out = in.drc(primary.area_ratio > 3) # equivalent
The "area_ratio" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.area_ratio".
Usage:
Returns the input polygons if the sum of their areas meets the specified condition. This condition is evaluated on the total of all shapes generated in one step of the "drc" loop. As there is a single primary in each loop iteration, "primary.area_sum" is equivalent to "primary.area".
See Layer#drc for more details about comparison specs.
Usage:
This operation is used in conditions to select shapes based on aspect ratios of their bounding boxes. The aspect ratio is computed by dividing the larger of width and height by the smaller of both. The aspect ratio is always larger or equal to 1. Square or square-boxed shapes have a bounding box aspect ratio of 1.
This filter is applicable on polygon expressions. The result will be the input polygon if the bounding box condition is met.
See Layer#drc for more details about comparison specs.
The following example will select all polygons whose bounding box aspect ratio is larger than 3:
out = in.drc(bbox_aspect_ratio > 3) out = in.drc(primary.bbox_aspect_ratio > 3) # equivalent
The "bbox_aspect_ratio" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.bbox_aspect_ratio".
Usage:
This operation acts similar to DRC#bbox_min, but takes the height of the shape's bounding box. In general, it's more advisable to use DRC#bbox_min or DRC#bbox_max because bbox_height implies a certain orientation. This can imply variant formation in hierarchical contexts: cells rotated by 90 degree have to be treated differently from ones not rotated. This usually results in a larger computation effort and larger result files.
The "bbox_height" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.bbox_height".
Usage:
This operation acts similar to DRC#bbox_min, but takes the larger dimension of the shape's bounding box.
The "bbox_max" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.bbox_max".
Usage:
This operation is used in conditions to select shapes based on smaller dimension of their bounding boxes. It is applicable on polygon expressions. The result will be the input polygons if the bounding box condition is met.
See Layer#drc for more details about comparison specs.
The following example will select all polygons whose bounding box smaller dimension is larger than 200 nm:
out = in.drc(bbox_min > 200.nm) out = in.drc(primary.bbox_min > 200.nm) # equivalent
The "bbox_min" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.bbox_min".
Usage:
This operation acts similar to DRC#bbox_min, but takes the width of the shape's bounding box. In general, it's more advisable to use DRC#bbox_min or DRC#bbox_max because bbox_width implies a certain orientation. This can imply variant formation in hierarchical contexts: cells rotated by 90 degree have to be treated differently from ones not rotated. This usually results in a larger computation effort and larger result files.
The "bbox_width" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.bbox_width".
Usage:
This method acts on edge expressions and delivers a specific part of each edge. See layer#centers for details about this functionality.
Usage:
This operation acts on polygons and selects the corners of the polygons. It can be put into a condition to select corners by their angles. The angle of a corner is positive for a turn to the left if walking a polygon clockwise and negative for the turn to the right. Hence positive angles indicate concave (inner) corners, negative ones indicate convex (outer) corners. Angles take values between -180 and 180 degree.
When using "as_dots" for an option, the operation will return single-point edges at the selected corners. With "as_boxes" (the default), small (2x2 DBU) rectangles will be produced at each selected corner.
Another option is "absolute" which selects the corners by absolute angle - i.e left and right turns will both be considered positive angles.
Examples for use of the options are:
corners(as_dots) corners(as_boxes, absolute)
The following example selects all corners:
out = in.drc(corners) out = in.drc(primary.corners) # equivalent
The following example selects all inner corners:
out = in.drc(corners > 0) out = in.drc(primary.corners > 0) # equivalent
The "corners" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.corners".
Usage:
This operation is used in conditions to select expression results based on their count. "count" is used as a method on a expression. It will evaluate the expression locally and return the original result if the shape count in the result is matching the condition.
See Layer#drc for more details about comparison specs.
Note that the expression is evaluated locally: for each primary shape, the expression is evaluated and the count of the resulting edge, edge pair or polygon set is taken. As the primary input will always have a single item (the local shape), using "count" on primary does not really make sense. It can be used on derived expressions however.
The following example selects triangles:
out = in.drc(if_any(corners.count == 3))
Note "if_any" which selects the primary shape if the argument evaluates to a non-empty result. Without "if_any" three corners are returned for each triangle.
Usage:
This method represents the selector of primary shapes which entirely cover shapes from the other layer. This version can be put into a condition indicating how many shapes of the other layer need to be covered. Use this variant within DRC expressions (also see Layer#drc).
For example, the following statement selects all input shapes which entirely cover shapes from the "other" layer:
out = in.drc(covering(other))
This example selects all input shapes which entire cover shapes from the other layer and there are more than two shapes from "other" inside primary shapes:
out = in.drc(covering(other) > 2)
Usage:
Polygons will be separated into edges forming their contours. Edge pairs will be decomposed into individual edges.
Contrary most other operations, "edges" does not have a plain function equivalent as this is reserved for the function generating an edges layer. To generate the edges of the primary shapes, use "primary" explicit as the source for the edges:
out = in.drc(primary.edges)
The "mode" argument allows selecting specific edges from polygons. Allowed values are: "convex", "concave", "step", "step_in" and "step_out". "step" generates edges only if they provide a step between two other edges. "step_in" creates edges that make a step towards the inside of the polygon and "step_out" creates edges that make a step towards the outside:
out = in.drc(primary.edges(convex))
In addition, "not_.." variants are available which selects edges not qualifying for the specific mode:
out = in.drc(primary.edges(not_convex))
The mode argument is ignored when translating other objects than polygons.
Usage:
This method acts on edge expressions and delivers a specific part of each edge. See layer#end_segments for details about this functionality.
Usage:
This method acts on edge expressions. It will create a polygon for each edge tracing the edge with certain offsets to the edge. "o" is the offset applied to the outer side of the edge, "i" is the offset applied to the inner side of the edge. "b" is the offset applied at the beginning and "e" is the offset applied at the end.
Usage:
This method acts on edge expressions. Polygons are generated for each edge describing the edge drawn with a certain width extending into the "inside" (the right side when looking from start to end). This method is basically equivalent to the extended method: "extended(0, 0, 0, dist)". A version extending to the outside is extended_out.
Usage:
This method acts on edge expressions. Polygons are generated for each edge describing the edge drawn with a certain width extending into the "outside" (the left side when looking from start to end). This method is basically equivalent to the extended method: "extended(0, 0, dist, 0)". A version extending to the inside is extended_in.
Usage:
The extent_refs operation acts on polygons and has the same effect than Layer#extent_refs. It takes the same arguments. It is available as a method on DRC expressions or as plain function, in which case it acts on the primary shapes.
Usage:
This method provides the same functionality as Layer#extents and takes the same arguments. It returns the bounding boxes of the input objects. It acts on edge edge pair and polygon expressions.
The "extents" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.extents".
Usage:
This method acts on edge pair expressions and returns the first edges of the edge pairs delivered by the expression.
Some checks deliver symmetric edge pairs (e.g. space, width, etc.) for which the edges are commutable. "first_edges" will deliver both edges for such edge pairs.
Usage:
This operation can be used as a plain function in which case it acts on primary shapes or can be used as method on another DRC expression. The following example selects all holes with an area larger than 2 square micrometers:
out = in.drc(holes.area > 2.um) out = in.drc(primary.holes.area > 2.um) # equivalent
Usage:
The hulls are the outer contours of the input polygons. By selecting hulls only, all holes will be closed.
This operation can be used as a plain function in which case it acts on primary shapes or can be used as method on another DRC expression. The following example closes all holes:
out = in.drc(hulls) out = in.drc(primary.hulls) # equivalent
Usage:
This method represents the selector of primary shapes which are entirely inside shapes from the other layer. Use this variant within DRC expressions (also see Layer#drc).
Usage:
See covering for a description of the use cases for this function. When using "interacting", shapes are selected when the interact (overlap, touch) shapes from the other layer.
When using this method with a count, the operation may not render the correct results if the other input is not merged. By nature of the generic DRC feature, only those shapes that interact with the primary shape will be selected. If the other input is split into multiple polygons, not all components may be captured and the computed interaction count may be incorrect.
Usage:
This operation will select those edges which are meeting the length criterion. Non-edge shapes (polygons, edge pairs) will be converted to edges before.
For example, this code selects all edges from the primary shape which are longer or equal than 1 micrometer:
out = in.drc(length >= 1.um) out = in.drc(primary.length >= 1.um) # equivalent
The "length" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.length".
Usage:
Returns the input edges if the sum of their lengths meets the specified condition. This condition is evaluated on the total of all edges generated in one step of the "drc" loop.
See Layer#drc for more details about comparison specs.
Usage:
This operation will act on polygons. Without a min_count argument, the merged polygons will be returned.
With a min_count argument, the result will include only those parts where more than the given number of polygons overlap. As the primary input is merged already, it will always contribute as one.
The "merged" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.merged".
Usage:
The middle operation acts on polygons and has the same effect than Layer#middle. It takes the same arguments. It is available as a method on DRC expressions or as plain function, in which case it acts on the primary shapes.
Usage:
This method represents the selector of primary shapes which are entirely outside shapes from the other layer. Use this variant within DRC expressions (also see Layer#drc).
Usage:
See covering for a description of the use cases for this function. When using "overlapping", shapes are selected when the overlap shapes from the other layer.
When using this method with a count, the operation may not render the correct results if the other input is not merged. By nature of the generic DRC feature, only those shapes that interact with the primary shape will be selected. If the other input is split into multiple polygons, not all components may be captured and the computed interaction count may be incorrect.
Usage:
This operation is used in conditions to select shapes based on their perimeter. It is applicable on polygon expressions. The result will be the input polygons if the perimeter condition is met.
See Layer#drc for more details about comparison specs.
The following example will select all polygons with a perimeter less than 10 micrometers:
out = in.drc(perimeter < 10.0) out = in.drc(primary.perimeter < 10.0) # equivalent
The perimeter method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.perimeter".
Usage:
Returns the input polygons if the sum of their perimeters meets the specified condition. This condition is evaluated on the total of all shapes generated in one step of the "drc" loop. As there is a single primary in each loop iteration, "primary.perimeter_sum" is equivalent to "primary.perimeter".
See Layer#drc for more details about comparison specs.
Usage:
Generates polygons from the input shapes. Polygons stay polygons. Edges and edge pairs are converted to polygons. For this, the enlargement parameter will specify the edge thickness or augmentation applied to edge pairs. With the default enlargement of zero edges will not be converted to valid polygons and degenerated edge pairs will not become valid polygons as well.
Contrary most other operations, "polygons" does not have a plain function equivalent as this is reserved for the function generating a polygon layer.
This method is useful for generating polygons from DRC violation markers as shown in the following example:
out = in.drc((width < 0.5.um).polygons)
Usage:
This operation can be used as a plain function in which case it acts on primary shapes or can be used as method on another DRC expression. The following example selects all rectangles:
out = in.drc(rectangles) out = in.drc(primary.rectangles) # equivalent
Usage:
Rectilinear polygons only have vertical and horizontal edges. Such polygons are also called manhattan polygons.
This operation can be used as a plain function in which case it acts on primary shapes or can be used as method on another DRC expression. The following example selects all manhattan polygons:
out = in.drc(rectilinear) out = in.drc(primary.rectilinear) # equivalent
Usage:
This operation is used in conditions to select shapes based on the ratio of bounding box height vs. width. The taller the shape, the larger the value. Wide polygons have a value below 1. A square has a relative height of 1.
This filter is applicable on polygon expressions. The result will be the input polygon if the condition is met.
Don't use this method if you can use bbox_aspect_ratio, because the latter is isotropic and can be used hierarchically without generating rotation variants.
See Layer#drc for more details about comparison specs.
The following example will select all polygons whose relative height is larger than 3:
out = in.drc(relative_height > 3) out = in.drc(primary.relative_height > 3) # equivalent
The "relative_height" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.bbox_aspect_ratio".
Usage:
This operation acts on polygons and applies corner rounding to the given inner and outer corner radius and the number of points n per full circle. See Layer#rounded_corners for more details.
The "rounded_corners" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.rounded_corners".
Usage:
This method acts on edge pair expressions and returns the second edges of the edge pairs delivered by the expression.
Some checks deliver symmetric edge pairs (e.g. space, width, etc.) for which the edges are commutable. "second_edges" will not deliver edges for such edge pairs. Instead, "first_edges" will deliver both.
Usage:
This method provides the same functionality as Layer#sized and takes the same arguments. It acts on polygon expressions.
The "sized" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.sized".
Usage:
This operation acts on polygons and applies polygon smoothing with the tolerance d. 'keep_hv' indicates whether horizontal and vertical edges are maintained. Default is 'no' which means such edges may be distorted. See Layer#smoothed for more details.
The "smoothed" method is available as a plain function or as a method on DRC expressions. The plain function is equivalent to "primary.smoothed".
Usage:
This operation can be used as a plain function in which case it acts on primary shapes or can be used as method on another DRC expression. The following example selects all squares:
out = in.drc(squares) out = in.drc(primary.squares) # equivalent
Usage:
This method acts on edge expressions and delivers a specific part of each edge. See layer#start_segments for details about this functionality.
Usage:
This operation can be used as a plain function in which case it acts on primary shapes or can be used as method on another DRC expression. The following example selects all polygons with more than 2 holes:
out = in.drc(with_holes > 2) out = in.drc(primary.with_holes > 2) # equivalent
Usage:
The | operator will compute the boolean OR between the results of two expressions. '+' is basically a synonym. Both expressions must render the same type.