Glade Reference
A cellView stores design data. It is a unique combination of a cell and a view. CellViews correspond to GDS2 STRUCTs, LEF MACROs or a DEF DESIGN. CellViews are stored in a library. CellView access functions are as follows. Note that all coordinate values are expected in database units. To find the number of database units per micron, use the library::dbuPerUU() function.
Creating or opening cellViews
Create a cellView in an existing library lib with cell cellName and view viewName. The function returns a cellview. mode is a single character denoting the access mode; 'r' signifies readonly access, 'w' signifies write access (the cellview should not already exist and will be created), and 'a' signifies append access (the cellview already exists and is opened for modification). Note that after creating a new cellView and any objects in it, update() must be called to build the data structures before editing/viewing/querying.
Creating objects in a cellView
A cellView contains shape and instance/array objects. Shape objects are created on a specified layer number, which is internally represented by a signed 16 bit integer value. To get a layer number given a layer name and purpose, you can use the db_Techfile class functions to get and manipulate layers.
Creates a rectangle object in the cellView with bounding box box and on layer layer and returns the created rectangle. If use_rect is false (the default), a square will be created instead of a rectangle if the box width equals the box height.
For example to create a rectangle on layer 3:
box = Rect(0, 0, 1000, 2000) layer = 3 cv.dbCreateRect(box, layer
Create a polygon object in the cellView and returns the polygon created. The array xpts and ypts are the X and Y coordinates of the polygon and should be created in python using the intarray() function. numPoints specifies the number of points and layer the layer the polygon is created on. If use_poly is false (the default), a rectangle will be created instead of a polygon if possible.
For example to create a triangle on layer 3:
numPoints = 3 x = intarray(numPoints) y = intarray(numPoints) x[0] = 0 y[0] = 0 x[1] = 2000 y[1] = 0 x[2] = 0 y[2] = 2000 layer = 3 poly = cv.dbCreatePolygon(x, y, numPoints, layer)
Similar to the above, but uses a python list of points, each of which is a list of x and y coordinates of the point.
poly = cv.dbCreatePolygon([[0,0],[1000,0],[1000,1000],[0,1000]], 4, 3)
polygon * p = cv.dbCreateHole(int *xpts, int *ypts, int nPoints, int lyr, shape *obj=NULL)
Creates a hole in a polygon . The hole to be 'cut' is represented by the poygon defined by xpts, ypts, nPoints. The polygon and hole are on layer lyr. If obj is non-null, it is assumed to be the polygon to cut the hole in; if non-null, the largest polygon that overlaps the hole will be cut. In general, it is better to use the boolean operations to cut holes in polygons as they are more robust.
Creates a label in the cellView at location origin with text name and returns the label created. The orientation of the label is given by orient and the label height by height. presentation is the alignment of the text label and layer is the label's layer.
Create a path object in the cellView and returns the path created. The array xpts and ypts are the X and Y coordinates of the path. numPoints specifies the number of points and layer the layer the polygon is created on. width is the width of the path and style the path style (0 = truncate, 1 = extend, 2 = octagonal, 4 = varExtend). If the path style is type 4, varExtend, then beginExtent and endExtent specify the path extension beyond the beginning and ending points.
Create a path object in the cellView and returns the path created. The python ptlist is a list of points, each of which is a list of x and y coordinates of the point. numPoints specifies the number of points and layer the layer the polygon is created on. width is the width of the path and style the path style (0 = truncate, 1 = extend, 2 = octagonal, 4 = varExtend). If the path style is type 4, varExtend, then beginExtent and endExtent specify the path extension beyond the beginning and ending points.
mpp *m = cv. dbCreateMPP(inst *xpts, int *ypts, inst nPoints)
Creates a MPP (MultiPartPath) in the cellView and returns the mpp created. The array xpts and ypts are the X and Y coordinates of the path. numPoints specifies the number of points.
Create an inst in the cellView and returns the instance created. The instance master cellView is specified by libName/cellName/viewName. The instance's origin is given by origin and its orientation by orient. The enumerations R0, R90, R180, R270, MX, MXR90, MY, MYR90 can be used to specify the orientation. Orientations other than variants of 90 degrees are not currently supported. The magnification is specified by mag. If specified, instName is used to name the instance; else the instance name is autogenerated with the first being I0, then I1, I2 etc.
Create an inst in the cellView and returns the instance created. This is identical to the above but takes a library *, rather than a library name, as argument. The instance master cellView is specified bycellName/viewName. The instance's origin is given by origin and its orientation by orient. The enumerations R0, R90, R180, R270, MX, MXR90, MY, MYR90 can be used to specify the orientation. Orientations other than variants of 90 degrees are not currently supported. The magnification is specified by mag. If specified, instName is used to name the instance; else the instance name is autogenerated with the first being I0, then I1, I2 etc.
Finds the instance with name name in the cellView and returns it, or null if not found.
Create an array in the cellView and returns the array created. The array master cellView is specified by libName, cellName and viewName. The array's origin is given by origin and its orientation by orient. The enumerations R0, R90, R180, R270, MX, MXR90, MY, MYR90 can be used tp specify the orientation. Orientations other than variants of 90 degrees are not supported. The magnification is specified by mag. If specified, instName is used to name the instance; else the instance name is autogenerated with the first being I0, then I1, I2 etc. numRows specifies the number of rows and must be greater than 0. numCols specifies the number of columns and must be greater than 0. rowSpacing is the spacing between rows and can be negative or positive, as can colSpacing.
Create an array in the cellView and returns the array created. This is identical to the above but takes a library *, rather than a library name, as argument. The array master cellView is specified by libName, cellName and viewName. The array's origin is given by origin and its orientation by orient. The enumerations R0, R90, R180, R270, MX, MXR90, MY, MYR90 can be used tp specify the orientation. Orientations other than variants of 90 degrees are not supported. The magnification is specified by mag. If specified, instName is used to name the instance; else the instance name is autogenerated with the first being I0, then I1, I2 etc. numRows specifies the number of rows and must be greater than 0. numCols specifies the number of columns and must be greater than 0. rowSpacing is the spacing between rows and can be negative or positive, as can colSpacing.
Creates an viaInst of a via with master name, origin origin and orient orient and returns the viaInst created.
hseg *h = cv.dbCreateHSeg(int x1, int y1, int x2, int y2, int layer, net *n, int width=0, int style=DB_TRUNCATED)
A HSeg is a horizontal track segment. HSegs are a memory efficient way of representing a two point path with a given layer that has a fixed width and style, and as such are used in representing DEF regular net routing. This function creates a HSeg object in the cellView and returns the HSeg created. (x1, y1) is the first point of the HSeg, (x2, y2) is the second point. layer is the layer the HSeg is created on. width is the HSeg width (defaults to 0) and style is the HSeg's path style (defaults to truncated). If the cellView's library does not contain a segparam index for the HSeg with matching layer and width/style, one is created.
vseg *v = cv.dbCreateVSeg(int x1, int y1, int x2, int y2, int layer, net *n, int width=0, int style=DB_TRUNCATED)
A VSeg is a vertical track segment. VSegs are a memory efficient way of representing a two point path with a given layer that has a fixed width and style, and as such are used in representing DEF regular net routing. This function creates a VSeg object in the cellView and returns the VSeg created. (x1, y1) is the first point of the VSeg, (x2, y2) is the second point. layer is the layer the VSeg is created on. width is the VSeg width (defaults to 0) and style is the VSeg's path style (defaults to truncated). If the cellView's library does not contain a segparam entry for the VSeg, one will be created with matching layer and width/style, one is created.
Create an ellipse with given origin (the centre of the ellipse), xRadius, yRadius and layer number
Create a circular ellipse, i.e. one with the same X and Y radius.
Create an arc with the specified origin, X and Y radius. The arc is part of an ellipse with the specified startAngle and stopAngle.
Creates a line in the cellView with vertices defined by points p1 and p2 on layer layer and returns the line created.
Creates a line in the cellView with vertices defined by integer arrays x and y with size numPoints on layer layer and returns the line created.
Creates a line in the cellView with vertices defined by the python list ptlist, which is a list of points. Each point is a list of x and y coordinates. numPoints is the number of points. The line is created on layer layer..
Creating connectivity in a cellView
A cellView can also contain connectivity, such as nets, pins and ports (physical pin shapes).
Creates a net in the cellView with name name and returns the net created. If the net already exists in the cellView, the net is not created.
Finds the net with name name in the cellView and returns it, or null if not found.
Creates a logical pin in the cellView with name name and db_PinDirection dir for the net n and returns the pin created. The net n must exist in the cellView.
Finds the pin with name name in the cellView and returns it, or null if not found.
Creates a port for pin p . A port is a physical representation of a pin so a valid shape s must be specified.
Creating and updating PCell instances in a cellView
PCell (programmable cell) instances can be created in a cellView. See also loadPCell.
Create an instance of a PCell in the cellView and returns the instance created. The PCell master must have been previously created e.g. by a call to ui::loadPCell(). libName is the library name containing the pcell, cellName is the cellView name of the PCell and viewName is the view type of the PCell. origin is the instance's origin. If specified, orient is the instance's orientation, otherwise defaulting to R0. If numRows or numCols are not 1, an array is created of PCells.
Updates a PCell instance after any of its properties have been changed. This is equivalent to querying the PCell instance properties in the GUI and changing them. Note that the originalInst is destroyed, and newInst is created.
Searching for objects in a cellView
Searches the area given by box for any objects whose bounding boxes overlap the area. If allLayers is 0, then shapes on only the specified layer are returned. If allLayers is 1, shapes on all layers are searched. If instsToo is 1, any instances whose bounding box overlaps the area are returned in addition to any valid shapes, similarly is viaInstsToo is 1 then any via insts that overlap are also checked.
As above, but returns a Python list of dbObj.
As dbGetOverlaps, but appends objects found to list.
Searches the are given by box for any objects whose bounding boxes overlap the area. If allLayers is 0, only the shapes on the specified layer are returned. If allLayers is 1, shapes on all layers are searched. The search is carried out hierarchically up to level levels deep.
A dbHierObj is a simple class conatining the object itself, the cellView containing the object and the transform of the object relative to the top level.
cellView utility functions
Updates the cellView's bounding box to enclose all objects it contains. This function is deprecated and update() should be used.
Build the internal data structures for the cellView. This must be called after creating any objects in a new cellView, but before viewing / editing / querying the cellView. This function is deprecated and update() should be used.
cv.update()
Calls updateBbox(), optimiseTrees(), sets the cellView as edited and sets the modification date. This should be called after a modification, or a set of modifications, to the cellView. For perfomance reasons it is better to call this after a set of operations rather than for each operation.
Get the bounding box of the cellView as a Rect.
Resets the cellView's bounding box to (0,0) (0,0).
The existing cellView's bounding box becomes the union of the current bounding box and box.
Rect box = cv.getBoundary()
Gets the cellView's boundary rectangle, if such a shape exists on the boundary drawing layer.
Delete the database object object. If reallyDelete is true, the object is deleted, else it is just removed from the object trees (and hence undoing the delete is possible). If opt is true, the tree is (re)optimised after the delete.
Get the number of shapes in the cellview.
Get the number of instances in the cellview.
Get the number of viaInsts in the cellview
Get the number of nets in the cellview.
Get the number of pins in the cellview.
Get the cellview's library.
bool val = cv.isPCell()
returns true if the cellView is a PCell superMaster.
bool val = cv.isSubMaster()
Returns true if the cellView is a PCell subMaster.
Get the cellview's name.
Get the cellview's viewname.
Get the nearest object to a point p in the cellview, up to a maximum distance dist.
Get the layer-purpose pair with layer number layer in this cellview.
Delete the layer-purpose pair lpp in this cellview. All objects (shapes, insts and viaInsts) on that lpp will be deleted.
Returns a Python list of all layer-purpose pairs in the cellview. This is a python wrapper created using the SWIG %extend function.
Returns a Python list of all instances in the cellView. This is a python wrapper created using the SWIG %extend function.
Returns a Python list of all nets in the cellView. This is a python wrapper created using the SWIG %extend function.
Returns a Python list of all pins in the cellView. This is a python wrapper created using the SWIG %extend function.
shape *new_shp = cv.roundCorners(shape *shp, int inner_radius, int outer_radius, int segs, double grid)
Rounds the shape shp with the radius given in dbu, using a minimum number of segments segs, and snaps the vertices of the curve to grid in microns. inner_radius is the radius of inner (concave) corners; outer_radius is the radius of outer (convex) corners.
Iterators
Instead of using getInsts/getNets/getPins/getLpps it is possible to use iterators in Python:
iter = instIterator(cellView *cv)
Initialises the inst iterator for the cellView. For example:
from ui import *
cv = getEditCellView()
iter = instIterator(cv)
while not iter.end() :
inst = iter.value()
name = inst.instName()
print "inst name = ", name
iter.next()
iter.next()
Advances the iterator to the next instance.
bool iter.end()
Returns false if there are more instances, else returns true if there are no more.
inst = iter.value()
Returns the current instance.
iter = netIterator(cellView *cv)
Initialises the net iterator for the cellView. The iterator has similar next(), end() and value() functions as above.
iter = pinIterator(cellView *cv)
Initialises the pin iterator for the cellView. The iterator has similar next(), end() and value() functions as above.
iter = lppIterator(cellView *cv)
Initialises the dbLpp iterator for the cellView. The iterator has similar next(), end() and value() functions as above.