# DRC Reference: Global Functions

## "antenna_check" - Performs an antenna check

Usage:

- antenna_check(gate, metal, ratio, [ diode_specs ... ])

See Netter#antenna_check for a description of that function.

## "area" - Selects the primary shape if the area is meeting the condition

Usage:

- area (in condition)
- area(layer)

This function can be used with a layer argument in which case it is equivalent to "layer.area" (see Layer#area). Without a layer argument, "area" represents an area filter for primary shapes in DRC expressions (see Layer#drc and DRC#area for more details).

## "bbox_height" - Selects primary shapes based on their bounding box height

Usage:

- bbox_height (in condition)

This method creates a universal DRC expression (see Layer#drc) to select primary shapes whose bounding box height satisfies the condition. Conditions may be written as arithmetic comparisons against numeric values. For example, "bbox_height < 2.0" will select all primary shapes whose bounding box height is less than 2 micrometers. See Layer#drc for more details about comparison specs. Plain "bbox_min" is equivalent to "primary.bbox_min" - i.e. it is used on the primary shape. Also see DRC#bbox_min.

## "bbox_max" - Selects primary shapes based on their bounding box height or width, whichever is larger

Usage:

- bbox_max (in condition)

See Layer#drc, bbox_max and DRC#bbox_max for more details.

## "bbox_min" - Selects primary shapes based on their bounding box height or width, whichever is smaller

Usage:

- bbox_max (in condition)

See Layer#drc, bbox_min and DRC#bbox_min for more details.

## "bbox_width" - Selects primary shapes based on their bounding box width

Usage:

- bbox_max (in condition)

See Layer#drc, bbox_height and DRC#bbox_height for more details.

## "bjt3" - Supplies the BJT3 transistor extractor class

Usage:

- bjt3(name)

Use this class with extract_devices to specify extraction of a bipolar junction transistor

See DeviceExtractorBJT3Transistor for more details about this extractor.

## "bjt4" - Supplies the BJT4 transistor extractor class

Usage:

- bjt4(name)

Use this class with extract_devices to specify extraction of a bipolar junction transistor with a substrate terminal

See DeviceExtractorBJT4Transistor for more details about this extractor.

## "box" - Creates a box object

Usage:

- box(...)

This function creates a box object. The arguments are the same than for the DBox constructors.

## "capacitor" - Supplies the capacitor extractor class

Usage:

- capacitor(name, area_cap)

Use this class with extract_devices to specify extraction of a capacitor. The area_cap argument is the capacitance in Farad per square micrometer.

See DeviceExtractorCapacitor for more details about this extractor.

## "capacitor_with_bulk" - Supplies the capacitor extractor class that includes a bulk terminal

Usage:

- capacitor_with_bulk(name, area_cap)

Use this class with extract_devices to specify extraction of a capacitor with a bulk terminal. The area_cap argument is the capacitance in Farad per square micrometer.

See DeviceExtractorCapacitorWithBulk for more details about this extractor.

## "case" - A conditional selector for the "drc" universal DRC function

Usage:

- case(...)

This function provides a conditional selector for the "drc" function. It is used this way:

    out = in.drc(case(c1, r1, c2, r2, ..., cn, rn)
    out = in.drc(case(c1, r1, c2, r2, ..., cn, rn, rdef)

This function will evaluate c1 which is a universal DRC expression (see Layer#drc). If the result is not empty, "case" will evaluate and return r1. Otherwise it will continue with c2 and the result of this expression is not empty it will return r2. Otherwise it will continue with c3/r3 etc.

If an odd number of arguments is given, the last expression is evaluated if none of the conditions c1..cn gives a non-empty result.

As a requirement, the result types of all r1..rn expressions and the rdef needs to be the same - i.e. all need to render polygons or edges or edge pairs.

## "cell" - Selects a cell for input on the default source

Usage:

- cell(args)

See Source#cell for a description of that function. In addition to the functionality described there, the global function will also send the output to the specified cell.

The following code will select cell "MACRO" from the input layout:

    cell("MACRO")
    # shapes now will be taken from cell "MACRO"
    l1 = input(1, 0)

## "cheat" - Hierarchy cheats

Usage:

- cheat(args) { block }

Hierarchy cheats can be used in deep mode to shortcut hierarchy evaluation for certain cells and consider their local configuration only. Cheats are useful for example when dealing with memory arrays. Often such arrays are build from unit cells and those often overlap with their neighbors. Now, if the hierarchical engine encounters such a situation, it will first analyse all these interactions (which can be expensive) and then it may come to the conclusion that boundary instances need to be handled differently than inside instances. This in turn might lead to propagation of shapes and in an LVS context to device externalisation: because some devices might have different parameters for boundary cells than for inside cells, the device instances can no longer be kept inside the unit cell. Specifically for memory arrays, this is not desired as eventually this leads to flattening of the whole array.

The solution is to cheat: provided the unit cell is fully fledged and neighbors do not disturb the unit cell's configuration in critical ways, the unit cell can be treated as being isolated and results are put together in the usual way.

Cheats can be applied on layout operations - specifically booleans - and device extraction operations. Cheats are only effective in deep mode.

For booleans, a cheat means that the cheating cell's boolean results are computed locally and are combined afterwards. A cheat is introduced this way:

    deep

    l1 = input(1, 0)
    l2 = input(2, 0)

    # usual booleans
    l1and2 = l1 & l2

    # will compute "UNIT_CELL" isolated and everything else in normal hierarchical mode:
    l1minus2 = cheat("UNIT_CELL) { l1 - l2 }

The cheat block can also be wrapped in do .. end statements and can return multiple layer objects:

    deep

    l1 = input(1, 0)
    l2 = input(2, 0)

    # computes both AND and NOT of l1 and l2 with cheating for "UNIT_CELL"
    l1and2, l1minus2 = cheat("UNIT_CELL) do
    [ l1 & l2, l1 - l2 ]
    end

(Technically, the cheat code block is a Ruby Proc and cannot create variables outside its scope. Hence the results of this code block have to be passed through the "cheat" method).

To apply cheats for device extraction, use the following scheme:

    deep

    poly = input(1, 0)
    active = input(2, 0)

    sd = active - poly
    gate = active & poly

    # device extraction with cheating for "UNIT_CELL":
    cheat("UNIT_CELL") do
    extract_devices(mos3("NMOS"), { "SD" => sd, "G" => gate, "tS" => sd, "tD" => sd, "tG" => poly }
    end

The argument to the cheat method is a list of cell name pattern (glob-style pattern). For example:

    cheat("UNIT_CELL*") { ... }
    cheat("UNIT_CELL1", "UNIT_CELL2") { ... }
    cheat("UNIT_CELL{1,2}") { ... }

For LVS applications, it's usually sufficient to cheat in the device extraction step. Cheats have been introduced in version 0.26.1.

## "clear_connections" - Clears all connections stored so far

Usage:

- clear_connections

See Netter#clear_connections for a description of that function.

## "clip" - Specifies clipped input on the default source

Usage:

- clip(args)

See Source#clip for a description of that function.

The following code will select shapes within a 500x600 micron rectangle (lower left corner at 0,0) from the input layout. The shapes will be clipped to that rectangle:

    clip(0.mm, 0.mm, 0.5.mm, 0.6.mm)
    # shapes now will be taken from the given rectangle and clipped to it
    l1 = input(1, 0)

## "connect" - Specifies a connection between two layers

Usage:

- connect(a, b)

See Netter#connect for a description of that function.

## "connect_global" - Specifies a connection to a global net

Usage:

- connect_global(l, name)

See Netter#connect_global for a description of that function.

## "connect_implicit" - Specifies a label pattern for implicit net connections

Usage:

- connect_implicit(label_pattern)
- connect_implicit(cell_pattern, label_pattern)

See Netter#connect_implicit for a description of that function.

## "corners" - Selects all polygons which are rectilinear

Usage:

- corners (in condition)
- corners(layer)

This function can be used with a layer argument in which case it is equivalent to "layer.corners" (see Layer#corners). Without a layer argument, "corners" represents the corner generator/filter in primary shapes for DRC expressions (see Layer#drc and DRC#corners for more details).

## "covering" - Selects shapes entirely covering other shapes

Usage:

- covering(other) (in conditions)
- covering(layer, other [, options ])

This function can be used with a layer argument in which case it is equivalent to "layer.covering" (see Layer#covering).

Without a layer argument, 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)

## "dbu" - Gets or sets the database unit to use

Usage:

- dbu(dbu_value)
- dbu

Without any argument, this method gets the database unit used inside the DRC engine.

With an argument, sets the database unit used internally in the DRC engine. Without using that method, the database unit is automatically taken as the database unit of the last input. A specific database unit can be set in order to optimize for two layouts (i.e. take the largest common denominator). When the database unit is set, it must be set at the beginning of the script and before any operation that uses it.

## "deep" - Enters deep (hierarchical) mode

Usage:

- deep

In deep mode, the operations will be performed in a hierarchical fashion. Sometimes this reduces the time and memory required for an operation, but this will also add some overhead for the hierarchical analysis.

"deepness" is a property of layers. Layers created with "input" while in deep mode carry hierarchy. Operations involving such layers at the only or the first argument are carried out in hierarchical mode.

Hierarchical mode has some more implications, like "merged_semantics" being implied always. Sometimes cell variants will be created.

Deep mode can be cancelled with tiles or flat.

## "device_scaling" - Specifies a dimension scale factor for the geometrical device properties

Usage:

- device_scaling(factor)

See Netter#device_scaling for a description of that function.

## "diode" - Supplies the diode extractor class

Usage:

- diode(name)

Use this class with extract_devices to specify extraction of a planar diode

See DeviceExtractorDiode for more details about this extractor.

## "dmos3" - Supplies the DMOS3 transistor extractor class

Usage:

- dmos3(name)

Use this class with extract_devices to specify extraction of a three-terminal DMOS transistor. A DMOS transistor is essentially the same than a MOS transistor, but source and drain are separated.

See DeviceExtractorMOS3Transistor for more details about this extractor (strict mode applies for 'dmos3').

## "dmos4" - Supplies the MOS4 transistor extractor class

Usage:

- dmos4(name)

Use this class with extract_devices to specify extraction of a four-terminal DMOS transistor. A DMOS transistor is essentially the same than a MOS transistor, but source and drain are separated.

See DeviceExtractorMOS4Transistor for more details about this extractor (strict mode applies for 'dmos4').

## "edge" - Creates an edge object

Usage:

- edge(...)

This function creates an edge object. The arguments are the same than for the DEdge constructors.

## "edge_layer" - Creates an empty edge layer

Usage:

- edge_layer

The intention of that method is to create an empty layer which can be filled with edge objects using Layer#insert.

## "edge_pairs" - Gets the edges from an original layer

Usage:

- edge_pairs(args)

See Source#edge_pairs for a description of that function.

## "edges" - Gets the edges from an original layer

Usage:

- edges(args)

See Source#edges for a description of that function.

## "enc" - Synonym for "enclosing"

Usage:

- enc(...)

"enc" is the short form for enclosing.

## "enclosing" - Performs an enclosing check

Usage:

- enclosing(other [, options ]) (in conditions)
- enclosing(layer, other [, options ])

This function can be used with a layer argument in which case it is equivalent to "layer.enclosing" (see Layer#enclosing).

The version without the first layer is intended for use within DRC expressions together with the Layer#drc method. In this case, this function needs to be put into a condition to specify the check constraints. The other options of Layer#enclosing (e.g. metrics, projection constraints, angle limits etc.) apply to this version too.

The conditions may involve an upper and lower limit. The following examples illustrate the use of this function with conditions:

    out = in.drc(enclosing(other) < 0.2.um)
    out = in.drc(enclosing(other) <= 0.2.um)
    out = in.drc(enclosing(other) > 0.2.um)
    out = in.drc(enclosing(other) >= 0.2.um)
    out = in.drc(enclosing(other) == 0.2.um)
    out = in.drc(0.1.um <= enclosing(other) < 0.2.um)

The result of the enclosing check are edge pairs forming the violation markers. With a lower limit, these markers are formed by two, identical but opposite edges attached to the primary shape. Without a lower limit, the first edge of the marker is attached to the primary shape while the second edge is attached to the shape of the "other" layer.

## "error" - Prints an error

Usage:

- error(message)

Similar to log, but the message is printed formatted as an error

## "extent" - Creates a new layer with the bounding box of the default source

Usage:

- extent

See Source#extent for a description of that function.

## "extent_refs" - Returns partial references to the boundings boxes of the polygons

Usage:

- extent_refs([ options ])
- extent_refs(layer, [ options ])

This function can be used with a layer argument in which case it is equivalent to "layer.extent_refs" (see Layer#extent_refs). Without a layer argument, "extent_refs" represents the partial extents extractor on primary shapes within DRC expressions (see Layer#drc and DRC#extent_refs for more details).

## "extents" - Returns the bounding box of each input object

Usage:

- extents([ enlargement ])
- extents(layer, [ enlargement ])

This function can be used with a layer argument in which case it is equivalent to "layer.extents" (see Layer#extents). Without a layer argument, "extents" represents the extents generator on primary shapes within DRC expressions (see Layer#drc and DRC#extents for more details).

## "extract_devices" - Extracts devices for a given device extractor and device layer selection

Usage:

- extract_devices(extractor, layer_hash)
- extract_devices(extractor_class, name, layer_hash)

See Netter#extract_devices for a description of that function.

## "flat" - Disables tiling mode

Usage:

- flat

Disables tiling mode. Tiling mode can be enabled again with tiles later.

## "foreign" - Represents all other polygons from primary except the current one

Usage:

- foreign

The primary input of the universal DRC function is the layer the Layer#drc function is called on. This operation represents all "other" primary polygons while primary represents the current polygon.

This feature opens new options for processing layouts beyond the abilities of the classical DRC concept. For classic DRC, intra-layer interactions are always symmetric: a polygon cannot be considered separated from it's neighbors on the same layer.

The following example computes every part of the input which is closer than 0.5 micrometers to other (disconnected) polygons on the same layer:

    out = in.drc(primary & foreign.sized(0.5.um))

## "holes" - Selects all holes from the input polygons

Usage:

- holes
- holes(layer)

This function can be used with a layer argument in which case it is equivalent to "layer.holes" (see Layer#hulls). Without a layer argument, "holes" represents a hole extractor for primary shapes in DRC expressions (see Layer#drc and DRC#hulls for more details).

## "hulls" - Selects all hulls from the input polygons

Usage:

- hulls
- hulls(layer)

This function can be used with a layer argument in which case it is equivalent to "layer.hulls" (see Layer#hulls). Without a layer argument, "hulls" represents a hull contour extractor for primary shapes in DRC expressions (see Layer#drc and DRC#hulls for more details).

## "if_all" - Evaluates to the primary shape when all condition expression results are non-empty

Usage:

- if_all(c1, ... cn)

This function will evaluate the conditions c1 to cn and return the current primary shape if all conditions render a non-empty result. The following example selects all shapes which are rectangles and whose area is larger than 0.5 square micrometers:

    out = in.drc(if_all(area > 0.5, rectangle))

The condition expressions may be of any type (edges, edge pairs and polygons).

## "if_any" - Evaluates to the primary shape when any condition expression results is non-empty

Usage:

- if_any(c1, ... cn)

This function will evaluate the conditions c1 to cn and return the current primary shape if at least one condition renders a non-empty result. See if_all for an example how to use the if_... functions.

## "if_none" - Evaluates to the primary shape when all of the condition expression results are empty

Usage:

- if_none(c1, ... cn)

This function will evaluate the conditions c1 to cn and return the current primary shape if all conditions renders an empty result. See if_all for an example how to use the if_... functions.

## "info" - Outputs as message to the logger window

Usage:

- info(message)
- info(message, indent)

Prints the message to the log window in verbose mode. In non-verbose more, nothing is printed. log is a function that always prints a message.

## "input" - Fetches the shapes from the specified input from the default source

Usage:

- input(args)

See Source#input for a description of that function. This method will fetch polygons and labels. See polygons and labels for more specific versions of this method.

## "inside" - Selects shapes entirely inside other shapes

Usage:

- inside(other)
- inside(layer, other)

This function can be used with a layer argument in which case it is equivalent to "layer.inside" (see Layer#inside).

Without a layer argument, 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).

## "interacting" - Selects shapes interacting with other shapes

Usage:

- interacting(other) (in conditions)
- interacting(layer, other [, options ])

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.

## "is_deep?" - Returns true, if in deep mode

Usage:

- is_deep?

## "is_tiled?" - Returns true, if in tiled mode

Usage:

- is_tiled?

## "iso" - Synonym for "isolated"

Usage:

- iso(...)

"iso" is the short form for isolated.

## "l2n_data" - Gets the internal LayoutToNetlist object for the default Netter

Usage:

- l2n_data

See Netter#l2n_data for a description of that function.

## "labels" - Gets the labels (text) from an original layer

Usage:

- labels(args)

See Source#labels for a description of that function.

## "layers" - Gets the layers contained in the default source

Usage:

- layers

See Source#layers for a description of that function.

## "layout" - Specifies an additional layout for the input source.

Usage:

- layout
- layout(what)

This function can be used to specify a new layout for input. It returns an Source object representing that layout. The "input" method of that object can be used to get input layers for that layout.

"what" specifies what input to use. "what" be either

- A string "@n" specifying input from a cellview in the current view
- A layout filename plus an optional cell name
- A Layout object
- A Cell object

Without any arguments the default layout is returned.

If a file name is given, a cell name can be specified as the second argument. If not, the top cell is taken which must be unique in that case.

Having specified a layout for input enables to use the input method for getting input:

    # XOR between layers 1 or the default input and "second_layout.gds":
    l2 = layout("second_layout.gds")
    (input(1, 0) ^ l2.input(1, 0)).output(100, 0)

For further methods on the source object see Source.

## "log" - Outputs as message to the logger window

Usage:

- log(message)
- log(message, indent)

Prints the message to the log window. info is a function that prints a message only if verbose mode is enabled.

## "log_file" - Specify the log file where to send to log to

Usage:

- log_file(filename)

After using that method, the log output is sent to the given file instead of the logger window or the terminal.

## "make_layer" - Creates an empty polygon layer based on the hierarchical scheme selected

Usage:

- make_layer

The intention of this method is to provide an empty polygon layer based on the hierarchical scheme selected. This will create a new layer with the hierarchy of the current layout in deep mode and a flat layer in flat mode. This method is similar to polygon_layer, but the latter does not create a hierarchical layer. Hence the layer created by make_layer is suitable for use in device extraction for example, while the one delivered by polygon_layer is not.

On the other hand, a layer created by the make_layer method is not intended to be filled with Layer#insert.

## "max_area_ratio" - Gets or sets the maximum bounding box to polygon area ratio for deep mode fragmentation

Usage:

- max_area_ratio(ratio)
- max_area_ratio

In deep mode, polygons with a bounding box to polygon area ratio bigger than the given number will be split into smaller chunks to optimize performance (which gets better if the polygon's bounding boxes do not cover a lot of empty space). The default threshold is 3.0 which means fairly compact polygons. Use this method with a numeric argument to set the value and without an argument to get the current maximum area ratio. Set the value to zero to disable splitting by area ratio.

See also max_vertex_count for the other option affecting polygon splitting.

## "max_vertex_count" - Gets or sets the maximum vertex count for deep mode fragmentation

Usage:

- max_vertex_count(count)
- max_vertex_count

In deep mode, polygons with more than the given number of vertexes will be split into smaller chunks to optimize performance (which is better or less complex polygons). The default threshold is 16 vertexes. Use this method with a vertex count to set the value and without an argument to get the current maximum vertex count. Set the value to zero to disable splitting by vertex count.

See also max_area_ratio for the other option affecting polygon splitting.

## "middle" - Returns the centers of polygon bounding boxes

Usage:

- middle([ options ])
- middle(layer, [ options ])

This function can be used with a layer argument in which case it is equivalent to "layer.middle" (see Layer#middle). Without a layer argument, "middle" represents the bounding box center marker generator on primary shapes within DRC expressions (see Layer#drc and DRC#middle for more details).

## "mos3" - Supplies the MOS3 transistor extractor class

Usage:

- mos3(name)

Use this class with extract_devices to specify extraction of a three-terminal MOS transistor.

See DeviceExtractorMOS3Transistor for more details about this extractor (non-strict mode applies for 'mos3').

## "mos4" - Supplies the MOS4 transistor extractor class

Usage:

- mos4(name)

Use this class with extract_devices to specify extraction of a four-terminal MOS transistor.

See DeviceExtractorMOS4Transistor for more details about this extractor (non-strict mode applies for 'mos4').

## "netlist" - Obtains the extracted netlist from the default Netter

The netlist is a Netlist object. If no netlist is extracted yet, this method will trigger the extraction process. See Netter#netlist for a description of this function.

## "netter" - Creates a new netter object

Usage:

- netter

See Netter for more details

## "no_borders" - Reset the tile borders

Usage:

- no_borders

Resets the tile borders - see tile_borders for a description of tile borders.

## "notch" - Performs a notch (intra-polygon space) check

Usage:

- notch([ options ]) (in conditions)
- notch(layer [, options ])

Provides a intra-polygon space check for polygons from the primary layer. Like width this function provides a single-layer check. See there for details how to use this function.

## "odd_polygons" - Selects all polygons which are non-orientable

Usage:

- odd_polygons
- odd_polygons(layer)

This function can be used with a layer argument in which case it is equivalent to "layer.odd_polygons" (see Layer#odd_polygons). Without a layer argument, "odd_polygons" represents an odd polygon filter for primary shapes in DRC expressions (see Layer#drc and DRC#odd_polygons for more details).

## "output" - Outputs a layer to the report database or output layout

Usage:

- output(layer, args)

This function is equivalent to "layer.output(args)". See Layer#output for details about this function.

## "output_cell" - Specifies a target cell, but does not change the target layout

Usage:

- output_cell(cellname)

This method switches output to the specified cell, but does not change the target layout nor does it switch the output channel to layout if is report database.

## "outside" - Selects shapes entirely outside other shapes

Usage:

- outside(other)
- outside(layer, other)

This function can be used with a layer argument in which case it is equivalent to "layer.outside" (see Layer#outside).

Without a layer argument, 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).

## "overlap" - Performs an overlap check

Usage:

- overlap(other [, options ]) (in conditions)
- overlap(layer, other [, options ])

Provides an overlap check (primary layer vs. another layer). Like enclosing this function provides a two-layer check. See there for details how to use this function.

## "overlapping" - Selects shapes overlapping with other shapes

Usage:

- overlapping(other) (in conditions)
- overlapping(layer, other [, options ])

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.

## "p" - Creates a point object

Usage:

- p(x, y)

A point is not a valid object by itself, but it is useful for creating paths for polygons:

    x = polygon_layer
    x.insert(polygon([ p(0, 0), p(16.0, 0), p(8.0, 8.0) ]))

## "path" - Creates a path object

Usage:

- path(...)

This function creates a path object. The arguments are the same than for the DPath constructors.

## "perimeter" - Selects the primary shape if the perimeter is meeting the condition

Usage:

- perimeter (in condition)
- perimeter(layer)

This function can be used with a layer argument in which case it is equivalent to "layer.perimeter" (see Layer#perimeter). Without a layer argument, "perimeter" represents a perimeter filter for primary shapes in DRC expressions (see Layer#drc and DRC#perimeter for more details).

## "polygon" - Creates a polygon object

Usage:

- polygon(...)

This function creates a polygon object. The arguments are the same than for the DPolygon constructors.

## "polygon_layer" - Creates an empty polygon layer

Usage:

- polygon_layer

The intention of that method is to create an empty layer which can be filled with polygon-like objects using Layer#insert. A similar method which creates a hierarchical layer in deep mode is make_layer. This other layer is better suited for use with device extraction.

## "polygons" - Fetches the polygons (or shapes that can be converted to polygons) from the specified input from the default source

Usage:

- polygons(args)

See Source#polygons for a description of that function.

## "primary" - Represents the primary input of the universal DRC function

Usage:

- primary

The primary input of the universal DRC function is the layer the Layer#drc function is called on.

## "rectangles" - Selects all polygons which are rectangles

Usage:

- rectangles
- rectangles(layer)

This function can be used with a layer argument in which case it is equivalent to "layer.rectangles" (see Layer#rectangles). Without a layer argument, "rectangles" represents the rectangles filter for primary shapes in DRC expressions (see Layer#drc and DRC#rectangles for more details).

## "rectilinear" - Selects all polygons which are rectilinear

Usage:

- rectilinear
- rectilinear(layer)

This function can be used with a layer argument in which case it is equivalent to "layer.rectilinear" (see Layer#rectilinear). Without a layer argument, "rectilinear" represents the rectilinear polygons filter for primary shapes in DRC expressions (see Layer#drc and DRC#rectilinear for more details).

## "report" - Specifies a report database for output

Usage:

- report(description [, filename [, cellname ] ])

After specifying a report database for output, output method calls are redirected to the report database. The format of the output calls changes and a category name plus description can be specified rather than a layer/datatype number of layer name. See the description of the output method for details.

If a filename is given, the report database will be written to the specified file name. Otherwise it will be shown but not written.

If external input is specified with source, "report" must be called after "source".

The cellname specifies the top cell used for the report file. By default this is the cell name of the default source. If there is no source layout you'll need to give the cell name in the third parameter.

## "report_netlist" - Specifies an extracted netlist report for output

Usage:

- report_netlist([ filename [, long ] ])

This method applies to runsets creating a netlist through extraction. Extraction happens when connections and/or device extractions are made. If this statement is used, the extracted netlist plus the net and device shapes are turned into a layout-to-netlist report (L2N database) and shown in the netlist browser window. If a file name is given, the report will also be written to the given file. If a file name is given and "long" is true, a verbose version of the L2N DB format will be used.

## "resistor" - Supplies the resistor extractor class

Usage:

- resistor(name, sheet_rho)

Use this class with extract_devices to specify extraction of a resistor.

The sheet_rho value is the sheet resistance in ohms/square. It is used to compute the resistance from the geometry.

See DeviceExtractorResistor for more details about this extractor.

## "resistor_with_bulk" - Supplies the resistor extractor class that includes a bulk terminal

Usage:

- resistor_with_bulk(name, sheet_rho)

Use this class with extract_devices to specify extraction of a resistor with a bulk terminal. The sheet_rho value is the sheet resistance in ohms/square.

See DeviceExtractorResistorWithBulk for more details about this extractor.

## "rounded_corners" - Applies corner rounding

Usage:

- rounded_corners(inner, outer, n)
- rounded_corners(layer, inner, outer, n)

This function can be used with a layer argument in which case it is equivalent to "layer.rounded_corners" (see Layer#rounded_corners). Without a layer argument, "rounded_corners" represents the corner rounding algorithm on primary shapes within DRC expressions (see Layer#drc and DRC#rounded_corners for more details).

## "secondary" - Provides secondary input for the "drc" universal DRC function

Usage:

- secondary(layer)

To supply additional input for the universal DRC expressions (see Layer#drc), use "secondary" with a layer argument. This example provides a boolean AND between l1 and l2:

    l1 = layer(1, 0)
    l2 = layer(2, 0)
    out = l1.drc(primary & secondary(l2))

## "select" - Specifies cell filters on the default source

Usage:

- select(args)

See Source#select for a description of that function.

## "sep" - Synonym for "separation"

Usage:

- sep(...)

"sep" is the short form for separation.

## "separation" - Performs a separation check

Usage:

- separation(other [, options ]) (in conditions)
- separation(layer, other [, options ])

Provides a separation check (primary layer vs. another layer). Like enclosing this function provides a two-layer check. See there for details how to use this function.

## "silent" - Resets verbose mode

Usage:

- silent

This function is equivalent to "verbose(false)" (see verbose)

## "sized" - Returns the sized version of the input

Usage:

- sized(d [, mode])
- sized(dx, dy [, mode]))
- sized(layer, d [, mode])
- sized(layer, dx, dy [, mode]))

This function can be used with a layer argument in which case it is equivalent to "layer.sized" (see Layer#sized). Without a layer argument, "sized" represents the polygon sizer on primary shapes within DRC expressions (see Layer#drc and DRC#sized for more details).

## "smoothed" - Applies smoothing

Usage:

- smoothed(d)
- smoothed(layer, d)

This function can be used with a layer argument in which case it is equivalent to "layer.smoothed" (see Layer#smoothed). Without a layer argument, "smoothed" represents the polygon smoother on primary shapes within DRC expressions (see Layer#drc and DRC#smoothed for more details).

## "source" - Specifies a source layout

Usage:

- source
- source(what)

This function replaces the default source layout by the specified file. If this function is not used, the currently active layout is used as input.

layout is a similar method which specifies an additional input layout.

"what" specifies what input to use. "what" be either

- A string "@n" specifying input from a layout in the current panel
- A layout filename plus an optional cell name
- A Layout object plus an optional cell name
- A Cell object

Without any arguments the default layout is returned. If a filename is given, a cell name can be specified as the second argument. If none is specified, the top cell is taken which must be unique in that case.

    # XOR between layers 1 of "first_layout.gds" and "second_layout.gds" and sends the results to "xor_layout.gds":
    target("xor_layout.gds")
    source("first_layout.gds")
    l2 = layout("second_layout.gds")
    (input(1, 0) ^ l2.input(1, 0)).output(100, 0)

For further methods on the source object see Source.

## "space" - Performs a space check

Usage:

- space([ options ]) (in conditions)
- space(layer [, options ])

Provides a space check on the primary layer. Like width this function provides a single-layer check. See there for details how to use this function.

## "target" - Specify the target layout

Usage:

- target(what [, cellname])

This function can be used to specify a target layout for output. Subsequent calls of "output" will send their results to that target layout. Using "target" will disable output to a report database. If any target was specified before, that target will be closed and a new target will be set up.

"what" specifies what input to use. "what" be either

- A string "@n" (n is an integer) specifying output to a layout in the current panel
- A string "@+" specifying output to a new layout in the current panel
- A layout filename
- A Layout object
- A Cell object

Except if the argument is a Cell object, a cellname can be specified stating the cell name under which the results are saved. If no cellname is specified, either the current cell or "TOP" is used.

## "target_netlist" - With this statement, an extracted netlist is finally written to a file

Usage:

- target_netlist(filename [, format [, comment ] ])

This method applies to runsets creating a netlist through extraction. Extraction happens when connections and/or device extractions are made. If this statement is used, the extracted netlist is written to the given file.

The format parameter specifies the writer to use. You can use nil to use the standard format or produce a SPICE writer with write_spice. See write_spice for more details.

## "threads" - Specifies the number of CPU cores to use in tiling mode

Usage:

- threads(n)
- threads

If using threads, tiles are distributed on multiple CPU cores for parallelization. Still, all tiles must be processed before the operation proceeds with the next statement.

Without an argument, "threads" will return the current number of threads

## "tile_borders" - Specifies a minimum tile border

Usage:

- tile_borders(b)
- tile_borders(bx, by)

The tile border specifies the distance to which shapes are collected into the tile. In order words, when processing a tile, shapes within the border distance participate in the operations.

For some operations such as booleans (and, or, ...), size and the DRC functions (width, space, ...) a tile border is automatically established. For other operations such as with_area or edges, the exact distance is unknown, because such operations may have a long range. In that cases, no border is used. The tile_borders function may be used to specify a minimum border which is used in that case. That allows taking into account at least shapes within the given range, although not necessarily all.

To reset the tile borders, use no_borders or "tile_borders(nil)".

## "tiles" - Specifies tiling

Usage:

- tiles(t)
- tiles(w, h)

Specifies tiling mode. In tiling mode, the DRC operations are evaluated in tiles with width w and height h. With one argument, square tiles with width and height t are used.

Special care must be taken when using tiling mode, since some operations may not behave as expected at the borders of the tile. Tiles can be made overlapping by specifying a tile border dimension with tile_borders. Some operations like sizing, the DRC functions specify a tile border implicitly. Other operations without a defined range won't do so and the consequences of tiling mode can be difficult to predict.

In tiling mode, the memory requirements are usually smaller (depending on the choice of the tile size) and multi-CPU support is enabled (see threads). To disable tiling mode use flat or deep.

Tiling mode will disable deep mode (see deep).

## "verbose" - Sets or resets verbose mode

Usage:

- verbose
- verbose(m)

In verbose mode, more output is generated in the log file

## "verbose?" - Returns true, if verbose mode is enabled

Usage:

- verbose?

In verbose mode, more output is generated in the log file

## "width" - Performs a width check

Usage:

- width([ options ]) (in conditions)
- width(layer [, options ])

This function can be used with a layer argument in which case it is equivalent to "layer.width" (see Layer#width).

The version without a layer is intended for use within DRC expressions together with the Layer#drc method. In this case, this function needs to be put into a condition to specify the check constraints. The other options of Layer#width (e.g. metrics, projection constraints, angle limits etc.) apply to this version too.

The conditions may involve an upper and lower limit. The following examples illustrate the use of this function with conditions:

    out = in.drc(width < 0.2.um)
    out = in.drc(width <= 0.2.um)
    out = in.drc(width > 0.2.um)
    out = in.drc(width >= 0.2.um)
    out = in.drc(width == 0.2.um)
    out = in.drc(0.1.um <= width < 0.2.um)

The result of the width check are edge pairs forming the violation markers. With a lower limit, these markers are formed by two, identical but opposite edges attached to the primary shape. Without a lower limit, both edges are attached to different sides of the primary shape.

## "write_spice" - Defines SPICE output format (with options)

Usage:

- write_spice([ use_net_names [, with_comments ] ])

Use this option in target_netlist for the format parameter to specify SPICE format. "use_net_names" and "with_comments" are boolean parameters indicating whether to use named nets (numbers if false) and whether to add information comments such as instance coordinates or pin names.