From 2c76a2680fb79f5285826990ef83a2bba15674c9 Mon Sep 17 00:00:00 2001 From: mrg Date: Thu, 5 Nov 2020 13:12:26 -0800 Subject: [PATCH] Adjust openram options. Remove option -d (dontpurge) and replace with keeptemp Add option -d (debug) to drop into pdb. Add option -k (--keeptemp) to keep temp files --- compiler/base/hierarchy_design.py | 6 +++--- compiler/characterizer/stimuli.py | 2 +- compiler/debug.py | 2 +- compiler/globals.py | 23 +++++++++++++-------- compiler/options.py | 8 +++++-- compiler/router/tests/testutils.py | 4 ++-- compiler/tests/05_bitcell_array_test.py | 1 - compiler/tests/26_hspice_pex_pinv_test.py | 6 +++--- compiler/tests/26_ngspice_pex_pinv_test.py | 8 +++---- compiler/tests/30_openram_back_end_test.py | 4 ++-- compiler/tests/30_openram_front_end_test.py | 4 ++-- compiler/tests/testutils.py | 10 ++++----- 12 files changed, 43 insertions(+), 35 deletions(-) diff --git a/compiler/base/hierarchy_design.py b/compiler/base/hierarchy_design.py index 28954834..5404838a 100644 --- a/compiler/base/hierarchy_design.py +++ b/compiler/base/hierarchy_design.py @@ -90,7 +90,7 @@ class hierarchy_design(hierarchy_spice.spice, hierarchy_layout.layout): "LVS failed for {0} with {1} errors(s)".format(self.cell_name, self.lvs_errors)) - if OPTS.purge_temp: + if not OPTS.keep_temp: os.remove(tempspice) os.remove(tempgds) @@ -112,7 +112,7 @@ class hierarchy_design(hierarchy_spice.spice, hierarchy_layout.layout): "DRC failed for {0} with {1} error(s)".format(self.cell_name, num_errors)) - if OPTS.purge_temp: + if not OPTS.keep_temp: os.remove(tempgds) def LVS(self, final_verification=False): @@ -134,7 +134,7 @@ class hierarchy_design(hierarchy_spice.spice, hierarchy_layout.layout): debug.check(num_errors == 0, "LVS failed for {0} with {1} error(s)".format(self.cell_name, num_errors)) - if OPTS.purge_temp: + if not OPTS.keep_temp: os.remove(tempspice) os.remove(tempgds) diff --git a/compiler/characterizer/stimuli.py b/compiler/characterizer/stimuli.py index a312fc6d..a354e353 100644 --- a/compiler/characterizer/stimuli.py +++ b/compiler/characterizer/stimuli.py @@ -260,7 +260,7 @@ class stimuli(): # create plots for all signals self.sf.write("* probe is used for hspice/xa, while plot is used in ngspice\n") - if OPTS.debug_level>0: + if OPTS.verbose_level>0: if OPTS.spice_name in ["hspice", "xa"]: self.sf.write(".probe V(*)\n") else: diff --git a/compiler/debug.py b/compiler/debug.py index 15876f22..5a2d2893 100644 --- a/compiler/debug.py +++ b/compiler/debug.py @@ -90,7 +90,7 @@ log.create_file = True def info(lev, str): from globals import OPTS - if (OPTS.debug_level >= lev): + if (OPTS.verbose_level >= lev): frm = inspect.stack()[1] mod = inspect.getmodule(frm[0]) # classname = frm.f_globals['__name__'] diff --git a/compiler/globals.py b/compiler/globals.py index 216a6a34..e3d2ea5e 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -63,7 +63,7 @@ def parse_args(): optparse.make_option("-v", "--verbose", action="count", - dest="debug_level", + dest="verbose_level", help="Increase the verbosity level"), optparse.make_option("-t", "--tech", @@ -83,11 +83,16 @@ def parse_args(): action="store_false", dest="analytical_delay", help="Perform characterization to calculate delays (default is analytical models)"), + optparse.make_option("-k", + "--keeptemp", + action="store_true", + dest="keep_temp", + help="Keep the contents of the temp directory after a successful run"), optparse.make_option("-d", - "--dontpurge", - action="store_false", - dest="purge_temp", - help="Don't purge the contents of the temp directory after a successful run") + "--debug", + action="store_true", + dest="debug", + help="Run in debug mode to drop to pdb on failure") # -h --help is implicit. } @@ -366,7 +371,7 @@ def cleanup_paths(): We should clean up the temp directory after execution. """ global OPTS - if not OPTS.purge_temp: + if OPTS.keep_temp: debug.info(0, "Preserving temp directory: {}".format(OPTS.openram_temp)) return @@ -534,12 +539,12 @@ def print_time(name, now_time, last_time=None, indentation=2): global OPTS # Don't print during testing - if not OPTS.is_unit_test or OPTS.debug_level > 0: + if not OPTS.is_unit_test or OPTS.verbose_level > 0: if last_time: - time = str(round((now_time-last_time).total_seconds(),1)) + " seconds" + time = str(round((now_time - last_time).total_seconds(), 1)) + " seconds" else: time = now_time.strftime('%m/%d/%Y %H:%M:%S') - debug.print_raw("{0} {1}: {2}".format("*"*indentation, name, time)) + debug.print_raw("{0} {1}: {2}".format("*" * indentation, name, time)) def report_status(): diff --git a/compiler/options.py b/compiler/options.py index 1a0d1804..89a801b6 100644 --- a/compiler/options.py +++ b/compiler/options.py @@ -80,7 +80,10 @@ class options(optparse.Values): os.getpid()) # This is the verbosity level to control debug information. 0 is none, 1 # is minimal, etc. - debug_level = 0 + verbose_level = 0 + # Drop to pdb on failure? + debug = False + ################### # Run-time vs accuracy options. @@ -141,7 +144,8 @@ class options(optparse.Values): # Route the input/output pins to the perimeter perimeter_pins = False - purge_temp = True + keep_temp = False + # These are the default modules that can be over-riden bitcell_suffix = "" diff --git a/compiler/router/tests/testutils.py b/compiler/router/tests/testutils.py index c6e91459..1f43db91 100644 --- a/compiler/router/tests/testutils.py +++ b/compiler/router/tests/testutils.py @@ -26,7 +26,7 @@ class openram_test(unittest.TestCase): if result != 0: self.fail("DRC failed: {}".format(w.name)) - if OPTS.purge_temp: + if not OPTS.keep_temp: self.cleanup() def local_check(self, a, final_verification=False): @@ -49,7 +49,7 @@ class openram_test(unittest.TestCase): if result != 0: self.fail("LVS mismatch: {}".format(a.name)) - if OPTS.purge_temp: + if not OPTS.keep_temp: self.cleanup() def cleanup(self): diff --git a/compiler/tests/05_bitcell_array_test.py b/compiler/tests/05_bitcell_array_test.py index 95a0d1fb..218cc734 100755 --- a/compiler/tests/05_bitcell_array_test.py +++ b/compiler/tests/05_bitcell_array_test.py @@ -15,7 +15,6 @@ from globals import OPTS from sram_factory import factory import debug -#@unittest.skip("SKIPPING 05_array_test") class array_test(openram_test): diff --git a/compiler/tests/26_hspice_pex_pinv_test.py b/compiler/tests/26_hspice_pex_pinv_test.py index 660469b1..74f1ae9c 100755 --- a/compiler/tests/26_hspice_pex_pinv_test.py +++ b/compiler/tests/26_hspice_pex_pinv_test.py @@ -34,9 +34,9 @@ class hspice_pex_pinv_test(openram_test): reload(characterizer) # generate the pinv - prev_purge_value = OPTS.purge_temp + prev_keep_value = OPTS.keep_temp # force set purge to false to save the sp file - OPTS.purge_temp = False + OPTS.keep_temp = True debug.info(2, "Checking 1x size inverter") tx = pinv.pinv(name="pinv", size=1) tempgds = "{0}{1}.gds".format(OPTS.openram_temp, tx.name) @@ -52,7 +52,7 @@ class hspice_pex_pinv_test(openram_test): # now generate its pex file pex_file = self.run_pex(tx) - OPTS.purge_temp = prev_purge_value # restore the old purge value + OPTS.keep_temp = prev_keep_value # restore the old keep # generate simulation for pex, make sure the simulation is successful pex_delay = self.simulate_delay(test_module=pex_file, top_level_name=tx.name) diff --git a/compiler/tests/26_ngspice_pex_pinv_test.py b/compiler/tests/26_ngspice_pex_pinv_test.py index 890ecb8b..7e3800ec 100755 --- a/compiler/tests/26_ngspice_pex_pinv_test.py +++ b/compiler/tests/26_ngspice_pex_pinv_test.py @@ -33,8 +33,8 @@ class ngspice_pex_pinv_test(openram_test): reload(characterizer) # generate the pinv module - prev_purge_value = OPTS.purge_temp - OPTS.purge_temp = False # force set purge to false to save the sp file + prev_keep_value = OPTS.keep_temp + OPTS.keep_temp = True # force set keep to true to save the sp file debug.info(2, "Checking 1x size inverter") tx = pinv.pinv(name="pinv", size=1) tempgds = "{0}{1}.gds".format(OPTS.openram_temp, tx.name) @@ -50,8 +50,8 @@ class ngspice_pex_pinv_test(openram_test): # now generate its pex file pex_file = self.run_pex(tx) - # restore the old purge value - OPTS.purge_temp = prev_purge_value + # restore the old keep value + OPTS.keep_temp = prev_keep_value # generate simulation for pex, make sure the simulation is successful pex_delay = self.simulate_delay(test_module=pex_file, top_level_name=tx.name) diff --git a/compiler/tests/30_openram_back_end_test.py b/compiler/tests/30_openram_back_end_test.py index 01c62a10..5df0b55a 100755 --- a/compiler/tests/30_openram_back_end_test.py +++ b/compiler/tests/30_openram_back_end_test.py @@ -40,7 +40,7 @@ class openram_back_end_test(openram_test): # specify the same verbosity for the system call options = "" - for i in range(OPTS.debug_level): + for i in range(OPTS.verbose_level): options += " -v" if OPTS.spice_name: @@ -86,7 +86,7 @@ class openram_back_end_test(openram_test): self.assertEqual(len(re.findall('WARNING', output)), 0) # now clean up the directory - if OPTS.purge_temp: + if not OPTS.keep_temp: if os.path.exists(out_path): shutil.rmtree(out_path, ignore_errors=True) self.assertEqual(os.path.exists(out_path), False) diff --git a/compiler/tests/30_openram_front_end_test.py b/compiler/tests/30_openram_front_end_test.py index 88d673b6..befbe850 100755 --- a/compiler/tests/30_openram_front_end_test.py +++ b/compiler/tests/30_openram_front_end_test.py @@ -40,7 +40,7 @@ class openram_front_end_test(openram_test): # specify the same verbosity for the system call options = "" - for i in range(OPTS.debug_level): + for i in range(OPTS.verbose_level): options += " -v" if OPTS.spice_name: @@ -86,7 +86,7 @@ class openram_front_end_test(openram_test): self.assertEqual(len(re.findall('WARNING', output)), 0) # now clean up the directory - if OPTS.purge_temp: + if not OPTS.keep_temp: if os.path.exists(out_path): shutil.rmtree(out_path, ignore_errors=True) self.assertEqual(os.path.exists(out_path), False) diff --git a/compiler/tests/testutils.py b/compiler/tests/testutils.py index 0ab7b8a8..e63b457d 100644 --- a/compiler/tests/testutils.py +++ b/compiler/tests/testutils.py @@ -10,6 +10,8 @@ import sys, os, glob sys.path.append(os.getenv("OPENRAM_HOME")) from globals import OPTS import debug +import pdb +import traceback class openram_test(unittest.TestCase): @@ -27,7 +29,7 @@ class openram_test(unittest.TestCase): if result != 0: self.fail("DRC failed: {}".format(w.name)) - if OPTS.purge_temp: + if not OPTS.keep_temp: self.cleanup() def local_check(self, a, final_verification=False): @@ -74,7 +76,7 @@ class openram_test(unittest.TestCase): # For debug... # import pdb; pdb.set_trace() - if OPTS.purge_temp: + if not OPTS.keep_temp: self.cleanup() def run_pex(self, a, output=None): @@ -321,9 +323,7 @@ def header(filename, technology): def debugTestRunner(post_mortem=None): """unittest runner doing post mortem debugging on failing tests""" - import pdb - import traceback - if post_mortem is None and not OPTS.purge_temp: + if post_mortem is None and OPTS.debug: post_mortem = pdb.post_mortem class DebugTestResult(unittest.TextTestResult):