diff --git a/tools/oneclick/base/hdl_config.py b/tools/oneclick/base/hdl_config.py index e3457bd43c1c2ec7de88103a0531e31b23360f5c..1d9142a5d88e7c5595cefbd4ee4d60d474812f1b 100644 --- a/tools/oneclick/base/hdl_config.py +++ b/tools/oneclick/base/hdl_config.py @@ -103,28 +103,43 @@ class HdlConfig: lib_order.insert(lib_order.index(lib_name), use_lib) # move used lib to just before this lib return lib_order - def get_lib_build_sim_dirs(self, lib_dicts=None): - """Get the simulation build directory for all HDL libraries in the specified list of lib_dicts. + def get_lib_build_dirs(self, build_type, build_subdir=None, lib_dicts=None): + """Get the tool build directory for all HDL libraries in the specified list of lib_dicts. - If key 'build_dir' in HDL library config file is '' then - define build dir by 'sim_tool_name' local to current HDL library directory. + The build_type can be: + 'sim' uses the 'build_sim_dir' key in the lib_dict, + 'synth' uses the 'build_synth_dir' key in the lib_dict + + If the build_subdir is not specfied then it defaults to the tool name key value. + + If the build dir key in HDL library config file is '' then + treat the build dir key as local directory in the HDL library directory. else - define build dir by 'sim_tool_name' local to 'build_dir' directory. + treat the build dir key as central directory. """ if lib_dicts==None: lib_dicts=self.libs.dicts - sim_dirs = [] + if build_type=='sim': + build_dir_key = 'build_sim_dir' + tool_name_key = 'sim_tool_name' + elif build_type=='synth': + build_dir_key = 'build_synth_dir' + tool_name_key = 'synth_tool_name' + else: + sys.exit('Error : Unknown build type') + if build_subdir==None: build_subdir = self.tool.get_key_values(tool_name_key) + build_dirs = [] for lib_dict in cm.listify(lib_dicts): - lib_path = self.libs.get_filePath(lib_dict) - build_dir = os.path.expandvars(self.libs.get_key_values('build_dir', lib_dict)) - sim_tool_name = self.tool.get_key_values('sim_tool_name') + build_dir = os.path.expandvars(self.libs.get_key_values(build_dir_key, lib_dict)) if build_dir=='': - sim_dirs.append(os.path.join(lib_path, build_dir, sim_tool_name)) + lib_path = self.libs.get_filePath(lib_dict) + build_dirs.append(os.path.join(lib_path, build_subdir)) # local build directory in HDL library directory else: - sim_dirs.append(os.path.join(lib_path, build_dir, sim_tool_name)) - return cm.unlistify(sim_dirs) + lib_name = lib_dict['hdl_lib_name'] + build_dirs.append(os.path.join(build_dir, build_subdir, lib_name)) # central build cdirectory + return cm.unlistify(build_dirs) def create_lib_order_files(self, lib_names=None): - """Create the Modelsim project file for all HDL libraries in the specified list of lib_names.""" + """Create the compile order file for all HDL libraries in the specified list of lib_names.""" if lib_names==None: lib_names=self.lib_names lib_dicts = self.libs.get_dicts('hdl_lib_name', lib_names) for lib_dict in cm.listify(lib_dicts): @@ -132,11 +147,11 @@ class HdlConfig: use_libs = self.derive_all_use_libs(lib_name) lib_order = self.derive_lib_order(use_libs) file_name = 'hdllib_order.txt' - file_path = self.get_lib_build_sim_dirs(lib_dict) + file_path = self.get_lib_build_dirs('sim', lib_dicts=lib_dict) cm.mkdir(file_path) filePathName = os.path.join(file_path, file_name) with open(filePathName, 'w') as fp: - for lib in lib_order: + for lib in lib_order: fp.write('%s\n' % lib) if __name__ == '__main__': @@ -173,13 +188,9 @@ if __name__ == '__main__': print 'derive_lib_order : ', hdl.derive_lib_order() print '' - print 'get_lib_build_sim_dirs:' - for sim_dir in hdl.get_lib_build_sim_dirs(): + print 'get_lib_build_dirs for simulation:' + for sim_dir in hdl.get_lib_build_dirs('sim'): print ' ', sim_dir - - print '' - print 'create_lib_order_files' - hdl.create_lib_order_files() print '' if libRootDir=='RADIOHDL': diff --git a/tools/oneclick/base/modelsim_config.py b/tools/oneclick/base/modelsim_config.py index 81c7f2820779d7848d59d832d8e9f5cab2f6c7e7..4655802c611c2288a58853d8d190364ff32a670e 100644 --- a/tools/oneclick/base/modelsim_config.py +++ b/tools/oneclick/base/modelsim_config.py @@ -71,7 +71,7 @@ class ModelsimConfig(hdl_config.HdlConfig): # Open mpf lib_name = lib_dict['hdl_lib_name'] mpf_name = lib_name + '.mpf' - mpf_path = self.get_lib_build_sim_dirs(lib_dict) + mpf_path = self.get_lib_build_dirs('sim', lib_dicts=lib_dict) cm.mkdir(mpf_path) mpfPathName = os.path.join(mpf_path, mpf_name) with open(mpfPathName, 'w') as fp: @@ -79,7 +79,7 @@ class ModelsimConfig(hdl_config.HdlConfig): fp.write('[Library]\n') use_lib_names = self.derive_all_use_libs(lib_name) use_lib_dicts = self.libs.get_dicts('hdl_lib_name', use_lib_names) - use_lib_build_sim_dirs = self.get_lib_build_sim_dirs(use_lib_dicts) + use_lib_build_sim_dirs = self.get_lib_build_dirs('sim', lib_dicts=use_lib_dicts) use_lib_clause_names = self.libs.get_key_values('hdl_library_clause_name', use_lib_dicts) for lib_clause, lib_dir in zip(cm.listify(use_lib_clause_names), cm.listify(use_lib_build_sim_dirs)): lib_work = os.path.join(lib_dir, 'work') @@ -143,7 +143,7 @@ class ModelsimConfig(hdl_config.HdlConfig): if lib_names==None: lib_names=self.lib_names with open(fileNamePath, 'w') as fp: lib_dicts = self.libs.get_dicts('hdl_lib_name', lib_names) - mpf_paths = self.get_lib_build_sim_dirs(lib_dicts) + mpf_paths = self.get_lib_build_dirs('sim', lib_dicts=lib_dicts) for lib, path in zip(cm.listify(lib_names),cm.listify(mpf_paths)): fp.write('%s = %s\n' % (lib, path)) @@ -157,15 +157,25 @@ if __name__ == '__main__': print '#' print '# ModelsimConfig:' print '#' - print 'derive_lib_order = ', msim.derive_lib_order() + print 'Derive library compile order = ', msim.derive_lib_order() + + print '' + print 'get_lib_build_dirs for simulation:' + for sim_dir in msim.get_lib_build_dirs('sim'): + print ' ', sim_dir + + print '' + print 'Create library compile order files.' + msim.create_lib_order_files() + print '' print 'Create modelsim projects list file.' msim.create_modelsim_project_files_file() - + print '' print 'Create modelsim project files for all HDL libraries in $%s.' % libRootDir msim.create_modelsim_project_file() - + # Use save_compile_order_in_mpf = True to avoid having to manually edit the compile order in the hdllib.cfg, because # the synth_files need to be in hierarchical order. The test_bench_files are typically independent so these may be # put in alphabetical order. The hdllib.cfg still does need some manual editing to set the proper key and paths.