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

Added read_modelsim_technology_libraries_file() to be able to add the...

Added read_modelsim_technology_libraries_file() to be able to add the technolgy libraries to the mpf.
parent 97175962
No related branches found
No related tags found
No related merge requests found
...@@ -63,7 +63,7 @@ class ModelsimConfig(hdl_config.HdlConfig): ...@@ -63,7 +63,7 @@ class ModelsimConfig(hdl_config.HdlConfig):
compile_order[k]=project_file_name compile_order[k]=project_file_name
return compile_order 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.""" """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 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)
...@@ -75,8 +75,13 @@ class ModelsimConfig(hdl_config.HdlConfig): ...@@ -75,8 +75,13 @@ class ModelsimConfig(hdl_config.HdlConfig):
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:
# Write [Library] section for afileNamell used libraries # Write [Library] section for all used libraries
fp.write('[Library]\n') 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_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_dirs('sim', lib_dicts=use_lib_dicts) 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): ...@@ -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)): 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')
fp.write('%s = %s\n' % (lib_clause, lib_work)) fp.write('%s = %s\n' % (lib_clause, lib_work))
# . work
fp.write('work = work\n') fp.write('work = work\n')
# . others
model_tech_dir = os.path.expandvars(self.tool.get_key_values('model_tech_dir')) 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')) fp.write('others = %s\n' % os.path.join(model_tech_dir, 'modelsim.ini'))
# Write [Project] section for all used libraries # Write [Project] section for all used libraries
...@@ -141,9 +148,23 @@ class ModelsimConfig(hdl_config.HdlConfig): ...@@ -141,9 +148,23 @@ class ModelsimConfig(hdl_config.HdlConfig):
fp.write('IterationLimit = 100\n') fp.write('IterationLimit = 100\n')
fp.write('DefaultRadix = decimal\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.""" """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 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)
...@@ -156,6 +177,7 @@ if __name__ == '__main__': ...@@ -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 # Read the dictionary info from all HDL tool and library configuration files in the current directory and the sub directories
libRootDir = 'RADIOHDL' libRootDir = 'RADIOHDL'
#libRootDir = 'UNB' #libRootDir = 'UNB'
technology_name = 'altera'
msim = ModelsimConfig(libRootDir=os.environ[libRootDir], toolRootDir=os.path.expandvars('$RADIOHDL/tools'), libFileName='hdllib.cfg', toolFileName='hdltool.cfg') msim = ModelsimConfig(libRootDir=os.environ[libRootDir], toolRootDir=os.path.expandvars('$RADIOHDL/tools'), libFileName='hdllib.cfg', toolFileName='hdltool.cfg')
print '#' print '#'
...@@ -177,8 +199,8 @@ if __name__ == '__main__': ...@@ -177,8 +199,8 @@ if __name__ == '__main__':
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 technology %s and all HDL libraries in $%s.' % (technology_name, libRootDir)
msim.create_modelsim_project_file() 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 # 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment