Simplify tech organization and import

This commit is contained in:
Matt Guthaus 2019-03-06 07:41:38 -08:00
parent 80a325fe32
commit d178801882
8 changed files with 29 additions and 45 deletions

View File

@ -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()

View File

@ -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))

View File

@ -2,5 +2,5 @@
Import tech specific modules.
"""
from tech import *
from .tech import *

View File

@ -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))

View File

@ -2,5 +2,5 @@
Import tech specific modules.
"""
from tech import *
from .tech import *

View File

@ -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))

View File

@ -2,5 +2,5 @@
Import tech specific modules.
"""
from tech import *
from .tech import *

View File

@ -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.