def __init__(self, toolRootDir, libFileName='hdllib.cfg', 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) - self.libs.dicts = list of dictionaries that contains the info of the HDL libraries. The libRootDir parameter is defined in the hdltool_<toolset>.cfg file and is the root directory from where the hdllib.cfg files are searched for. The technologyNames parameter is defined in the hdltool_<toolset>.cfg file. All generic HDL libraries and these technology specific libraries are kept. If technologyNames is: [] : Keep all HDL libraries that were found. ['ip_stratixiv', 'ip_arria10'] : The HDL libraries with a hdl_lib_technology that is not '' or does not match one of the technologies in technologyNames are removed from the list of HDL library dictionaries. """ self.toolRootDir = toolRootDir # HDL tool config file self.tool = common_dict_file.CommonDictFile(toolRootDir, toolFileName) # tool dict file 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 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.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): self.removed_dicts.append(d) #print 'remove=',d for d in self.removed_dicts: self.libs.remove_dict_from_list(d) # Keep list of HDL library names self.lib_names = self.libs.get_key_values('hdl_lib_name') # 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)
def MaxDecodingNonUniq ( F ): """ F is a list of max marginal factors passed in. We don't assume that there is a unique max value. So we get the indices of the non-uniq max value as a tuple and add it to """ ASSIGNMENTS=[] for f in F: values=f.getVal().tolist() maxvalue=max(values) """ if the maxvalue is duplicated, we get the indices of where it resides in the value array """ if common.isMaxDuplicated(values): dup_indices_list=[dup for dup in sorted(common.list_duplicates(values)) ] dup_values= [ x for (x, y) in dup_indices_list ] dup_indices= [ y for (x, y) in dup_indices_list ] non_uniq_max_indices=tuple(dup_indices [ dup_values.index(maxvalue) ]) ASSIGNMENTS.append ( non_uniq_max_indices ) else: ASSIGNMENTS.append( values.index(maxvalue)) return ASSIGNMENTS
def MaxDecodingNonUniq(F): """ F is a list of max marginal factors passed in. We don't assume that there is a unique max value. So we get the indices of the non-uniq max value as a tuple and add it to """ ASSIGNMENTS = [] for f in F: values = f.getVal().tolist() maxvalue = max(values) """ if the maxvalue is duplicated, we get the indices of where it resides in the value array """ if common.isMaxDuplicated(values): dup_indices_list = [ dup for dup in sorted(common.list_duplicates(values)) ] dup_values = [x for (x, y) in dup_indices_list] dup_indices = [y for (x, y) in dup_indices_list] non_uniq_max_indices = tuple( dup_indices[dup_values.index(maxvalue)]) ASSIGNMENTS.append(non_uniq_max_indices) else: ASSIGNMENTS.append(values.index(maxvalue)) return ASSIGNMENTS