diff --git a/tools/oneclick/base/modelsim_config.py b/tools/oneclick/base/modelsim_config.py index db52b380eb75d72bc54bdda046a7dcc69aaec110..a59fc97512e25aeb124ba8ec7bdc103b2b405a47 100644 --- a/tools/oneclick/base/modelsim_config.py +++ b/tools/oneclick/base/modelsim_config.py @@ -63,7 +63,7 @@ class ModelsimConfig(hdl_config.HdlConfig): compile_order[k]=project_file_name return compile_order - def create_modelsim_project_file(self, lib_names=None): + def create_modelsim_project_file(self, technology_name, lib_names=None): """Create the Modelsim project 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) @@ -75,8 +75,13 @@ class ModelsimConfig(hdl_config.HdlConfig): cm.mkdir(mpf_path) mpfPathName = os.path.join(mpf_path, mpf_name) with open(mpfPathName, 'w') as fp: - # Write [Library] section for afileNamell used libraries + # Write [Library] section for all used libraries fp.write('[Library]\n') + # . technology libs + tech_dict = self.read_modelsim_technology_libraries_file(technology_name) + for lib_clause, lib_work in tech_dict.iteritems(): + fp.write('%s = %s\n' % (lib_clause, lib_work)) + # . all used libs for this lib_name 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_dirs('sim', lib_dicts=use_lib_dicts) @@ -84,7 +89,9 @@ class ModelsimConfig(hdl_config.HdlConfig): 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') fp.write('%s = %s\n' % (lib_clause, lib_work)) + # . work fp.write('work = work\n') + # . others model_tech_dir = os.path.expandvars(self.tool.get_key_values('model_tech_dir')) fp.write('others = %s\n' % os.path.join(model_tech_dir, 'modelsim.ini')) # Write [Project] section for all used libraries @@ -141,9 +148,23 @@ class ModelsimConfig(hdl_config.HdlConfig): fp.write('IterationLimit = 100\n') fp.write('DefaultRadix = decimal\n') - def create_modelsim_project_files_file(self, fileNamePath=None, lib_names=None): + def read_modelsim_technology_libraries_file(self, technologyName, filePath=None): + """Read the list of technology libraries from a file.""" + fileName = 'modelsim_libraries_' + technologyName + '.txt' # use fixed file name format + if filePath==None: + fileNamePath=os.path.join(self.toolRootDir, 'modelsim', fileName) # default file path + else: + fileNamePath=os.path.join(filePath, fileName) # specified file path + tech_dict = self.tool.read_dict_file(fileNamePath) + return tech_dict + + def create_modelsim_project_files_file(self, filePath=None, lib_names=None): """Create file with list of the Modelsim project files for all HDL libraries in the specified list of lib_names.""" - if fileNamePath==None: fileNamePath=os.path.join(self.toolRootDir, 'modelsim', 'modelsim_project_files.txt') + fileName = 'modelsim_project_files.txt' # use fixed file name + if filePath==None: + fileNamePath=os.path.join(self.toolRootDir, 'modelsim', fileName) # default file path + else: + fileNamePath=os.path.join(filePath, fileName) # specified file path 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) @@ -156,6 +177,7 @@ if __name__ == '__main__': # Read the dictionary info from all HDL tool and library configuration files in the current directory and the sub directories libRootDir = 'RADIOHDL' #libRootDir = 'UNB' + technology_name = 'altera' msim = ModelsimConfig(libRootDir=os.environ[libRootDir], toolRootDir=os.path.expandvars('$RADIOHDL/tools'), libFileName='hdllib.cfg', toolFileName='hdltool.cfg') print '#' @@ -177,8 +199,8 @@ if __name__ == '__main__': msim.create_modelsim_project_files_file() print '' - print 'Create modelsim project files for all HDL libraries in $%s.' % libRootDir - msim.create_modelsim_project_file() + print 'Create modelsim project files for technology %s and all HDL libraries in $%s.' % (technology_name, libRootDir) + msim.create_modelsim_project_file(technology_name) # 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