diff --git a/tools/oneclick/base/hdl_config.py b/tools/oneclick/base/hdl_config.py index d73dd069201810acc8ab93d4fc4682d75daff5c6..c4536ea9866cf9a61bf16b925b7d73a22e121f2c 100644 --- a/tools/oneclick/base/hdl_config.py +++ b/tools/oneclick/base/hdl_config.py @@ -58,7 +58,7 @@ import argparse class HdlConfig: - def __init__(self, toolRootDir, libFileName='hdllib.cfg', toolFileName='hdltool_<toolset>.cfg'): + def __init__(self, toolRootDir, libFileName='hdllib.cfg', libFileSections=None, toolFileName='hdltool_<toolset>.cfg'): """Get tool dictionary info from toolRootDir and all HDL library dictionary info for it - self.tool.dicts = single dictionary that contains the tool info (only one tool dict in dicts list) @@ -76,27 +76,24 @@ class HdlConfig: self.toolRootDir = toolRootDir # HDL tool config file - self.tool = common_dict_file.CommonDictFile(toolRootDir, toolFileName) # tool dict file + self.tool = common_dict_file.CommonDictFile(toolRootDir, toolFileName) # tool dict filedupkc if self.tool.nof_dicts==0: sys.exit('Error : No HDL tool config file found') if self.tool.nof_dicts >1: sys.exit('Error : Multiple HDL tool config files found') self.tool_dict = self.tool.dicts[0] # there is only one tool dict in dicts list so for convenience make it also accessible as self.tool_dict # HDL library config files self.libRootDir = os.path.expandvars(self.tool_dict['lib_root_dir']) - self.libs = common_dict_file.CommonDictFile(self.libRootDir, libFileName) # library dict files + self.libs = common_dict_file.CommonDictFile(self.libRootDir, libFileName, libFileSections) # library dict files if self.libs.nof_dicts==0: sys.exit('Error : No HDL library config file found') # Keep the generic HDL libraries and remove those that do not match the specified IP technologies - self.technologyNames = os.path.expandvars(self.tool_dict['technology_names']) + self.technologyNames = self.tool_dict['technology_names'].split() self.removed_dicts = [] print 'self.technologyNames=',self.technologyNames if len(self.technologyNames)>0: for d in self.libs.dicts: - #if not(d['hdl_lib_technology']=='' or d['hdl_lib_technology'] in self.technologyNames): - #print 'd[hdl_lib_technology]=',d['hdl_lib_technology'] - if not(d['hdl_lib_technology']=='' or d['hdl_lib_technology'] == self.technologyNames): + if not(d['hdl_lib_technology']=='' or d['hdl_lib_technology'] in self.technologyNames): self.removed_dicts.append(d) - #print 'remove=',d for d in self.removed_dicts: self.libs.remove_dict_from_list(d) @@ -105,7 +102,15 @@ class HdlConfig: # Check that there are no duplicate library names (eg. due to copying a hdlib.cfg without modifying the hdl_lib_name value) duplicate_lib_names = cm.list_duplicates(self.lib_names) - if len(duplicate_lib_names)>0: sys.exit('Error : Duplicate HDL library config file found %s' % duplicate_lib_names) + if len(duplicate_lib_names)>0: + for dup_name in duplicate_lib_names: + dup_dicts = self.libs.get_dicts('hdl_lib_name', values=dup_name) + for d in dup_dicts: + self.libs.remove_dict_from_list(d) + print 'Warning : Duplicate HDL library config files found and removed from list %s' % duplicate_lib_names + # Update list of HDL library names + self.lib_names = self.libs.get_key_values('hdl_lib_name') + def get_used_libs(self, build_type, lib_dict, arg_exclude_libs=[]): """Get the list of used HDL libraries from the lib_dict and remove the excluded libs. @@ -152,7 +157,6 @@ class HdlConfig: # use recursion to include all used libs use_libs, exclude_libs = self.get_used_libs(build_type, lib_dict, exclude_libs) try: - use_libs for use_lib in use_libs: if use_lib in self.lib_names: all_use_libs.append(use_lib) @@ -337,7 +341,7 @@ if __name__ == '__main__': # Parse command line arguments toolsetSelect = ['unb1', 'unb2', 'unb2a'] - argparser = argparse.ArgumentParser(description='Create Modelsim mpf files for all hdllib.cfg') + argparser = argparse.ArgumentParser(description='Derive HDL library dictionary from hdllib.cfg') argparser.add_argument('-t','--toolset', help='choose toolset %s (default: %s)' % (toolsetSelect,toolsetSelect[0]), default=toolsetSelect[0], required=False) argparser.add_argument('-v','--verbosity', help='verbosity >= 0 for more info', type=int, default=0, required=False) args = vars(argparser.parse_args()) @@ -364,22 +368,30 @@ if __name__ == '__main__': print '' print '' - print 'tool = ', hdl.tool.filePathNames[0] + print 'Toolset file = ', hdl.tool.filePathNames[0] print '' - print 'lib paths' + print 'Library paths :' for p in hdl.libs.filePaths: print ' ', p print '' - print 'lib paths names' + print 'Library paths names :"' for p in hdl.libs.filePathNames: print ' ', p print '' - print 'lib_names = ', hdl.lib_names - print 'derive_lib_order for sim : ', hdl.derive_lib_order('sim') - print 'derive_lib_order for synth : ', hdl.derive_lib_order('synth') + print 'Library section headers :' + for lib_name in hdl.lib_names: + lib_dict = hdl.libs.dicts[hdl.lib_names.index(lib_name)] + print ' %-52s :' % lib_name, lib_dict['section_headers'] + + print '' + print 'Library names = \n', hdl.lib_names + print '' + print 'derive_lib_order for sim :\n', hdl.derive_lib_order('sim') + print '' + print 'derive_lib_order for synth :\n', hdl.derive_lib_order('synth') print '' print 'get_lib_build_dirs for simulation:' @@ -393,15 +405,19 @@ if __name__ == '__main__': #use_libs = hdl.derive_all_use_libs('sim', 'tech_xaui') use_libs = hdl.derive_all_use_libs('sim', 'unb1_test_10GbE') use_libs = hdl.derive_all_use_libs('sim', 'tech_ddr') - print 'derive_all_use_libs = ', use_libs + print '' + print 'derive_all_use_libs = \n', use_libs lib_order = hdl.derive_lib_order('sim', use_libs) - print 'derive_lib_order = ', lib_order + print '' + print 'derive_lib_order = \n', lib_order if hdl.libRootDir=='UNB': use_libs = hdl.derive_all_use_libs('sim', 'unb_minimal') use_libs = hdl.derive_all_use_libs('sim', 'dp') - print 'derive_all_use_libs = ', use_libs + print '' + print 'derive_all_use_libs = \n', use_libs lib_order = hdl.derive_lib_order('sim', use_libs) - print 'derive_lib_order = ', lib_order + print '' + print 'derive_lib_order = \n', lib_order if mode==1: key = 'build_dir'