Glade Reference


UI Python command reference

This document describes the Python functions available to control the Glade GUI. Argument types are shown as C++ types with default values where applicable, however all arguments are really python variables. Note in Python the bool type is mapped to an integer. All of the following functions are part of the ui class. There is a global pointer to the gui called cvar.guiptr . Therefore to use them , define you own variable e.g. gui=cvar.guiptr, then call as  gui.OpenCellView(...)

 

int errors = ui.check (char *libName, char *cellName, char *viewName)

Check a schematic or symbol cellView. errors is the number of errors found, or -1 if the cell could not be checked.

 

bool ok = ui.createCellView (char *libName, char *cellName, char *viewName)

Create a symbol cellView from the given cellView (normally a schematic). Returns True if successful.

 

bool ok = ui.loadPCell(char *libName, char *pcellName)

Loads the PCell with name pcellName into the library libName. If the PCell already exists in the library, the action is ignored and returns true. If a cellView with the same name exists, it is deleted and is replaced by the PCell supermaster. Note that once a PCell is loaded into a library and that library is saved, it will remain a PCell, so there is no need to load it again (although it is harmless and you will just get warnings about the load being ignored). If the PCell cannot be created, it returns false.

 

ui.addMarker( int x, int y, int size=20, int lineWidth=0, color=Qt::yellow)

Adds a marker at the specified x and y values (given in database units). The size of the marker defaults to 20 dbu and the linewith to 0 (i.e. one pixel wide).

 

ui.clearMarkers()

Clears all markers.

 

ui.getSelectedSet()

Returns a dbObjList of the selected set. There is also a top level python binding of the same name that returns a python list of selected objects.

 

ui.getEditCellView()

Returns the current cellview being edited. If multiple cellviews are open, it returns the cellview of the current active window. There is also a top level python binding to this function, getEditCellView().

 

ui.getLibByName(const char *name)

Returns the library given by name.

 

ui.getLibList()

Returns a dbObjList of all open libraries. There is also a top level python binding of the same name that returns a python list of open libraries.

 

ui.getCellList()

Returns a dbObjList of all open cellViews. There is also a top level python binding of the same name that returns a python list of open cellViews.

 

ui.openCellView (const char * libName, const char * cellName, const char * viewName)

Opens the cellview specified by libName, cellName and viewName in a new window.

 

bool ok = ui.importTech(const char *libName, const char *techFileName, unsigned int dbu=1000)

Imports the techfile techFileName into the library libName. The library is created if it does not already exist. Returns true if no error occurred.

 

bool ok = ui.exportTech(const char *libName, const char *techFileName, bool systemLayers)

Exports the techfile techFileName from the library libName. The library must exist. If systemLayers is 1, Glade system layers e.g. cursor, backgnd etc will be written to the techfile. This is only necessary if you have modified the system layers in the LSW - for example changed the backgnd color from black to white. Returns true if no error occurred.

 

bool ok = ui.importGds2 (const char * libName, const char * gdsFileName, const char * dumpFile = NULL, int csen = 0, bool do_dump = False, double gdsScaleFactor = 1.0, double gdsXOffset = 0.0, double gdsYOffset = 0.0, int gdsNetAttr = 0, int gdsInstAttr = 0, bool compressed=False, bool dubiousData=True, bool setDBUfromGDS=True, bool reportCells=False, int pathConv=2, int convLayers=0, int layer=0, int datatype=0, bool openTopCell=False, bool setLibName=False, bool convertVias=False, int duplicates=0, char *viewName="layout")

Import the GDS2 file gdsFileName into library libName. The library is created if it does not already exist. If do_dump is 1 and dumpFile is a valid file name, the GDS2 will be written in an ascii format suitable for debugging purposes. gdsScaleFactor can be used to scale all coordinates in the GDS2 file. gdsXOffset and gdsYOffset can be used to apply a fixed offset to all GDS2 coordinates. gdsNetAttr specifies the GDS2 attribute number used for net names, if present, and gdsInstAttr specifies the GDS2 attribute number for instance names, if present. If compressed is true, a gzip compressed format file is expected and will be uncompressed during stream in. If dubiousData is true, dubious data constructs in the GDS2 file are reported. If setDBUfromGDS is true, the library DBUperUU is set from the GDS DBU. If reportCells is true, cells are reported in the message window as they are read. pathconv is used to control 2 point path conversion. If set to 0, 2 point manhattan paths are converted to rectangles. If set to 1, 2 point manhattan paths are set to H/VSegs. If set to 2 (the default), paths remain as paths. convLayers determines which layers are imported. If set to 0 (the default), all layers found in the GDS2 file are converted. If set to 1, only layers that are defined in the techfile with gds layer number/datatypes are imported. If set to 2, only a single layer will be imported, defined by layer and datatype. If openTopCell is true, all potential top cell candidates are opened in the gui. A top cell candidate is any cell that is not referenced by another cell, and is not empty. If setLibName is true, the library name is set to that of the GDS2 library name. If convertVias is true, Glade will convert via cells to Glade vias, and instances of these via cells to viaInsts. duplicates controls handling of duplicate cell definitions. If 0, duplicate cells replace any existing cell definitions. If 1, duplicate cells definitions are ignored. If 2, duplicate cell data is merged into existing cells. viewName sets the view name of cellViews created during import GDS2.

 

bool ok = ui.exportGds2 (const char * libName, const char * viewNames, const char * gdsFileName, bool outputInstAttrs=0, bool outputNetAttrs=false, bool outputAllCells=true, const char * topCellName =NULL, int instAttr=0, int netAttr=0, bool compressed=False, bool reportCells=False, double grid=0.005, bool writeViaCells=True)

Export a GDS2 file gdsFileName from the library libName. viewNames is a space seperated list of view names to export. If outputAllCells is true then all cells in the library are output to the GDS2 file and topCellName is ignored. If outputAllCells is false then topCellName is a space or comma delimited list of cells to output. If outputInstAttrs is true then instance names are output as GDS2 attributes with attribute number given by instAttr. If outputNetAttrs is true then net names are output as GDS2 attributes with attribute number given by netAttr. If compressed is true the GDS2 file is written in gzip compressed format according to RFC1951. If reportCells is true, cells are reported in the message window as they are written. grid specifies the manufacturing grid, used to snap vertices of circles/ellipses as they are converted to polygons on export. writeViaCells if true will write vias as cells and viaInsts as instances, else vias will get flattened.

 

bool ok = ui.importLef (const char * libName, const char * lefFileName, bool compressed= 0, bool generateLabels= 1, float size=0.25. bool allPinShapes=false)

Import a LEF file lefFileName into the library libName. The library will be created if it does not already exist. If compressed is true a gzip compressed format file is expected and will be uncompressed during LEF in. If generateLabels is true, text labels will be generated on the Text layer for each pin in the LEF macro. size sets the size of the generated labels. If allPinShapes is true (1), then text labels are generated for all pin shapes.

 

bool ok = ui.exportLef (const char * libName, const char * lefFileName, bool technology=1, bool allCells=1, const char * powerNets=NULL, const char * groundNets=NULL)

Export a LEF file lefFileName from library libName. If technology is true, the LEF technology section will be included in the LEF file. If allCells is true, all library cells will be output, else only the current open cellView will be output. The string powerNets is a space delimited list of net names. Any pins with a name in this list will have their +USE attribute set to POWER. Similarly, the string groundNets is a space delimited list of net names; any pins with a name in this list will have their +USE attribute set to GROUND.

 

bool ok = ui.importDef (const char * libName, const char * viewName, const char * defFileName, bool ecoMode=0, bool compressed=0, bool reportMissingPins=1, bool importSpecial=1, bool importRegular=1, bool reportUnplacedComps=0)

Import a DEF file defFileName into the library libName, which must exist. The cellName is determined from the DEF DESIGN keyword and the view name from viewName. If ecoMode is true then the COMPONENTS and PINS sections only are read, and existing components and pins will have their origin and orientation updated from the DEF file. If compressed is true a gzip compressed format file is expected and will be uncompressed during DEF in. Id reportMissingPins is true, missing net connections to pins will be reported. If importSpecial is true then the SPECIALNETS section is imported; if importRegular is true then the NETS section is imported. If reportUnplacedComps is true then any components with a placement status of UNPLACED will be reported.

 

bool ok = ui.exportDef (const char * libName, const char * cellName, const char * viewName, const char * defFileName, bool comps=1, bool pins=1, bool regular=1, bool special=1, bool regularRouting=1, bool specialRouting=1)

Export a DEF file defFileName from the library libName, cell cellName and view viewName. if comps is true the COMPONENTS section will be output; if pins is true the PINS section will be output; if regular is true the NETS section will be output; if special is true the SPECIALNETS section will be output. If regularRouting is true then routing from the NETS section is output, else just the connectivity. If specialRouting is true then routing from the SPECIALNETS section is output, else just the connectivity.

 

bool ok = ui.importVerilog (const char * libName, const char * verilogFileName, const char * powerNet, const char * groundNet, const char * flatViewName, bool flatten, const char * topCellName, int hPinLayer, int vPinLayer, double aspect, double utilisation)

Import a Verilog file verilogFileName into library libName. Cells with names matching the verilog module names are created with a view type of netlist. powerNet and groundNet specify the supply and ground nets used to resolve 1'b1 and 1'b0 references respectively. If flatten is true the Verilog netlist will be flattened into view flatViewName; topCellName is used as the top cell of the design to flatten. hPinLayer and vPinLayer are the layer numbers that are used for pins created in the flattened view. aspect is the aspect ratio of the resulting boundary layer created in the flattened view and utilisation sets the area out the boundary layer such that the total cell area divided by the boundary area equals the utilisation.

 

bool ok = ui.exportVerilog (const char * libName, const char * cellName, const char * viewName, const char * verilogFileName)

Export a Verilog file verilogFileName from library libName, cell name cellName, and view name viewName. Currently only a flat verilog netlist is output.

 

bool ok = ui.importECO (const char * ecoFileName)

Import an ECO file from file ecoFileName into the current open cellView.

 

bool ok = ui.importOasis (const char * libName, const char * oasisFileName, bool dubiousData=True, bool allowNonPrintingChars=False, bool reportCells=False, bool openTopCell=False, double scale=1.0, double xoffset=0.0, double yoffset=0.0, int csen=0, int duplicates=0, char *viewName="layout")

Import an OASIS file oasisFileName into the library libName. The library is created if it does not already exist. If dubiousData is true, dubious constructs in the Oasis data are reported. is allowNonPrintingChars is true, non-printing characters will be allowed to be read; normally Oasis only permits printable characters in a-string or n-string types. If reportCells is true, cells are reported in the message window as they are read. If openTopCell is true, all potential top cell candidates are opened in the gui. A top cell candidate is any cell that is not referenced by another cell, and is not empty. scale allows scaling of all input data by the factor specified. xoffset will add the specified offset to all x coordinate data, yoffset will add the specified offset to all y coordinate data. csen controls case sensitivity, 0 means preserve case, 1 converts to uppercase, 2 to lowercase. duplicates controls handling of duplicate cell definitions. If 0, duplicate cells replace any existing cell definitions. If 1, duplicate cells definitions are ignored. If 2, duplicate cell data is merged into existing cells. viewName sets the view name of cellViews created during import. viewName sets the view name of imported cellviews.

 

bool ok = ui.exportOasis (const char * libName, const char * viewNames, const char * oasisFileName, bool outputAllCells = True, bool outputChildCells = True, const char * topCellName = NULL, bool strict = False, bool cblock = False, bool cellOfsets = False, bool reportCells = False, double grid=0.005)

Export an OASIS file oasisFileName from library libName. All views specified in the space or comma delimited list viewNames are output. If outputAllCells is true then all cells in the library are output to the GDS2 file and topCellName is ignored. If outputAllCells is false then topCellName is a space or comma delimited list of cells to output. If strict is true, the OASIS file is written in STRICT mode. If cblock is true, CBLOCK compression is used which can substantially reduce the output file size. If cellOfsetts is checked in STRICT mode, the property S_CELL_OFFSET is written for each cell in the cellname table so that random access to cells are possible allowing e.g. multithreaded reading of the OASIS file. If reportCells is checked, cells are reported in the message window as they are written.

 

bool ok = ui.importDxf (const char * libName, const char * cellName, const char * dxfFileName, int dbu=1000)

Import a DXF file dxfFileName into the library libName. The library is created if it does not already exist. The DXF file is imported into a cell with name cellName and viewname layout.

 

bool ok = ui.exportDxf (const char * libName, const char * cellName, const char * dxfFileName, bool outputText=1, bool allLayers=1)

Export a DXF file dxfFileName from the library libName, cell cellName and view name layout. If outputText is true then text labels are output. If allLayers is true then all layers are output to the DXF file, else only the currently visible layers are output.

 

bool ok = ui.importCDL (const char * libName, const char * cdlFileName)

Import a CDL file cdlFileName into the library libName.

 

bool ok = ui.exportCDL (const char * libName, const char *cellname, const char *viewName, const char * cdlFileName, const char *globals, bool annotateXY=0, bool microns= 0, bool rmodel=0, char * rpropname="r", bool cmodel=0, char *cpropname= "c", double filterCapLimit=-1.0, bool mergeCaps= 0)

Export a flat CDL file cdlFileName from the library libName with cell cellname, view viewName. globals is a space delimited list of global net names e.g. VDD and VSS. If annotateXY is true, XY coordinates of instances are written in the CDL file as $X= / $Y= values. If rmodel is true (1) then the resistor model name is reported, else the resistor value (R=...) is reported. rpropname is the property that is used to report the resistor value and should be a property of the resistor extraction pcell. cmodel and cpropname act similarly for capacitors (but not for parasitic capacitors which are always reported by value). If a positive filterCapLimit is specified, any parasitic capacitances below this limit (in Farads) will not be written in the CDL file. If mergeCaps is true (1) then parasitic caps between net pairs are lumped all togther and reported only once per net pair.

 

ui.schHNLOut (char *libName, char *cellName, char *viewName, char *cdlFileName, char *switchList, char *stopList, char *globals)

Export a hierarchical CDL file cdlFileName from the library libName with cell cellName and view viewName. switchList is a space delimited list of view names the netlister can switch into e.g. "schematic symbol". stopList is a space delimited list of views the netlist can stop on, which should have a NLPDeviceFormat string property to describe the netlist format for the cellView. globals is a space delimited list of global net names.

 

ui.zoomIn ()

Zoom in according to the current zoomin factor.


ui.zoomIn (int x1, int y1, int x2, int y2)

Zoom in to the area given by x1 y1 x2 y2.


ui.zoomOut ()

Zoom out according to the current zoomout factor.


ui.zoomOut (int x1, int y1, int x2, int y2)

Zoom out by the area given by x1 y1 x2 y2.

 

ui.selectArea (int x1, int y1, int x2, int y2, bool add = 0)

Select objects in the area given by x1 y1 x2 y2. If add is true, then the objects are added to the selected set.


ui.deselectArea (int x1, int y1, int x2, int y2)

Deselect objects in the area given by x1 y1 x2 y2.


ui.selectPoint (int x1, int y1, bool add = 0)

Select an object at the coordinate x1 y1. If add is true, then the object is added to the selected set.


ui.deselectPoint (int x1, int y1)

Deselect an object at the coordinate x1 y1.


ui.execPythonFile (const char *fileName)

Execute the python script given by fileName.

 

ui.deleteCell(const char *libName, const char *cellName, const char *viewName)

Delete the cell specified by libName, cellName and viewName .


ui.renameCell(const char *libName, const char *cellName, const char *viewName)

Rename the cell specified by libName, cellName and viewName . A dialog will be displayed prompting for the new cell name.


ui.copyCell(const char *libName, const char *cellName, const char *viewName)

Copy the cell specified by libName, cellName and viewName . A dialog will be displayed prompting for the new cell name.


ui.properties(const char *libName, const char *cellName, const char *viewName)

Display the properties of the cell specified by libName, cellName and viewName .

 

ui.biasCells(cellView *cv, int layer, int biasFactor, int grid, int allCells)

Bias cell(s). cv is the cellView of the cell to bias, or any cell in the library. layer is the layer to bias, and biasFactor is the amount to bias the layer in database units. A positive biasFactor will grow the shapes, a negative biasFactor will shrink the shapes. grid is the snap grid to snap resulting shapes to. If allCells is true (1), then all cellViews in the library containing cv will be biassed.

 

ui.scaleCells(cellView *cv, db_Float64 scaleFactor, db_Int32 grid, bool allCells)

Scale cell(s). cv is the cellView of the cell to bias, or any cell in the library. scaleFactor is the scale factor to apply to the cell(s). grid is the snap grid to snap resulting shapes to. If allCells is true (1), then all cellViews in the library containing cv will be scaled.

 

ui.compareCells(char *libName1, char *cellName1, char *viewName1, char *libName2, char *cellName2, char *viewName2, int compareLayer, bool hier, bool countShapes)

Compares two cellViews using an XOR operation using a simple non-tiled approach. This is good for small-ish cells or less than a few thousand transistors/shapes. The comparison is done for compareLayer; if this is set to -1 all layers in the cellViews are compared, else just the layer specified. If hier is false(0, the default), then the comparison is done at the top level only; if true (1) then it is done hierarchically. The function returns 0 if the two cellViews are identical, -1 if an error occurred e.g. different number of layers in the cells, or different number of shapes (but see countShapes), or the number of differences found. If countShapes is false (0, the default) then the number of shapes may differ between the cells, but the XOR result must match.

 

int val = ui.compareCells2 (char *libName1, char *cellName1, char *viewName1, char *libName2, char *cellName2, char *viewName2, int compareLayer, bool hier, bool multiThreaded=1, int maxThreads=QThread::idealThreadCount(), bool tileAuto=1, int  tileWidth=1, int tileHeight=1, int outputLayer=TECH_DRCMARKER_LAYER)

Compares two cellViews using a tiled XOR operation. The comparison is done for compareLayer; if this is set to -1 all layers in the cellViews are compared. If hier is true (1), then the comparison is done hierarchically. The function returns 0 if the two cellViews are identical, -1 if an error occurred, or the number of differences found. If multiThreaded is true (the default), then the layout is tiled and run with maxThreads threads. If tileAuto is true (the default), an intelligent tiling algorithm is used, else tile widths and heights must be specified.

 

bool val = ui.runLVS(char *libName, char *cellName, char *viewName, char *netlist, char *globalNets= NULL, char *workDir= ".", bool isHierNetList= false, const char *delimiter= "/", const char *topCellName=NULL, bool checkDeviceProps=false, bool collapseLikeSized= false, bool noCollapseFingered= false,bool noCollapseChains= false, bool warnChains= false, bool caseFoldNets= false,bool noLocalMatching= false, bool noOptLabelling= false, bool matchProperties=false, bool matchPorts=false, bool warnZeroNets= false, bool verbose= false,const char *errorLimit= NULL, const char *netSizeLimit= NULL,const char *progressLimit= NULL, const char *suspectNodeLimit= NULL,db_Float64 tranTolerance=10.0, db_Float64 capTolerance= 10.0 ,const char *equivInFileName= NULL, const char *equivOutFileName= NULL)

Runs LVS, comparing the cellview given by libName/cellName/viewName, which should be an extracted cellView, against the Spice/CDL netlist given by netlist. globalNets is a space delimited list of global net names. workDir is used for the creation of temporary files. If isHierNetList is true, then the netlist is treated as hierarchical and will be flattened with delimiter character delimiter and top cell name topCellName. If checkDeviceProps is true, device properties e.g. W, L or MOS devices are checked according to the tolerance specified by tranTolerance and capTolerance.

The remainder of the parameters correspond to Gemini options.

 

ui.updateLibBrowser()

Updates (refreshes)  the library browser.

 

ui.updateLSW()

Updates (refreshes) the LSW.

 

bool ok = ui.isLayerVisible(const char *layerName, const char *purpose)

Returns True if the layer specified by layerName and purpose is visible in the current cellView or False if it is invisible, or there is no current cellView.

 

bool ok = ui.isLayerSelectable(const char *layerName, const char *purpose)

Returns True if the layer specified by layerName and purpose is selectablein the current cellView or False if it is invisible, or there is no current cellView.

 

bool ok = ui.setLayerVisible(const char *layerName, const char *purpose, bool val)

Returns True if the layer specified by layerName and purpose can be set visible in the current cellView or False if there is no current cellView.

 

bool ok = ui.setLayerSelectable(const char *layerName, const char *purpose, bool val)

Returns True if the layer specified by layerName and purpose can be set visible in the current cellView or False if there is no current cellView.

 

Extending Glade by creating menus / bindkeys etc.

cvar.uiptr

A global pointer to the ui class instanciation in Glade. Use this rather than creating your own ui variable using ui(). For example:

gui=cvar.uiptr

gui.OpenCellView("default", "nand", "layout")

Although you can use e.g. ui().<functionName()>, this will not work for commands like createAction() which only work with the existing instanciated ui object.

 

menu = ui.createMenu(const char *name)

Creates a menu called name in the menu bar.

 

menu = ui.createMenu(QMenu *menu, const char *name)

Creates a submenu called name in menu.

 

ui.addSeparator(QMenu *menu)

Adds a separator to the menu.

 

action = ui.createAction(const char *name, const char *cmd)

Creates an action called name with a command cmd. The command should be a valid Python command. An action defines a common command that can be invoked by any or all of a menu item, a bindkey or a toolbar button.

 

action = ui.createAction(const char *name, const char *cmd, QActionGroup *group)

Creates an action called name with a command cmd that is part of an actionGroup group. The command should be a valid Python command. An action defines a common command that can be invoked by any or all of a menu item, a bindkey or a toolbar button.

 

actionGroup = ui.createActionGroup()

Create an actionGroup.

 

ui.createMenuItem(menu, action)

Adds the action to the menu. The action name will be shown on the menu, along with any key binding defined for the action.

 

setBindKey(action, const char *keysequence)

Sets the bindkey for action. keysequence can be a key e.g. "k" or a combination e.g. "Ctrl+p", "Shift+p", "Alt+p"

 

icon = ui.createIcon (const char *fileName)

Creates an icon from an image file (.png format)

 

ui.setIcon (QAction *action, const char *fileName)

Sets the icon for an action from the image file (.png format)

 

ui.setIcon (QAction *action, QIcon *icon)

Sets the icon for an action

 

toolbar = ui.createToolBar (const char *name)

Creates a tool bar with name name.

 

ui.createToolBarItem (QToolBar *toolBar, QAction *action)

Adds an action to a toolbar.

 

ui.addSeparator (QToolBar *toolBar)

Adds a seperator to a toolbar.

 

An example of a python script for setting up a user-defined menu is as follows:

# define some user function

def myFunction() :

print "Hello World!"

gui = cvar.uiptr

menu = gui.createMenu("MyMenu")

action=gui.createAction("MyAction", "myFunction()")

gui.createMenuItem(menu, action)

gui.setBindKey(action, "!")

 

Contents|Index

Copyright © Peardrop Design 2016.