diff --git a/compiler/globals.py b/compiler/globals.py index c1422592..a3e98b56 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -187,11 +187,12 @@ def setup_bitcell(): # See if a custom bitcell exists from importlib import find_loader - bitcell_loader = find_loader(OPTS.bitcell) - replica_bitcell_loader = find_loader(OPTS.replica_bitcell) - # Use the pbitcell if we couldn't find a custom bitcell - # or its custom replica bitcell - if bitcell_loader==None or replica_bitcell_loader==None: + try: + __import__(OPTS.bitcell) + __import__(OPTS.replica_bitcell) + except ImportError: + # Use the pbitcell if we couldn't find a custom bitcell + # or its custom replica bitcell # Use the pbitcell (and give a warning if not in unit test mode) OPTS.bitcell = "pbitcell" OPTS.replica_bitcell = "replica_pbitcell" @@ -403,27 +404,30 @@ def import_tech(): try: OPENRAM_TECH = os.path.abspath(os.environ.get("OPENRAM_TECH")) except: - debug.error("$OPENRAM_TECH is not properly defined.",1) - debug.check(os.path.isdir(OPENRAM_TECH),"$OPENRAM_TECH does not exist: {0}".format(OPENRAM_TECH)) - - OPTS.openram_tech = OPENRAM_TECH + "/" + OPTS.tech_name - if not OPTS.openram_tech.endswith('/'): - OPTS.openram_tech += "/" - debug.info(1, "Technology path is " + OPTS.openram_tech) + debug.error("$OPENRAM_TECH environment variable is not defined.",1) + # Add all of the paths + for tech_path in OPENRAM_TECH.split(":"): + debug.check(os.path.isdir(tech_path),"$OPENRAM_TECH does not exist: {0}".format(tech_path)) + sys.path.append(tech_path) + debug.info(1, "Adding technology path: {}".format(tech_path)) + + # Import the tech try: - filename = "setup_openram_{0}".format(OPTS.tech_name) - # we assume that the setup scripts (and tech dirs) are located at the - # same level as the compielr itself, probably not a good idea though. - path = "{0}/setup_scripts".format(os.environ.get("OPENRAM_TECH")) - debug.check(os.path.isdir(path),"OPENRAM_TECH does not exist: {0}".format(path)) - sys.path.append(os.path.abspath(path)) - __import__(filename) + tech_mod = __import__(OPTS.tech_name) except ImportError: - debug.error("Nonexistent technology_setup_file: {0}.py".format(filename)) - sys.exit(1) + debug.error("Nonexistent technology_setup_file: {0}.py".format(filename), -1) - import tech + OPTS.openram_tech = os.path.dirname(tech_mod.__file__) + "/" + + + # Add the tech directory + tech_path = OPTS.openram_tech + sys.path.append(tech_path) + try: + import tech + except ImportError: + debug.error("Could not load tech module.", -1) # Set some default options now based on the technology... if (OPTS.process_corners == ""): OPTS.process_corners = tech.spice["fet_models"].keys() diff --git a/technology/setup_scripts/setup_openram_freepdk45.py b/technology/freepdk45/__init__.py similarity index 83% rename from technology/setup_scripts/setup_openram_freepdk45.py rename to technology/freepdk45/__init__.py index 3ba0aa16..f7f801ea 100644 --- a/technology/setup_scripts/setup_openram_freepdk45.py +++ b/technology/freepdk45/__init__.py @@ -8,7 +8,6 @@ import sys import os TECHNOLOGY = "freepdk45" -LOCAL = "{0}/..".format(os.path.dirname(__file__)) ########################## # FreePDK45 paths @@ -33,8 +32,3 @@ os.environ["DRCLVS_HOME"] = DRCLVS_HOME # except: # Always use the one in the PDK dir for FreePDK45 os.environ["SPICE_MODEL_DIR"] = PDK_DIR+"/ncsu_basekit/models/hspice/tran_models" - -########################## -#Paths required for OPENRAM to function - -sys.path.append("{0}/{1}/tech".format(LOCAL,TECHNOLOGY)) diff --git a/technology/freepdk45/tech/__init__.py b/technology/freepdk45/tech/__init__.py index 6b2d03b3..2573d2c2 100644 --- a/technology/freepdk45/tech/__init__.py +++ b/technology/freepdk45/tech/__init__.py @@ -2,5 +2,5 @@ Import tech specific modules. """ -from tech import * +from .tech import * diff --git a/technology/setup_scripts/setup_openram_scn3me_subm.py b/technology/scn3me_subm/__init__.py similarity index 83% rename from technology/setup_scripts/setup_openram_scn3me_subm.py rename to technology/scn3me_subm/__init__.py index 1508b2a8..9542c26a 100644 --- a/technology/setup_scripts/setup_openram_scn3me_subm.py +++ b/technology/scn3me_subm/__init__.py @@ -34,8 +34,3 @@ os.environ["DRCLVS_HOME"] = DRCLVS_HOME OPENRAM_TECH=os.path.abspath(os.environ.get("OPENRAM_TECH")) os.environ["SPICE_MODEL_DIR"] = "{0}/{1}/models".format(OPENRAM_TECH, TECHNOLOGY) -########################## -# Paths required for OPENRAM to function - -LOCAL = "{0}/..".format(os.path.dirname(__file__)) -sys.path.append("{0}/{1}/tech".format(LOCAL,TECHNOLOGY)) diff --git a/technology/scn3me_subm/tech/__init__.py b/technology/scn3me_subm/tech/__init__.py index 6b2d03b3..2573d2c2 100755 --- a/technology/scn3me_subm/tech/__init__.py +++ b/technology/scn3me_subm/tech/__init__.py @@ -2,5 +2,5 @@ Import tech specific modules. """ -from tech import * +from .tech import * diff --git a/technology/setup_scripts/setup_openram_scn4m_subm.py b/technology/scn4m_subm/__init__.py similarity index 83% rename from technology/setup_scripts/setup_openram_scn4m_subm.py rename to technology/scn4m_subm/__init__.py index 19a4960c..d8474497 100644 --- a/technology/setup_scripts/setup_openram_scn4m_subm.py +++ b/technology/scn4m_subm/__init__.py @@ -34,8 +34,3 @@ os.environ["DRCLVS_HOME"] = DRCLVS_HOME OPENRAM_TECH=os.path.abspath(os.environ.get("OPENRAM_TECH")) os.environ["SPICE_MODEL_DIR"] = "{0}/{1}/models".format(OPENRAM_TECH, TECHNOLOGY) -########################## -# Paths required for OPENRAM to function - -LOCAL = "{0}/..".format(os.path.dirname(__file__)) -sys.path.append("{0}/{1}/tech".format(LOCAL,TECHNOLOGY)) diff --git a/technology/scn4m_subm/tech/__init__.py b/technology/scn4m_subm/tech/__init__.py index 6b2d03b3..2573d2c2 100755 --- a/technology/scn4m_subm/tech/__init__.py +++ b/technology/scn4m_subm/tech/__init__.py @@ -2,5 +2,5 @@ Import tech specific modules. """ -from tech import * +from .tech import * diff --git a/technology/setup_scripts/README b/technology/setup_scripts/README deleted file mode 100644 index 628cec7e..00000000 --- a/technology/setup_scripts/README +++ /dev/null @@ -1,4 +0,0 @@ -THIS DIRECTORY SHOULD ONLY CONTAIN SETUP SCRIPTS FOR TECHNOLOGIES. - -These scripts will be called automatically by the import_tech functions in -globals.py in the compiler directory.