From e4041d5e26d2927b181dda6031baefbdd27b4cd0 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Tue, 14 Jul 2020 19:49:54 +0200 Subject: [PATCH] Improved Hurricane/Python database reset. * Change: In CRL/helpers/__init__.py, to ensure a complete restart of the database the __init__.py must be called again, but it's not the case with reload() (see Python doc). So helpers.resetCoriolis() must explicitly removes the Coriolis related Python modules from sys.modules (calling "del sys.modules[moduleName]"). That list of Coriolis Python modules is built by calling helpers.tagConfModules(), it will tag all modules added to sys.modules since startup. It will remove (much) more than Coriolis modules, but that should be ok. * Change: In CRL/etc/{node*,symbolic}/TECH/__init__.py, add a call to helpers.tagConfModules() for the techno modules to be erased on reset. --- crlcore/etc/node180/scn6m_deep_09/__init__.py | 2 + crlcore/etc/node45/freepdk45/__init__.py | 2 + crlcore/etc/node600/phenitec/__init__.py | 2 + crlcore/etc/symbolic/cmos/__init__.py | 3 ++ crlcore/etc/symbolic/cmos/plugins.py | 1 + crlcore/etc/symbolic/cmos45/__init__.py | 2 + crlcore/python/helpers/__init__.py | 45 ++++++++++++------- 7 files changed, 40 insertions(+), 17 deletions(-) diff --git a/crlcore/etc/node180/scn6m_deep_09/__init__.py b/crlcore/etc/node180/scn6m_deep_09/__init__.py index 3e87f4a0..8f89f0ad 100644 --- a/crlcore/etc/node180/scn6m_deep_09/__init__.py +++ b/crlcore/etc/node180/scn6m_deep_09/__init__.py @@ -39,3 +39,5 @@ import node180.scn6m_deep_09.devices import node180.scn6m_deep_09.dtr_scn6m_deep_09 Cfg.Configuration.popDefaultPriority() + +helpers.tagConfModules() diff --git a/crlcore/etc/node45/freepdk45/__init__.py b/crlcore/etc/node45/freepdk45/__init__.py index c245b98c..d02344fa 100644 --- a/crlcore/etc/node45/freepdk45/__init__.py +++ b/crlcore/etc/node45/freepdk45/__init__.py @@ -38,3 +38,5 @@ import node45.freepdk45.stratus1 import node45.freepdk45.devices Cfg.Configuration.popDefaultPriority() + +helpers.tagConfModules() diff --git a/crlcore/etc/node600/phenitec/__init__.py b/crlcore/etc/node600/phenitec/__init__.py index 5ba0b2db..de569860 100644 --- a/crlcore/etc/node600/phenitec/__init__.py +++ b/crlcore/etc/node600/phenitec/__init__.py @@ -38,3 +38,5 @@ import node600.phenitec.stratus1 import node600.phenitec.devices Cfg.Configuration.popDefaultPriority() + +helpers.tagConfModules() diff --git a/crlcore/etc/symbolic/cmos/__init__.py b/crlcore/etc/symbolic/cmos/__init__.py index 0a07e2a8..4cb5139a 100644 --- a/crlcore/etc/symbolic/cmos/__init__.py +++ b/crlcore/etc/symbolic/cmos/__init__.py @@ -14,6 +14,7 @@ import Cfg +import helpers import helpers.io helpers.io.vprint( 1, ' o Loading "symbolic.cmos" technology.' ) helpers.io.vprint( 2, ' - "%s".' % helpers.truncPath(__file__) ) @@ -37,3 +38,5 @@ import symbolic.cmos.plugins import symbolic.cmos.stratus1 Cfg.Configuration.popDefaultPriority() + +helpers.tagConfModules() diff --git a/crlcore/etc/symbolic/cmos/plugins.py b/crlcore/etc/symbolic/cmos/plugins.py index 7dc461b9..c0c8b359 100644 --- a/crlcore/etc/symbolic/cmos/plugins.py +++ b/crlcore/etc/symbolic/cmos/plugins.py @@ -27,3 +27,4 @@ Cfg.getParamInt ( "chip.block.rails.vSpacing" ).setInt ( l( 6) ) Cfg.getParamInt ( 'clockTree.minimumSide' ).setInt ( l(600) ) Cfg.getParamString( 'clockTree.buffer' ).setString( 'buf_x2') Cfg.getParamString( 'clockTree.placerEngine' ).setString( 'Etesian') +Cfg.getParamInt ( 'block.spareSide' ).setInt ( 10 ) diff --git a/crlcore/etc/symbolic/cmos45/__init__.py b/crlcore/etc/symbolic/cmos45/__init__.py index 111afeec..7d038c3d 100644 --- a/crlcore/etc/symbolic/cmos45/__init__.py +++ b/crlcore/etc/symbolic/cmos45/__init__.py @@ -37,3 +37,5 @@ import symbolic.cmos45.plugins import symbolic.cmos45.stratus1 Cfg.Configuration.popDefaultPriority() + +helpers.tagConfModules() diff --git a/crlcore/python/helpers/__init__.py b/crlcore/python/helpers/__init__.py index 2f74af65..cdddc6b3 100644 --- a/crlcore/python/helpers/__init__.py +++ b/crlcore/python/helpers/__init__.py @@ -10,23 +10,20 @@ # | Author : Jean-Paul Chaput | # | E-mail : Jean-Paul.Chaput@lip6.fr | # | =============================================================== | -# | Python : "./crlcore/__init__.py" | +# | Python : "./crlcore/helpers/__init__.py" | # +-----------------------------------------------------------------+ # # This is file is mandatory to tell python that 'helpers' is a module # rather than an ordinary directory, thus enabling the uses of the # 'dot' notation in import. +#print 'helpers.__init__()' import sys import os import os.path import re import traceback -import Hurricane -import Viewer -import CRL -import helpers.io quiet = False sysConfDir = None @@ -35,7 +32,17 @@ ndaDir = None techno = 'symbolic/cmos' technoDir = None moduleGlobals = globals() -confModules = [ ] +sysModules = set() +confModules = set() + +if not sysModules: + for moduleName in sys.modules.keys(): + sysModules.add( moduleName ) + +import Hurricane +import Viewer +import CRL +import helpers.io def stype ( o ): return str(type(o)).split("'")[1] @@ -348,10 +355,10 @@ def setSysConfDir ( quiet=False ): if sysConfDir != None: #if not quiet: print ' o helpers.staticInitialization() Already run, exit.' return - + reSysConfDir = re.compile(r'.*etc\/coriolis2') if not quiet: print ' o Locating configuration directory:' - + for path in sys.path: if reSysConfDir.match(path): sysConfDir = path @@ -397,9 +404,10 @@ setSysConfDir( False ) def unloadUserSettings (): + global confModules + print ' o Unloading Python user\'s modules.' - global confModules for moduleName in confModules: refcount = sys.getrefcount( sys.modules[moduleName] ) warning = '' @@ -411,16 +419,12 @@ def unloadUserSettings (): # ] ) print ' - %-34s %-35s' % ('"%s".'%moduleName, warning) del sys.modules[ moduleName ] - confModules = [] + confModules = set() return def loadUserSettings (): - global confModules - rvalue = False - beforeModules = set() - for moduleName in sys.modules.keys(): beforeModules.add( moduleName ) if os.path.isfile('./coriolis2/settings.py'): if os.path.isfile('./coriolis2/__init__.py'): @@ -434,17 +438,24 @@ def loadUserSettings (): else: import symbolic.cmos + tagConfModules() + + return rvalue + + +def tagConfModules (): + global sysModules + global confModules + confModules = set() for moduleName in sys.modules.keys(): - if not (moduleName in beforeModules): + if not (moduleName in sysModules): confModules.add( moduleName ) #print 'Configuration modules:' #for moduleName in confModules: # print '-', moduleName - return rvalue - def resetCoriolis (): print ' o Full reset of Coriolis/Hurricane databases.'