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

Renamed get_lib_build_sim_dirs() into get_lib_build_dirs() and distinguish...

Renamed get_lib_build_sim_dirs() into get_lib_build_dirs() and distinguish separate keys for build_sim_dir and build_synth_dir.
parent b199208d
No related branches found
No related tags found
No related merge requests found
...@@ -103,28 +103,43 @@ class HdlConfig: ...@@ -103,28 +103,43 @@ class HdlConfig:
lib_order.insert(lib_order.index(lib_name), use_lib) # move used lib to just before this lib lib_order.insert(lib_order.index(lib_name), use_lib) # move used lib to just before this lib
return lib_order return lib_order
def get_lib_build_sim_dirs(self, lib_dicts=None): def get_lib_build_dirs(self, build_type, build_subdir=None, lib_dicts=None):
"""Get the simulation 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.
If key 'build_dir' in HDL library config file is '' then The build_type can be:
define build dir by 'sim_tool_name' local to current HDL library directory. '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 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 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): 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_key, 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')
if build_dir=='': 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: else:
sim_dirs.append(os.path.join(lib_path, build_dir, sim_tool_name)) lib_name = lib_dict['hdl_lib_name']
return cm.unlistify(sim_dirs) 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): 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 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)
for lib_dict in cm.listify(lib_dicts): for lib_dict in cm.listify(lib_dicts):
...@@ -132,11 +147,11 @@ class HdlConfig: ...@@ -132,11 +147,11 @@ class HdlConfig:
use_libs = self.derive_all_use_libs(lib_name) use_libs = self.derive_all_use_libs(lib_name)
lib_order = self.derive_lib_order(use_libs) lib_order = self.derive_lib_order(use_libs)
file_name = 'hdllib_order.txt' 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) cm.mkdir(file_path)
filePathName = os.path.join(file_path, file_name) filePathName = os.path.join(file_path, file_name)
with open(filePathName, 'w') as fp: with open(filePathName, 'w') as fp:
for lib in lib_order: for lib in lib_order:
fp.write('%s\n' % lib) fp.write('%s\n' % lib)
if __name__ == '__main__': if __name__ == '__main__':
...@@ -173,13 +188,9 @@ if __name__ == '__main__': ...@@ -173,13 +188,9 @@ if __name__ == '__main__':
print 'derive_lib_order : ', hdl.derive_lib_order() print 'derive_lib_order : ', hdl.derive_lib_order()
print '' print ''
print 'get_lib_build_sim_dirs:' print 'get_lib_build_dirs for simulation:'
for sim_dir in hdl.get_lib_build_sim_dirs(): for sim_dir in hdl.get_lib_build_dirs('sim'):
print ' ', sim_dir print ' ', sim_dir
print ''
print 'create_lib_order_files'
hdl.create_lib_order_files()
print '' print ''
if libRootDir=='RADIOHDL': if libRootDir=='RADIOHDL':
......
...@@ -71,7 +71,7 @@ class ModelsimConfig(hdl_config.HdlConfig): ...@@ -71,7 +71,7 @@ class ModelsimConfig(hdl_config.HdlConfig):
# Open mpf # Open mpf
lib_name = lib_dict['hdl_lib_name'] lib_name = lib_dict['hdl_lib_name']
mpf_name = lib_name + '.mpf' 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) cm.mkdir(mpf_path)
mpfPathName = os.path.join(mpf_path, mpf_name) mpfPathName = os.path.join(mpf_path, mpf_name)
with open(mpfPathName, 'w') as fp: with open(mpfPathName, 'w') as fp:
...@@ -79,7 +79,7 @@ class ModelsimConfig(hdl_config.HdlConfig): ...@@ -79,7 +79,7 @@ class ModelsimConfig(hdl_config.HdlConfig):
fp.write('[Library]\n') fp.write('[Library]\n')
use_lib_names = self.derive_all_use_libs(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_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) 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)): 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') lib_work = os.path.join(lib_dir, 'work')
...@@ -143,7 +143,7 @@ class ModelsimConfig(hdl_config.HdlConfig): ...@@ -143,7 +143,7 @@ class ModelsimConfig(hdl_config.HdlConfig):
if lib_names==None: lib_names=self.lib_names if lib_names==None: lib_names=self.lib_names
with open(fileNamePath, 'w') as fp: with open(fileNamePath, 'w') as fp:
lib_dicts = self.libs.get_dicts('hdl_lib_name', lib_names) 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)): for lib, path in zip(cm.listify(lib_names),cm.listify(mpf_paths)):
fp.write('%s = %s\n' % (lib, path)) fp.write('%s = %s\n' % (lib, path))
...@@ -157,15 +157,25 @@ if __name__ == '__main__': ...@@ -157,15 +157,25 @@ if __name__ == '__main__':
print '#' print '#'
print '# ModelsimConfig:' print '# ModelsimConfig:'
print '#' 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 ''
print 'Create modelsim projects list file.' print 'Create modelsim projects list file.'
msim.create_modelsim_project_files_file() msim.create_modelsim_project_files_file()
print '' print ''
print 'Create modelsim project files for all HDL libraries in $%s.' % libRootDir print 'Create modelsim project files for all HDL libraries in $%s.' % libRootDir
msim.create_modelsim_project_file() 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 # 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 # 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. # put in alphabetical order. The hdllib.cfg still does need some manual editing to set the proper key and paths.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment