Magic-7.3 Command Reference

#

## search

Execute a TCL procedure on each tile in the current edit cell definition.

### Usage:

> search [layers] procedure

> > where layers is a comma-separated list of layer types to generate a mask to limit the tile search, and procedure is the name of a predefined Tcl procedure (see Summary, below).

### Summary:

> The search command is a method for user access to the magic database search routines. It searches the tile database of the current edit cell definition and its hierarchy of descendents and applies the callback procedure to each. The callback procedure must be defined as described below.

> Note that the callback method into Tcl is inherently slow and should only be used for non-compute-intensive tasks. In particular, unless it is known that the cell definition being traversed has relatively few structures, the layers argument should be used to severely limit the scope of the search. This function can be useful in certain situations, such as parsing a layout for layer "pad" to enumerate the number of pads in a design.

> The Tcl callback procedure is passed five values, the four coordinates of the tile, and the layer type of the tile. The procedure must be defined to accept these five arguments, as in the following example:

> > `

> >     	proc tile_callback {llx lly urx ury ttype} {
> >     	   puts stdout "Tile type $ttype at $llx $lly $urx $ury"
> >             }

> > `

> When non-manhattan tiles are parsed, the type $ttype is passed as a list of two string elements, the type on the left side of the diagonal split, and the type on the right side of the diagonal split.

### Implementation Notes:

> search is implemented as an internal magic command that links to an external Tcl procedure as a callback function. This routine is experimental and subject to change without notice.

### Bugs:

> As currently implemented, there is no protection against calling a magic command from the callback procedure that will alter the internal tile structures while the tile plane is being traversed, causing a crash. The implementation should be changed to a 2-step procedure that traverses the tile plane first, creating an internal list of function arguments to pass for each tile, and then executes the callback function on each.

> There are more efficient ways of executing the callback function than Tcl_EvalEx(). In particular, the procedure should be cast as a Tcl object and Tcl_EvalObjEx() used.

> The callback function should allow in-line Tcl procedures and use the standard Tcl/Tk method of "%" escape sequences used as arguments to the callback function that allow the user to specify what arguments are passed to the callback function (as is done for the tag command).

### See Also:

> cellsearch

Return to command index

Last updated: October 4, 2004 at 5:05am