Fix option reload problems and checkpointing so that it works properly.

This commit is contained in:
Matt Guthaus 2018-07-11 12:00:15 -07:00
parent 58646ab8e6
commit 265b5d977a
8 changed files with 30 additions and 16 deletions

View File

@ -1,16 +1,18 @@
import os import os
import debug import debug
import globals
from globals import OPTS,find_exe,get_tool from globals import OPTS,find_exe,get_tool
from .lib import * from .lib import *
from .delay import * from .delay import *
from .setup_hold import * from .setup_hold import *
debug.info(2,"Initializing characterizer...") debug.info(1,"Initializing characterizer...")
OPTS.spice_exe = "" OPTS.spice_exe = ""
if not OPTS.analytical_delay: if not OPTS.analytical_delay:
debug.info(1, "Finding spice simulator.")
if OPTS.spice_name != "": if OPTS.spice_name != "":
OPTS.spice_exe=find_exe(OPTS.spice_name) OPTS.spice_exe=find_exe(OPTS.spice_name)
if OPTS.spice_exe=="": if OPTS.spice_exe=="":
@ -24,6 +26,7 @@ if not OPTS.analytical_delay:
if OPTS.spice_exe == "": if OPTS.spice_exe == "":
debug.error("No recognizable spice version found. Unable to perform characterization.",1) debug.error("No recognizable spice version found. Unable to perform characterization.",1)
else:
debug.info(1,"Analytical model enabled.")

View File

@ -155,7 +155,7 @@ def read_config(config_file, is_unit_test=True):
# If a unit test fails, we don't have to worry about restoring the old config values # If a unit test fails, we don't have to worry about restoring the old config values
# that may have been tested. # that may have been tested.
if is_unit_test and CHECKPOINT_OPTS: if is_unit_test and CHECKPOINT_OPTS:
OPTS = copy.deepcopy(CHECKPOINT_OPTS) OPTS.__dict__ = CHECKPOINT_OPTS.__dict__.copy()
return return
# Create a full path relative to current dir unless it is already an abs path # Create a full path relative to current dir unless it is already an abs path
@ -213,13 +213,18 @@ def read_config(config_file, is_unit_test=True):
# Make a checkpoint of the options so we can restore # Make a checkpoint of the options so we can restore
# after each unit test # after each unit test
CHECKPOINT_OPTS = copy.deepcopy(OPTS) if not CHECKPOINT_OPTS:
CHECKPOINT_OPTS = copy.copy(OPTS)
def end_openram(): def end_openram():
""" Clean up openram for a proper exit """ """ Clean up openram for a proper exit """
cleanup_paths() cleanup_paths()
import verify
verify.print_drc_stats()
verify.print_lvs_stats()
verify.print_pex_stats()
@ -227,6 +232,7 @@ def cleanup_paths():
""" """
We should clean up the temp directory after execution. We should clean up the temp directory after execution.
""" """
global OPTS
if not OPTS.purge_temp: if not OPTS.purge_temp:
debug.info(0,"Preserving temp directory: {}".format(OPTS.openram_temp)) debug.info(0,"Preserving temp directory: {}".format(OPTS.openram_temp))
return return
@ -341,6 +347,8 @@ def print_time(name, now_time, last_time=None):
def report_status(): def report_status():
""" Check for valid arguments and report the info about the SRAM being generated """ """ Check for valid arguments and report the info about the SRAM being generated """
global OPTS
# Check if all arguments are integers for bits, size, banks # Check if all arguments are integers for bits, size, banks
if type(OPTS.word_size)!=int: if type(OPTS.word_size)!=int:
debug.error("{0} is not an integer in config file.".format(OPTS.word_size)) debug.error("{0} is not an integer in config file.".format(OPTS.word_size))

View File

@ -14,7 +14,7 @@ class library_lvs_test(openram_test):
def runTest(self): def runTest(self):
globals.init_openram("config_20_{0}".format(OPTS.tech_name)) globals.init_openram("config_20_{0}".format(OPTS.tech_name))
import verify import verify
OPTS.check_lvsdrc=True
(gds_dir, sp_dir, allnames) = setup_files() (gds_dir, sp_dir, allnames) = setup_files()
lvs_errors = 0 lvs_errors = 0
debug.info(1, "Performing LVS on: " + ", ".join(allnames)) debug.info(1, "Performing LVS on: " + ", ".join(allnames))

View File

@ -18,6 +18,7 @@ class timing_sram_test(openram_test):
OPTS.spice_name="hspice" OPTS.spice_name="hspice"
OPTS.analytical_delay = False OPTS.analytical_delay = False
# This is a hack to reload the characterizer __init__ with the spice version # This is a hack to reload the characterizer __init__ with the spice version
from importlib import reload from importlib import reload
import characterizer import characterizer
@ -83,7 +84,6 @@ class timing_sram_test(openram_test):
else: else:
self.isclose(data[k],golden_data[k],0.15) self.isclose(data[k],golden_data[k],0.15)
reload(characterizer)
globals.end_openram() globals.end_openram()
# instantiate a copdsay of the class to actually run the test # instantiate a copdsay of the class to actually run the test

View File

@ -26,7 +26,6 @@ class timing_setup_test(openram_test):
if not OPTS.spice_exe: if not OPTS.spice_exe:
debug.error("Could not find {} simulator.".format(OPTS.spice_name),-1) debug.error("Could not find {} simulator.".format(OPTS.spice_name),-1)
import sram import sram
import tech import tech
slews = [tech.spice["rise_time"]*2] slews = [tech.spice["rise_time"]*2]
@ -58,7 +57,6 @@ class timing_setup_test(openram_test):
else: else:
self.isclose(data[k],golden_data[k],0.15) self.isclose(data[k],golden_data[k],0.15)
reload(characterizer)
globals.end_openram() globals.end_openram()
# instantiate a copdsay of the class to actually run the test # instantiate a copdsay of the class to actually run the test

View File

@ -83,7 +83,6 @@ class timing_sram_test(openram_test):
else: else:
self.isclose(data[k],golden_data[k],0.15) self.isclose(data[k],golden_data[k],0.15)
reload(characterizer)
globals.end_openram() globals.end_openram()
# instantiate a copdsay of the class to actually run the test # instantiate a copdsay of the class to actually run the test

View File

@ -16,6 +16,17 @@ class sram_func_test(openram_test):
def runTest(self): def runTest(self):
globals.init_openram("config_20_{0}".format(OPTS.tech_name)) globals.init_openram("config_20_{0}".format(OPTS.tech_name))
OPTS.use_pex = True
# This is a hack to reload the characterizer __init__ with the spice version
from importlib import reload
import characterizer
reload(characterizer)
from characterizer import setup_hold
if not OPTS.spice_exe:
debug.error("Could not find {} simulator.".format(OPTS.spice_name),-1)
global verify global verify
import verify import verify
@ -31,8 +42,6 @@ class sram_func_test(openram_test):
import tech import tech
debug.info(1, "Testing timing for sample 1bit, 16words SRAM with 1 bank") debug.info(1, "Testing timing for sample 1bit, 16words SRAM with 1 bank")
global OPTS
OPTS.use_pex = True
s = sram.sram(word_size=OPTS.word_size, s = sram.sram(word_size=OPTS.word_size,
num_words=OPTS.num_words, num_words=OPTS.num_words,
num_banks=OPTS.num_banks, num_banks=OPTS.num_banks,

View File

@ -73,10 +73,7 @@ class openram_test(openram_test):
shutil.rmtree(out_path, ignore_errors=True) shutil.rmtree(out_path, ignore_errors=True)
self.assertEqual(os.path.exists(out_path),False) self.assertEqual(os.path.exists(out_path),False)
# The default was on, so disable it.
OPTS.check_lvsdrc=False
globals.end_openram() globals.end_openram()
OPTS.check_lvsdrc=True
# instantiate a copy of the class to actually run the test # instantiate a copy of the class to actually run the test
if __name__ == "__main__": if __name__ == "__main__":