From 8071dcc0f318fd328ff3b25bdb211951313fadc6 Mon Sep 17 00:00:00 2001 From: Matt Guthaus Date: Sun, 12 Nov 2017 10:42:41 -0800 Subject: [PATCH] Add customsim (xa) as optional simulator. Fix regex to support scientific notation. Go through list of preferred simulators in order. Always abort if command-line simulator not found. --- compiler/characterizer/charutils.py | 4 +- compiler/characterizer/stimuli.py | 8 ++-- compiler/globals.py | 51 ++++++++------------- compiler/options.py | 2 - compiler/tests/21_hspice_delay_test.py | 2 - compiler/tests/21_hspice_setuphold_test.py | 1 - compiler/tests/21_ngspice_delay_test.py | 2 - compiler/tests/21_ngspice_setuphold_test.py | 2 - 8 files changed, 28 insertions(+), 44 deletions(-) diff --git a/compiler/characterizer/charutils.py b/compiler/characterizer/charutils.py index 27e1b9a4..d933ba7c 100644 --- a/compiler/characterizer/charutils.py +++ b/compiler/characterizer/charutils.py @@ -13,8 +13,10 @@ def relative_compare(value1,value2,error_tolerance=0.001): def parse_output(filename, key): """Parses a hspice output.lis file for a key value""" if OPTS.spice_version == "xa" : + # customsim has a different output file name full_filename="{0}xa.meas".format(OPTS.openram_temp) - else : + else: + # ngspice/hspice using a .lis file full_filename="{0}{1}.lis".format(OPTS.openram_temp, filename) try: diff --git a/compiler/characterizer/stimuli.py b/compiler/characterizer/stimuli.py index a33e587c..13c9bb06 100644 --- a/compiler/characterizer/stimuli.py +++ b/compiler/characterizer/stimuli.py @@ -279,13 +279,15 @@ def run_sim(): if OPTS.spice_version == "xa": - cmd = "{0} {1} -o {2}xa -mt 20".format(OPTS.spice_exe,temp_stim,OPTS.openram_temp) + cmd = "{0} {1} -o {2}xa -mt 20".format(OPTS.spice_exe, + temp_stim, + OPTS.openram_temp) valid_retcode=0 elif OPTS.spice_version == "hspice": # TODO: Should make multithreading parameter a configuration option cmd = "{0} -mt 2 -i {1} -o {2}timing".format(OPTS.spice_exe, - temp_stim, - OPTS.openram_temp) + temp_stim, + OPTS.openram_temp) valid_retcode=0 else: cmd = "{0} -b -o {2}timing.lis {1}".format(OPTS.spice_exe, diff --git a/compiler/globals.py b/compiler/globals.py index 99161541..4ad650f8 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -234,6 +234,16 @@ def setup_paths(): +def find_spice(spice_exe): + # Check if the preferred spice option exists in the path + for path in os.environ["PATH"].split(os.pathsep): + spice_exe = os.path.join(path, OPTS.spice_version) + # if it is found, then break and use first version + if is_exe(spice_exe): + debug.info(1, "Using spice: " + spice_exe) + OPTS.spice_exe = spice_exe + return True + return False def set_spice(): debug.info(2,"Finding spice...") @@ -247,46 +257,25 @@ def set_spice(): OPTS.spice_exe = "" - # Check if the preferred spice option exists in the path - for path in os.environ["PATH"].split(os.pathsep): - spice_exe = os.path.join(path, OPTS.spice_version) - # if it is found, then break and use first version - if is_exe(spice_exe): - debug.info(1, "Using spice: " + spice_exe) - OPTS.spice_exe = spice_exe - break - - if not OPTS.force_spice and OPTS.spice_exe == "": - # if we didn't find the preferred version, try the other version and warn - prev_version=OPTS.spice_version - if OPTS.spice_version == "hspice": - OPTS.spice_version = "ngspice" - else: - OPTS.spice_version = "hspice" - debug.warning("Unable to find {0} so trying {1}".format(prev_version,OPTS.spice_version)) + spice_preferences = ["xa", "hspice", "ngspice", "ngspice.exe"] - for path in os.environ["PATH"].split(os.pathsep): - spice_exe = os.path.join(path, OPTS.spice_version) - # if it is found, then break and use first version - if is_exe(spice_exe): - found_spice = True - debug.info(1, "Using spice: " + spice_exe) - OPTS.spice_exe = spice_exe + if OPTS.spice_version != "": + if not find_spice(OPTS.spice_version): + debug.error("{0} not found. Unable to perform characterization.".format(OPTS.spice_version),1) + else: + for spice_exe in spice_preferences: + if find_spice(spice_exe): break + else: + debug.warning("Unable to find spice {0}, trying another.".format(spice_exe)) # set the input dir for spice files if using ngspice if OPTS.spice_version == "ngspice": os.environ["NGSPICE_INPUT_DIR"] = "{0}".format(OPTS.openram_temp) if OPTS.spice_exe == "": - # otherwise, give warning and procede - if OPTS.force_spice: - debug.error("{0} not found. Unable to perform characterization.".format(OPTS.spice_version),1) - else: - debug.error("Neither hspice/ngspice not found. Unable to perform characterization.",1) + debug.error("No recognizable spice version found. Unable to perform characterization.",1) - if OPTS.analytical_delay: - debug.warning("Using analytical delay models instead of characterization.") # imports correct technology directories for testing diff --git a/compiler/options.py b/compiler/options.py index 53587578..da7cf6df 100644 --- a/compiler/options.py +++ b/compiler/options.py @@ -20,8 +20,6 @@ class options(optparse.Values): check_lvsdrc = True # Variable to select the variant of spice (hspice or ngspice right now) spice_version = "hspice" - # Should we fall back if we can't find our preferred spice? - force_spice = False # Should we print out the banner at startup print_banner = True # The Calibre executable being used which is derived from the user PATH. diff --git a/compiler/tests/21_hspice_delay_test.py b/compiler/tests/21_hspice_delay_test.py index 2069c6e1..eeca9bc6 100644 --- a/compiler/tests/21_hspice_delay_test.py +++ b/compiler/tests/21_hspice_delay_test.py @@ -23,7 +23,6 @@ class timing_sram_test(unittest.TestCase): # we will manually run lvs/drc OPTS.check_lvsdrc = False OPTS.spice_version="hspice" - OPTS.force_spice = True OPTS.analytical_delay = False globals.set_spice() @@ -88,7 +87,6 @@ class timing_sram_test(unittest.TestCase): # reset these options OPTS.check_lvsdrc = True OPTS.spice_version="hspice" - OPTS.force_spice = False OPTS.analytical_delay = True globals.set_spice() diff --git a/compiler/tests/21_hspice_setuphold_test.py b/compiler/tests/21_hspice_setuphold_test.py index 89cec0d9..a48408b8 100644 --- a/compiler/tests/21_hspice_setuphold_test.py +++ b/compiler/tests/21_hspice_setuphold_test.py @@ -24,7 +24,6 @@ class timing_setup_test(unittest.TestCase): # we will manually run lvs/drc OPTS.check_lvsdrc = False OPTS.spice_version="hspice" - OPTS.force_spice = True globals.set_spice() import sram diff --git a/compiler/tests/21_ngspice_delay_test.py b/compiler/tests/21_ngspice_delay_test.py index 3f0e9e5d..1e4a4869 100644 --- a/compiler/tests/21_ngspice_delay_test.py +++ b/compiler/tests/21_ngspice_delay_test.py @@ -21,7 +21,6 @@ class timing_sram_test(unittest.TestCase): # we will manually run lvs/drc OPTS.check_lvsdrc = False OPTS.spice_version="ngspice" - OPTS.force_spice = True OPTS.analytical_delay = False globals.set_spice() @@ -84,7 +83,6 @@ class timing_sram_test(unittest.TestCase): # reset these options OPTS.check_lvsdrc = True OPTS.spice_version="hspice" - OPTS.force_spice = False OPTS.analytical_delay = True globals.set_spice() diff --git a/compiler/tests/21_ngspice_setuphold_test.py b/compiler/tests/21_ngspice_setuphold_test.py index 5314408f..2def0342 100644 --- a/compiler/tests/21_ngspice_setuphold_test.py +++ b/compiler/tests/21_ngspice_setuphold_test.py @@ -23,7 +23,6 @@ class timing_setup_test(unittest.TestCase): # we will manually run lvs/drc OPTS.check_lvsdrc = False OPTS.spice_version="ngspice" - OPTS.force_spice = True globals.set_spice() import sram @@ -61,7 +60,6 @@ class timing_setup_test(unittest.TestCase): # reset these options OPTS.check_lvsdrc = True OPTS.spice_version="hspice" - OPTS.force_spice = False globals.set_spice() globals.end_openram()