Skip to content
Snippets Groups Projects
Commit 073b1337 authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Corrected derive_lib_order(), it now uses recursion to keep on reordering the...

Corrected derive_lib_order(), it now uses recursion to keep on reordering the lib_order until it is stable.
parent b774ec78
No related branches found
No related tags found
No related merge requests found
...@@ -67,41 +67,46 @@ class HdlConfig: ...@@ -67,41 +67,46 @@ class HdlConfig:
self.libs = common_dict_file.CommonDictFile(libRootDir, libFileName) # library dict files self.libs = common_dict_file.CommonDictFile(libRootDir, libFileName) # library dict files
if self.libs.nof_dicts==0: sys.exit('Error : No HDL library config file found') if self.libs.nof_dicts==0: sys.exit('Error : No HDL library config file found')
self.lib_names = self.libs.get_key_values('hdl_lib_name') self.lib_names = self.libs.get_key_values('hdl_lib_name')
self.MODELSIM_MPF_NAME = 'hdllib.mpf'
def derive_all_use_libs(self, lib_name): def derive_all_use_libs(self, lib_name):
"""Derive a list of all HDL libraries that the specified HDL lib_name library depends on.""" """Derive a list of all HDL libraries that the specified HDL lib_name library depends on."""
if lib_name in self.lib_names: if lib_name in self.lib_names:
all_use_libs = [lib_name] all_use_libs = [lib_name]
lib_dict = self.libs.dicts[self.lib_names.index(lib_name)] lib_dict = self.libs.dicts[self.lib_names.index(lib_name)]
# use recursion to include all used libs
if 'hdl_lib_uses' in lib_dict: if 'hdl_lib_uses' in lib_dict:
use_libs = lib_dict['hdl_lib_uses'].split() use_libs = lib_dict['hdl_lib_uses'].split()
for use_lib in use_libs: for use_lib in use_libs:
all_use_libs.append(use_lib) all_use_libs.append(use_lib)
all_use_libs += self.derive_all_use_libs(use_lib) all_use_libs += self.derive_all_use_libs(use_lib)
# remove all duplicates from the list
return cm.unique(all_use_libs) return cm.unique(all_use_libs)
else: else:
sys.exit('Error : Unknown HDL library name') sys.exit('Error : Unknown HDL library name')
def derive_lib_order(self, lib_names=None): def derive_lib_order(self, lib_names=None):
"""Derive the dependency order for all HDL libraries in the specified list of lib_names.""" """Derive the dependency order for all HDL libraries in the fully specified list of lib_names.
Note:
The lib_names list must include all used libs, so if necessary first call derive_all_use_libs().
"""
if lib_names==None: lib_names=self.lib_names if lib_names==None: lib_names=self.lib_names
lib_dicts = self.libs.get_dicts('hdl_lib_name', lib_names) lib_dicts = self.libs.get_dicts('hdl_lib_name', lib_names)
lib_order = [] # use list() to take local copy to avoid modifying list order of self.lib_names which matches self.libs.dicts list order
lib_order = list(lib_names)
for lib_dict in cm.listify(lib_dicts): for lib_dict in cm.listify(lib_dicts):
lib_name = lib_dict['hdl_lib_name'] lib_name = lib_dict['hdl_lib_name']
if not lib_name in lib_order:
lib_order.append(lib_name) # append this lib
if 'hdl_lib_uses' in lib_dict: if 'hdl_lib_uses' in lib_dict:
use_libs = lib_dict['hdl_lib_uses'].split() use_libs = lib_dict['hdl_lib_uses'].split()
for use_lib in use_libs: for use_lib in use_libs:
if not use_lib in lib_order: if lib_order.index(use_lib) > lib_order.index(lib_name):
lib_order.insert(lib_order.index(lib_name), use_lib) # insert used lib just before this lib lib_order.remove(use_lib)
else: lib_order.insert(lib_order.index(lib_name), use_lib) # move used lib to just before this lib
if lib_order.index(use_lib) > lib_order.index(lib_name): # use recursion to keep on reordering the lib_order until it is stable
lib_order.remove(use_lib) if lib_names != lib_order:
lib_order.insert(lib_order.index(lib_name), use_lib) # move used lib to just before this lib lib_order = self.derive_lib_order(lib_order)
return lib_order return lib_order
def get_lib_build_dirs(self, build_type, build_subdir=None, lib_dicts=None): 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. """Get the tool build directory for all HDL libraries in the specified list of lib_dicts.
...@@ -194,10 +199,14 @@ if __name__ == '__main__': ...@@ -194,10 +199,14 @@ if __name__ == '__main__':
print '' print ''
if libRootDir=='RADIOHDL': if libRootDir=='RADIOHDL':
print 'derive_all_use_libs = ', hdl.derive_lib_order(hdl.derive_all_use_libs('technology_memory')) #print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('tech_memory'))
#print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('numonyx_m25p128'))
#print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('ip_stratixiv'))
#print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('tech_flash'))
print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('epcs'))
if libRootDir=='UNB': if libRootDir=='UNB':
print 'derive_all_use_libs = ', hdl.derive_lib_order(hdl.derive_all_use_libs('dp')) print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('dp'))
print 'derive_all_use_libs = ', hdl.derive_lib_order(hdl.derive_all_use_libs('uth')) print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('uth'))
print 'derive_all_use_libs = ', hdl.derive_lib_order(hdl.derive_all_use_libs('unb_common')) print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('unb_common'))
print 'derive_all_use_libs = ', hdl.derive_lib_order(hdl.derive_all_use_libs('unb_minimal')) print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('unb_minimal'))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment