Automatically loading a techfile at startup

Here’s a handy way of loading a techfile (or in fact running any python script) on startup.

Glade reads a .glade.py file, if it exists in the user’s home directory, when it starts. On WIndows, the env var HOME defines the user home dir. So you can load a techfile e.g.

# .glade.py - load a techfile on startup
#
# get the ptr to the ui class
ui = cvar.uiptr
#
# import the techfile
ui.importTech('myLib', 'myTechfile.tch')

Or if you want to load several libraries at startup:

# .glade.py - load libraries on startup
#
# get the ptr to the ui class
ui=cvar.uiptr
#
mylibs = ['XyceLib', 'example']
nlib = len(mylibs)
libinit = [0 for i in range(nlib)]
for n in range(nlib):
libinit[n] = library(mylibs[n])
libinit[n].dbOpenLib('./'+mylibs[n])

Note that the .glade.py script is executed before any command line args are processed, so you can e.g. load a techfile and then in your command line specify a GDS file to be read.

In the above, you may be wondering why you can’t do:

mylibs = ['XyceLib', 'example']
for libname in mylibs :
lib = library(libname)
lib.dbOpenLib('./'+libname)

If you try it, you will get a crash. Why? Because python sees ‘lib’ go out of scope at the end of the for loop, and so deletes the library pointer to ‘XyceLib’. In theory this can be avoided by careful use of reference counting, but this hasn’t been implemented (yet).

Leave a Reply