From 265b5d977a0acd6ec8703f465e3c695944518776 Mon Sep 17 00:00:00 2001 From: Matt Guthaus Date: Wed, 11 Jul 2018 12:00:15 -0700 Subject: [PATCH] Fix option reload problems and checkpointing so that it works properly. --- compiler/characterizer/__init__.py | 9 ++++++--- compiler/globals.py | 14 +++++++++++--- compiler/tests/02_library_lvs_test.py | 2 +- compiler/tests/21_hspice_delay_test.py | 2 +- compiler/tests/21_hspice_setuphold_test.py | 2 -- compiler/tests/21_ngspice_delay_test.py | 1 - compiler/tests/22_pex_test.py | 13 +++++++++++-- compiler/tests/30_openram_test.py | 3 --- 8 files changed, 30 insertions(+), 16 deletions(-) diff --git a/compiler/characterizer/__init__.py b/compiler/characterizer/__init__.py index 6930a112..dc9398d0 100644 --- a/compiler/characterizer/__init__.py +++ b/compiler/characterizer/__init__.py @@ -1,16 +1,18 @@ import os import debug +import globals from globals import OPTS,find_exe,get_tool from .lib import * from .delay import * from .setup_hold import * -debug.info(2,"Initializing characterizer...") - +debug.info(1,"Initializing characterizer...") OPTS.spice_exe = "" if not OPTS.analytical_delay: + debug.info(1, "Finding spice simulator.") + if OPTS.spice_name != "": OPTS.spice_exe=find_exe(OPTS.spice_name) if OPTS.spice_exe=="": @@ -24,6 +26,7 @@ if not OPTS.analytical_delay: if OPTS.spice_exe == "": debug.error("No recognizable spice version found. Unable to perform characterization.",1) - +else: + debug.info(1,"Analytical model enabled.") diff --git a/compiler/globals.py b/compiler/globals.py index 8c305664..90f85f70 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -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 # that may have been tested. if is_unit_test and CHECKPOINT_OPTS: - OPTS = copy.deepcopy(CHECKPOINT_OPTS) + OPTS.__dict__ = CHECKPOINT_OPTS.__dict__.copy() return # Create a full path relative to current dir unless it is already an abs path @@ -213,12 +213,17 @@ def read_config(config_file, is_unit_test=True): # Make a checkpoint of the options so we can restore # after each unit test - CHECKPOINT_OPTS = copy.deepcopy(OPTS) - + if not CHECKPOINT_OPTS: + CHECKPOINT_OPTS = copy.copy(OPTS) def end_openram(): """ Clean up openram for a proper exit """ 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. """ + global OPTS if not OPTS.purge_temp: debug.info(0,"Preserving temp directory: {}".format(OPTS.openram_temp)) return @@ -341,6 +347,8 @@ def print_time(name, now_time, last_time=None): def report_status(): """ 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 if type(OPTS.word_size)!=int: debug.error("{0} is not an integer in config file.".format(OPTS.word_size)) diff --git a/compiler/tests/02_library_lvs_test.py b/compiler/tests/02_library_lvs_test.py index d85f284e..0b35f159 100755 --- a/compiler/tests/02_library_lvs_test.py +++ b/compiler/tests/02_library_lvs_test.py @@ -14,7 +14,7 @@ class library_lvs_test(openram_test): def runTest(self): globals.init_openram("config_20_{0}".format(OPTS.tech_name)) import verify - OPTS.check_lvsdrc=True + (gds_dir, sp_dir, allnames) = setup_files() lvs_errors = 0 debug.info(1, "Performing LVS on: " + ", ".join(allnames)) diff --git a/compiler/tests/21_hspice_delay_test.py b/compiler/tests/21_hspice_delay_test.py index b170b072..289f3934 100755 --- a/compiler/tests/21_hspice_delay_test.py +++ b/compiler/tests/21_hspice_delay_test.py @@ -17,6 +17,7 @@ class timing_sram_test(openram_test): globals.init_openram("config_20_{0}".format(OPTS.tech_name)) OPTS.spice_name="hspice" OPTS.analytical_delay = False + # This is a hack to reload the characterizer __init__ with the spice version from importlib import reload @@ -83,7 +84,6 @@ class timing_sram_test(openram_test): else: self.isclose(data[k],golden_data[k],0.15) - reload(characterizer) globals.end_openram() # instantiate a copdsay of the class to actually run the test diff --git a/compiler/tests/21_hspice_setuphold_test.py b/compiler/tests/21_hspice_setuphold_test.py index 5c4f72a6..f9d8a01c 100755 --- a/compiler/tests/21_hspice_setuphold_test.py +++ b/compiler/tests/21_hspice_setuphold_test.py @@ -26,7 +26,6 @@ class timing_setup_test(openram_test): if not OPTS.spice_exe: debug.error("Could not find {} simulator.".format(OPTS.spice_name),-1) - import sram import tech slews = [tech.spice["rise_time"]*2] @@ -58,7 +57,6 @@ class timing_setup_test(openram_test): else: self.isclose(data[k],golden_data[k],0.15) - reload(characterizer) globals.end_openram() # instantiate a copdsay of the class to actually run the test diff --git a/compiler/tests/21_ngspice_delay_test.py b/compiler/tests/21_ngspice_delay_test.py index 36e0c0d0..739d63ea 100755 --- a/compiler/tests/21_ngspice_delay_test.py +++ b/compiler/tests/21_ngspice_delay_test.py @@ -83,7 +83,6 @@ class timing_sram_test(openram_test): else: self.isclose(data[k],golden_data[k],0.15) - reload(characterizer) globals.end_openram() # instantiate a copdsay of the class to actually run the test diff --git a/compiler/tests/22_pex_test.py b/compiler/tests/22_pex_test.py index 1ccf6cfe..24cb7733 100755 --- a/compiler/tests/22_pex_test.py +++ b/compiler/tests/22_pex_test.py @@ -16,6 +16,17 @@ class sram_func_test(openram_test): def runTest(self): 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 import verify @@ -31,8 +42,6 @@ class sram_func_test(openram_test): import tech 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, num_words=OPTS.num_words, num_banks=OPTS.num_banks, diff --git a/compiler/tests/30_openram_test.py b/compiler/tests/30_openram_test.py index df480fdc..51546ae3 100755 --- a/compiler/tests/30_openram_test.py +++ b/compiler/tests/30_openram_test.py @@ -73,10 +73,7 @@ class openram_test(openram_test): shutil.rmtree(out_path, ignore_errors=True) self.assertEqual(os.path.exists(out_path),False) - # The default was on, so disable it. - OPTS.check_lvsdrc=False globals.end_openram() - OPTS.check_lvsdrc=True # instantiate a copy of the class to actually run the test if __name__ == "__main__":