diff --git a/compiler/globals.py b/compiler/globals.py index fc250033..dd688db5 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -134,7 +134,16 @@ def set_calibre(): debug.warning("Calibre not found. Not performing inline LVS/DRC.") OPTS.check_lvsdrc = False +def end_openram(): + """ Clean up openram for a proper exit """ + cleanup_paths() + +def cleanup_paths(): + # we should clean up this temp directory after execution... + if os.path.exists(OPTS.openram_temp): + shutil.rmtree(OPTS.openram_temp, ignore_errors=True) + def setup_paths(): """ Set up the non-tech related paths. """ debug.info(2,"Setting up paths...") @@ -150,14 +159,11 @@ def setup_paths(): sys.path.append("{0}/tests".format(OPENRAM_HOME)) sys.path.append("{0}/characterizer".format(OPENRAM_HOME)) - if not OPTS.openram_temp.endswith('/'): OPTS.openram_temp += "/" debug.info(1, "Temporary files saved in " + OPTS.openram_temp) - # we should clean up this temp directory after execution... - if os.path.exists(OPTS.openram_temp): - shutil.rmtree(OPTS.openram_temp, ignore_errors=True) + cleanup_paths() # make the directory if it doesn't exist try: diff --git a/compiler/openram.py b/compiler/openram.py index dace6489..cbff2bf4 100755 --- a/compiler/openram.py +++ b/compiler/openram.py @@ -117,5 +117,6 @@ libname = OPTS.out_path + s.name + ".lib" print "LIB: Writing to {0}".format(libname) lib.lib(libname,s,sram_file) +globals.end_openram() print "End: ", datetime.datetime.now() diff --git a/compiler/options.py b/compiler/options.py index 0b03933e..83fda555 100644 --- a/compiler/options.py +++ b/compiler/options.py @@ -1,5 +1,6 @@ import optparse import getpass +import os class options(optparse.Values): """ @@ -10,7 +11,7 @@ class options(optparse.Values): # This is the name of the technology. tech_name = "" # This is the temp directory where all intermediate results are stored. - openram_temp = "/tmp/openram_{0}_temp/".format(getpass.getuser()) + openram_temp = "/tmp/openram_{0}_{1}_temp/".format(getpass.getuser(),os.getpid()) # This is the verbosity level to control debug information. 0 is none, 1 # is minimal, etc. debug_level = 0 diff --git a/compiler/tests/01_library_drc_test.py b/compiler/tests/01_library_drc_test.py index ea1612ff..e394d84b 100644 --- a/compiler/tests/01_library_drc_test.py +++ b/compiler/tests/01_library_drc_test.py @@ -33,7 +33,7 @@ class library_drc_test(unittest.TestCase): # fails if there are any DRC errors on any cells self.assertEqual(drc_errors, 0) - + globals.end_openram() def setup_files(): gds_dir = OPTS.openram_tech + "/gds_lib" diff --git a/compiler/tests/02_library_lvs_test.py b/compiler/tests/02_library_lvs_test.py index 0ef925c6..734784e0 100644 --- a/compiler/tests/02_library_lvs_test.py +++ b/compiler/tests/02_library_lvs_test.py @@ -37,7 +37,7 @@ class library_lvs_test(unittest.TestCase): # fail if the error count is not zero self.assertEqual(lvs_errors, 0) - + globals.end_openram() def setup_files(): gds_dir = OPTS.openram_tech + "/gds_lib" diff --git a/compiler/tests/03_contact_test.py b/compiler/tests/03_contact_test.py index 5b068786..85acc10a 100644 --- a/compiler/tests/03_contact_test.py +++ b/compiler/tests/03_contact_test.py @@ -54,7 +54,8 @@ class contact_test(unittest.TestCase): self.local_check(c) OPTS.check_lvsdrc = True - + globals.end_openram() + def local_check(self, c): tempgds = OPTS.openram_temp + "temp.gds" c.gds_write(tempgds) diff --git a/compiler/tests/03_path_test.py b/compiler/tests/03_path_test.py index 62a0ec0e..64767f3f 100644 --- a/compiler/tests/03_path_test.py +++ b/compiler/tests/03_path_test.py @@ -75,7 +75,8 @@ class path_test(unittest.TestCase): # return it back to it's normal state OPTS.check_lvsdrc = True - + globals.end_openram() + def local_check(self, w): tempgds = OPTS.openram_temp + "temp.gds" w.gds_write(tempgds) diff --git a/compiler/tests/03_ptx_1finger_nmos_test.py b/compiler/tests/03_ptx_1finger_nmos_test.py index eec4f13c..3f023020 100644 --- a/compiler/tests/03_ptx_1finger_nmos_test.py +++ b/compiler/tests/03_ptx_1finger_nmos_test.py @@ -33,7 +33,7 @@ class ptx_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(fet) - + globals.end_openram() def add_mods(self, fet): diff --git a/compiler/tests/03_ptx_1finger_pmos_test.py b/compiler/tests/03_ptx_1finger_pmos_test.py index 243f30de..4bb3e312 100644 --- a/compiler/tests/03_ptx_1finger_pmos_test.py +++ b/compiler/tests/03_ptx_1finger_pmos_test.py @@ -33,7 +33,7 @@ class ptx_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(fet) - + globals.end_openram() def add_mods(self, fet): diff --git a/compiler/tests/03_ptx_3finger_nmos_test.py b/compiler/tests/03_ptx_3finger_nmos_test.py index 61257e49..17ec9092 100644 --- a/compiler/tests/03_ptx_3finger_nmos_test.py +++ b/compiler/tests/03_ptx_3finger_nmos_test.py @@ -33,7 +33,7 @@ class ptx_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(fet) - + globals.end_openram() def add_mods(self, fet): self.create_contacts() diff --git a/compiler/tests/03_ptx_3finger_pmos_test.py b/compiler/tests/03_ptx_3finger_pmos_test.py index ffcb5086..f889527d 100644 --- a/compiler/tests/03_ptx_3finger_pmos_test.py +++ b/compiler/tests/03_ptx_3finger_pmos_test.py @@ -33,7 +33,8 @@ class ptx_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(fet) - + globals.end_openram() + def add_mods(self, fet): self.create_contacts() self.add_well_extension(fet) diff --git a/compiler/tests/03_wire_test.py b/compiler/tests/03_wire_test.py index 46b7eee5..d9856b43 100644 --- a/compiler/tests/03_wire_test.py +++ b/compiler/tests/03_wire_test.py @@ -128,7 +128,8 @@ class wire_test(unittest.TestCase): # return it back to it's normal state OPTS.check_lvsdrc = True - + globals.end_openram() + def local_check(self, w): tempgds = OPTS.openram_temp + "temp.gds" w.gds_write(tempgds) diff --git a/compiler/tests/04_nand_2_test.py b/compiler/tests/04_nand_2_test.py index 308a8867..aa8d6c08 100644 --- a/compiler/tests/04_nand_2_test.py +++ b/compiler/tests/04_nand_2_test.py @@ -33,7 +33,8 @@ class nand_2_test(unittest.TestCase): tx = nand_2.nand_2(name="a_nand_1", nmos_width=2 * tech.drc["minwidth_tx"]) OPTS.check_lvsdrc = True self.local_check(tx) - + globals.end_openram() + def local_check(self, tx): tempspice = OPTS.openram_temp + "temp.sp" diff --git a/compiler/tests/04_nand_3_test.py b/compiler/tests/04_nand_3_test.py index 70972192..87ba75a0 100644 --- a/compiler/tests/04_nand_3_test.py +++ b/compiler/tests/04_nand_3_test.py @@ -31,7 +31,8 @@ class nand_3_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(tx) - + globals.end_openram() + def local_check(self, tx): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/04_nor_2_test.py b/compiler/tests/04_nor_2_test.py index 8ef09468..d866cede 100644 --- a/compiler/tests/04_nor_2_test.py +++ b/compiler/tests/04_nor_2_test.py @@ -32,7 +32,7 @@ class nor_2_test(unittest.TestCase): tx = nor_2.nor_2(name="a_nor_1", nmos_width=2 * tech.drc["minwidth_tx"]) OPTS.check_lvsdrc = True self.local_check(tx) - + globals.end_openram() def local_check(self, tx): tempspice = OPTS.openram_temp + "temp.sp" diff --git a/compiler/tests/04_pinv_test.py b/compiler/tests/04_pinv_test.py index cdc35175..de20a27d 100644 --- a/compiler/tests/04_pinv_test.py +++ b/compiler/tests/04_pinv_test.py @@ -42,6 +42,7 @@ class pinv_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(tx) + globals.end_openram() def local_check(self, tx): tempspice = OPTS.openram_temp + "temp.sp" diff --git a/compiler/tests/04_wordline_driver_test.py b/compiler/tests/04_wordline_driver_test.py index a18b3c8c..b1a5c470 100644 --- a/compiler/tests/04_wordline_driver_test.py +++ b/compiler/tests/04_wordline_driver_test.py @@ -33,7 +33,7 @@ class wordline_driver_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(tx) - + globals.end_openram() def local_check(self, tx): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/05_bitcell_array_test.py b/compiler/tests/05_bitcell_array_test.py index 80dba9c1..6ec0c7d4 100644 --- a/compiler/tests/05_bitcell_array_test.py +++ b/compiler/tests/05_bitcell_array_test.py @@ -31,7 +31,7 @@ class array_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) - + globals.end_openram() def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" diff --git a/compiler/tests/06_hierarchical_decoder_test.py b/compiler/tests/06_hierarchical_decoder_test.py index 6fc77d15..649a1fd9 100644 --- a/compiler/tests/06_hierarchical_decoder_test.py +++ b/compiler/tests/06_hierarchical_decoder_test.py @@ -57,7 +57,8 @@ class hierarchical_decoder_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) - + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/06_hierarchical_predecode2x4_test.py b/compiler/tests/06_hierarchical_predecode2x4_test.py index 3b630fe4..551a1fb0 100644 --- a/compiler/tests/06_hierarchical_predecode2x4_test.py +++ b/compiler/tests/06_hierarchical_predecode2x4_test.py @@ -30,7 +30,8 @@ class hierarchical_predecode2x4_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) - + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/06_hierarchical_predecode3x8_test.py b/compiler/tests/06_hierarchical_predecode3x8_test.py index 39f3517f..50162d31 100644 --- a/compiler/tests/06_hierarchical_predecode3x8_test.py +++ b/compiler/tests/06_hierarchical_predecode3x8_test.py @@ -30,6 +30,7 @@ class hierarchical_predecode3x8_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) + globals.end_openram() def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" diff --git a/compiler/tests/07_single_level_column_mux_test.py b/compiler/tests/07_single_level_column_mux_test.py index 35305102..490a3497 100644 --- a/compiler/tests/07_single_level_column_mux_test.py +++ b/compiler/tests/07_single_level_column_mux_test.py @@ -28,7 +28,8 @@ class single_level_column_mux_test(unittest.TestCase): rows=32, columns=32, word_size=16) OPTS.check_lvsdrc = True self.local_check(a) - + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/08_precharge_array_test.py b/compiler/tests/08_precharge_array_test.py index 8b4d3e92..308dc937 100644 --- a/compiler/tests/08_precharge_array_test.py +++ b/compiler/tests/08_precharge_array_test.py @@ -38,7 +38,8 @@ class precharge_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(pc) - + globals.end_openram() + def local_check(self, pc): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/09_sense_amp_array_test.py b/compiler/tests/09_sense_amp_array_test.py index d29f496d..80536e16 100644 --- a/compiler/tests/09_sense_amp_array_test.py +++ b/compiler/tests/09_sense_amp_array_test.py @@ -41,7 +41,8 @@ class sense_amp_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) - + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/10_write_driver_array_test.py b/compiler/tests/10_write_driver_array_test.py index 4148e865..ca289e30 100644 --- a/compiler/tests/10_write_driver_array_test.py +++ b/compiler/tests/10_write_driver_array_test.py @@ -35,6 +35,7 @@ class write_driver_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) + globals.end_openram() def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" diff --git a/compiler/tests/11_ms_flop_array_test.py b/compiler/tests/11_ms_flop_array_test.py index 0c26a001..9f282278 100644 --- a/compiler/tests/11_ms_flop_array_test.py +++ b/compiler/tests/11_ms_flop_array_test.py @@ -31,6 +31,7 @@ class dff_array_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) + globals.end_openram() def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" diff --git a/compiler/tests/13_control_logic_test.py b/compiler/tests/13_control_logic_test.py index 567f3584..8d308ace 100644 --- a/compiler/tests/13_control_logic_test.py +++ b/compiler/tests/13_control_logic_test.py @@ -29,7 +29,8 @@ class control_logic_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) - + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/14_logic_effort_dc_test.py b/compiler/tests/14_logic_effort_dc_test.py index 9cd3c2ea..0ce27871 100644 --- a/compiler/tests/14_logic_effort_dc_test.py +++ b/compiler/tests/14_logic_effort_dc_test.py @@ -31,6 +31,8 @@ class logic_effort_dc_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/15_tri_gate_array_test.py b/compiler/tests/15_tri_gate_array_test.py index 3daa7556..1b7c8440 100644 --- a/compiler/tests/15_tri_gate_array_test.py +++ b/compiler/tests/15_tri_gate_array_test.py @@ -28,6 +28,8 @@ class tri_gate_array_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/16_replica_bitline_test.py b/compiler/tests/16_replica_bitline_test.py index c8e732c8..6e0d943e 100644 --- a/compiler/tests/16_replica_bitline_test.py +++ b/compiler/tests/16_replica_bitline_test.py @@ -31,6 +31,8 @@ class replica_bitline_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/19_bank_test.py b/compiler/tests/19_bank_test.py index 0bd67b5b..bfeeef61 100644 --- a/compiler/tests/19_bank_test.py +++ b/compiler/tests/19_bank_test.py @@ -35,6 +35,8 @@ class bank_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/20_sram_1bank_test.py b/compiler/tests/20_sram_1bank_test.py index 5ca96ab0..261fa315 100644 --- a/compiler/tests/20_sram_1bank_test.py +++ b/compiler/tests/20_sram_1bank_test.py @@ -30,7 +30,8 @@ class sram_1bank_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) - + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/20_sram_2bank_test.py b/compiler/tests/20_sram_2bank_test.py index 9f87d55b..ce0e1c07 100644 --- a/compiler/tests/20_sram_2bank_test.py +++ b/compiler/tests/20_sram_2bank_test.py @@ -30,6 +30,8 @@ class sram_2bank_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/20_sram_4bank_test.py b/compiler/tests/20_sram_4bank_test.py index 146b04fe..8603cd8a 100644 --- a/compiler/tests/20_sram_4bank_test.py +++ b/compiler/tests/20_sram_4bank_test.py @@ -30,6 +30,8 @@ class sram_4bank_test(unittest.TestCase): OPTS.check_lvsdrc = True self.local_check(a) + globals.end_openram() + def local_check(self, a): tempspice = OPTS.openram_temp + "temp.sp" tempgds = OPTS.openram_temp + "temp.gds" diff --git a/compiler/tests/21_hspice_delay_test.py b/compiler/tests/21_hspice_delay_test.py index 48a74dcc..eef6b3e2 100644 --- a/compiler/tests/21_hspice_delay_test.py +++ b/compiler/tests/21_hspice_delay_test.py @@ -63,8 +63,9 @@ class timing_sram_test(unittest.TestCase): self.assertTrue(False) # other techs fail os.remove(tempspice) - + globals.end_openram() + # instantiate a copdsay of the class to actually run the test if __name__ == "__main__": (OPTS, args) = globals.parse_args() diff --git a/compiler/tests/21_hspice_hold_test.py b/compiler/tests/21_hspice_hold_test.py index 8bc48afa..54385898 100644 --- a/compiler/tests/21_hspice_hold_test.py +++ b/compiler/tests/21_hspice_hold_test.py @@ -44,6 +44,7 @@ class timing_setup_test(unittest.TestCase): else: self.assertTrue(False) # other techs fail + globals.end_openram() # instantiate a copdsay of the class to actually run the test if __name__ == "__main__": diff --git a/compiler/tests/21_hspice_setup_test.py b/compiler/tests/21_hspice_setup_test.py index e60e937c..9e15b990 100644 --- a/compiler/tests/21_hspice_setup_test.py +++ b/compiler/tests/21_hspice_setup_test.py @@ -44,6 +44,8 @@ class timing_setup_test(unittest.TestCase): else: self.assertTrue(False) # other techs fail + globals.end_openram() + # instantiate a copdsay of the class to actually run the test if __name__ == "__main__": (OPTS, args) = globals.parse_args() diff --git a/compiler/tests/22_pex_func_test_with_pinv.py b/compiler/tests/22_pex_func_test_with_pinv.py index 4f79fcb6..f9410eea 100644 --- a/compiler/tests/22_pex_func_test_with_pinv.py +++ b/compiler/tests/22_pex_func_test_with_pinv.py @@ -24,6 +24,8 @@ class sram_func_test(unittest.TestCase): self.func_test(bank_num=2) self.func_test(bank_num=4) + globals.end_openram() + def func_test(self, bank_num): import sram diff --git a/compiler/tests/22_sram_func_test.py b/compiler/tests/22_sram_func_test.py index 70bea6d4..c549d27c 100644 --- a/compiler/tests/22_sram_func_test.py +++ b/compiler/tests/22_sram_func_test.py @@ -51,6 +51,8 @@ class sram_func_test(unittest.TestCase): os.remove(tempspice) + globals.end_openram() + # instantiate a copdsay of the class to actually run the test if __name__ == "__main__": (OPTS, args) = globals.parse_args() diff --git a/compiler/tests/23_lib_sram_test.py b/compiler/tests/23_lib_sram_test.py index 29303dae..037a1d65 100644 --- a/compiler/tests/23_lib_sram_test.py +++ b/compiler/tests/23_lib_sram_test.py @@ -47,7 +47,7 @@ class lib_test(unittest.TestCase): os.system("rm {0}".format(libname)) - + globals.end_openram() # instantiate a copdsay of the class to actually run the test if __name__ == "__main__": diff --git a/compiler/tests/24_lef_sram_test.py b/compiler/tests/24_lef_sram_test.py index 7efc27f5..3c4e2b81 100644 --- a/compiler/tests/24_lef_sram_test.py +++ b/compiler/tests/24_lef_sram_test.py @@ -47,7 +47,7 @@ class lef_test(unittest.TestCase): os.system("rm {0}".format(gdsname)) os.system("rm {0}".format(lefname)) - + globals.end_openram() # instantiate a copdsay of the class to actually run the test if __name__ == "__main__": diff --git a/compiler/tests/25_verilog_sram_test.py b/compiler/tests/25_verilog_sram_test.py index 8ba64637..66abfa47 100644 --- a/compiler/tests/25_verilog_sram_test.py +++ b/compiler/tests/25_verilog_sram_test.py @@ -44,6 +44,8 @@ class verilog_test(unittest.TestCase): os.system("rm {0}".format(vname)) + globals.end_openram() + # instantiate a copdsay of the class to actually run the test if __name__ == "__main__": (OPTS, args) = globals.parse_args() diff --git a/compiler/tests/30_openram_test.py b/compiler/tests/30_openram_test.py index cf5ddf70..4327f401 100644 --- a/compiler/tests/30_openram_test.py +++ b/compiler/tests/30_openram_test.py @@ -73,6 +73,7 @@ class openram_test(unittest.TestCase): shutil.rmtree(out_path, ignore_errors=True) self.assertEqual(os.path.exists(out_path),False) + globals.end_openram() # instantiate a copdsay of the class to actually run the test if __name__ == "__main__":