next up previous contents index
Next: Object Management by Handles Up: Geometry Editing Functions 1 Previous: Current Transform   Contents   Index

Derived Layers

These functions provide an interface to the derived layer capability (see 15.2). Derived layers are invisible internal layers that imply geometry resulting from evaluation of a layer expression, which may involve normal layers and other derived layers. Derived layers are recognized by name in layer expressions.

There are actually two implementations of derived layer functionality. The interface functions allow explicit choice of which evaluation method to use. Within Xic, this detail is generally invisible to the user.

In the original implementation, developed for the DRC system, the geometry of derived layers must be created or updated before the derived layer is referenced. In use, reference to a derived layer in a layer expression retrieves this geometry, very similar to what happens when a normal layer is referenced. Ordinarily, the derived layer geometry will be cleared after final use. This method may be fast when the same layer expressions must be evaluated many times, so it seems a good match for DRC, where it is used.

To use this method, the interface function EvalDerivedLayers is called to create the geometry for each derived layer that will be evaluated. Then, GetDerivedLayerLexpr is called with a boolean true second argument to get the evaluation objects as needed, which are evaluated to create new geometry. When done, ClearDerivedLayers is called to destroy the precomputed geometry.

In the second mode of operation, when the parse tree for the derived layer is created, references to derived layers will be recursively parsed and stitched into the tree. The final parse tree will contain normal layers only, and can therefor be evaluated in any context, without the need for precomputed geometry caches.

With this method, there is no need to call EvalDerivedLayers and ClearDerivedLayers, as there is no use of cached geometry. The evaluation object is returned from GetDerivedLayerLexpr with a boolean false second argument.

(int) AddDerivedLayer(lname, index, lexpr)
This will add a derived layer to the database, under the name given in the first argument. The second argument is an integer layer number for the layer, which is used for ordering when the derived layers are printed, for example to an updated technology file. If not positive, Xic will generate a number to be used for a new layer. Numbers need not be unique, sorting is alphabetic among derived layer names with the same index number. If a derived layer of the same name already exists, it will be silently overwritten.

The third argument is a string starting with an optional keyword followed by a layer expression, separated by space. The keyword is one of join, split, or splitv. These are the same keywords, and have the same effects, as is explained for the DerivedLayer keyword in the technology file. The expression can reference by name ordinary layers and derived layers. The expression is not parsed until evaluation time.

The function fails if either the lname or lexpr are null or empty strings.

(int) RemDerivedLayer(lname)
If a derived layer exists with the given name, remove the definition from the internal registry, so that the derived layer definition and any existing geometry becomes inaccessible. The derived layer definition can be restored with AddDerivedLayer. If the derived layer is found and removed, this function will return 1, otherwise 0 is returned.

(int) IsDerivedLayer(lname)
This function will return 1 if the string argument matches a derived layer name in the database, 0 otherwise. Matching is case-insensitive.

The name can be in the form ``layer:purpose'' as for normal Xic layers, however the entire token is taken verbatim. This is a subtle difference from normal layers, where for example ``m1:drawing'' and ``m1'' are equivalent (the drawing purpose being the default). As derived layer names, the two would differ, and the notion of a purpose does not apply to derived layers.

(int) GetDerivedLayerIndex(lname)
This returns a positive integer which is the layer index number of the derived layer whose name was given, or 0 if no derived layer can be found with that name (case insensitive).

(string) GetDerivedLayerExpString(lname)
This returns the layer expression string for the derived layer whose name is passed. If the derived layer is not found, a null string is returned.

(layer_expr) GetDerivedLayerLexpr(lname, noexp)
This returns a parsed layer expression object created from the layer expression of the derived layer whose name is passed. This can be passed to other functions which can use this data type. If there is a parse error, the function fails fatally. Otherwise the return is a valid parse tree object.

The boolean second argument will suppress derived layer expansion if set.

There are two ways to handle derived layers. Generally, layer expression parse trees are expanded (second argument is false), meaning that when a derived layer is encountered, the parser recursively descends into the layer's expression. The resulting tree references only normal layers, and evaluation is straightforward.

A second approach might be faster. The parse trees are not expanded (second argument is true), and a parse node to a derived layer contains a layer descriptor, just as for normal layers. Before any computation, EvalDerivedLayers must be called, which actually creates database objects in a database for the derived layer. Evaluation involves only finding the geometry in the search area, as for a normal layer.

(string) EvalDerivedLayers(list, array)
Derived layer evaluation objects (such as the return from GetDerivedLayerLexpr) that are not recursively expanded must have derived layer geometry precomputed before use. This function creates derived layer geometry for this purpose.

Evaluation creates the geometry described by the layer expression. Derived layers are never visible, so this geometry is internal, but can be accessed, e.g., by design rule evaluation functions, or used to create normal layers with the !layer command or the Evaluate Layer Expression panel from the Edit Menu.

The first argument is a string containing a list of derived layer names, separated by commas or white space. The function will evaluate these derived layers, and any derived layers referenced in their layer expressions, in an order such that the derived layers will be evaluated before being referenced during another evaluation.

All geometry created will exist in the current cell, and the layer expressions will source all levels of the hierarchy. Any geometry left in the current cell from a previous evaluation will be cleared first. Derived layer geometry in subcells is ignored.

The second argument can set the area where the layers will be evaluated, which can be any rectangular region of the current cell. This can be an array of size four or larger, specifying left, bottom, right, and top coordinates in microns in the 0, 1, 2, 3 indices. The argument can also be a scalar 0 which indicates to use the entire current cell.

The return is a string listing all of the derived layers evaluated, which will include derived layers referenced by the original list but not included in the list. This should be passed to ClearDerivedLayers when finished using the layers.

(int) ClearDerivedLayers(list)
The argument is a string containing a list of derived layer names, separated by commas or white space. This may be the return from EvalDerivedLayers. All of the layers listed will be cleared in the current cell. If a layer name is not resolved as a derived layer, it is silently ignored. Clearing already clear layers is not an error. Derived layers should be cleared after their work is done, to recycle memory. The return value is an integer count of the number of derived layers that were cleared.

next up previous contents index
Next: Object Management by Handles Up: Geometry Editing Functions 1 Previous: Current Transform   Contents   Index
Stephen R. Whiteley 2022-05-28