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

Added more documentation text. Clarified the used files that are read or written.

parent 181a3a6b
No related branches found
No related tags found
No related merge requests found
......@@ -144,7 +144,10 @@ class HdlConfig:
return cm.unlistify(build_dirs)
def create_lib_order_files(self, lib_names=None):
"""Create the compile order 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.
The file is stored in the sim build directory of the HDL library.
"""
if lib_names==None: lib_names=self.lib_names
lib_dicts = self.libs.get_dicts('hdl_lib_name', lib_names)
for lib_dict in cm.listify(lib_dicts):
......
......@@ -31,12 +31,44 @@ import os.path
class ModelsimConfig(hdl_config.HdlConfig):
def __init__(self, libRootDir, toolRootDir, libFileName='hdllib.cfg', toolFileName='hdltool.cfg'):
"""Get Modelsim tool info from toolRootDir and all HDL library info from libRootDir."""
"""Get Modelsim tool info from toolRootDir and all HDL library info from libRootDir.
Arguments:
- libRootDir : Root directory from where the hdllib.cfg files are searched for.
- toolRootDir : Root directory from where the hdltool.cfg file is searched for.
- libFileName : Default HDL library configuration file name
- toolFileName : Default HDL tools configuration file name
Files:
- hdltool.cfg : HDL tool configuration dictionary file. One central file.
- hdllib.cfg : HDL library configuration dictionary file. One file for each HDL library.
- modelsim_libraries_<technologyName>.txt : Dictionary file with the technology libraries for the FPGA device that
come with the synthesis tool. The keys are the library names and the values are the paths. The file needs to be
created manually and can be read by read_modelsim_technology_libraries_file().
- modelsim_project_files.txt
The modelsim_project_files.txt file is a dictionary file with the list the Modelsim project files for all HDL
libraries that were found in the libRootDir. The keys are the library names and the values are the paths to the
corresponding modelsim project files. The modelsim_project_files.txt file is created by
create_modelsim_project_files_file() and is read by the TCL commands.do file in Modelsim. Creating the file in
Python and then reading this in TCL makes the commands.do much simpler.
- <lib_name>.mpf : Modelsim project file for a certain HDL library based on the hdllib.cfg. The file is created by
create_modelsim_project_file().
- <lib_name>_lib_order.txt
The <lib_name>_lib_order.txt file contains the library compile order for a certain HDL library. The files are
created by create_lib_order_files() in the same build directory as where the Modelsim project file is stored.
The <lib_name>_lib_order.txt files are read by the TCL commands.do file in Modelsim. Creating the files in Python
and then reading them in TCL makes the commands.do much simpler.
"""
hdl_config.HdlConfig.__init__(self, libRootDir, toolRootDir, libFileName, toolFileName)
# Modelsim
def read_compile_order_from_mpf(self, mpfPathName):
"""Utility to read the compile order of the project files from an existing <mpfPathName>.mpf and save it into hdl_order.out."""
"""Utility to read the compile order of the project files from an existing <mpfPathName>.mpf."""
# read <mpfPathName>.mpf to find all project files
project_file_indices = []
project_file_names = []
......@@ -63,8 +95,13 @@ class ModelsimConfig(hdl_config.HdlConfig):
compile_order[k]=project_file_name
return compile_order
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."""
def create_modelsim_project_file(self, technologyName, lib_names=None):
"""Create the Modelsim project file for all technology libraries and RTL HDL libraries.
Arguments:
- technologyName : refers to the modelsim_libraries_<technologyName>.txt file.
- lib_names : one or more HDL libraries
"""
if lib_names==None: lib_names=self.lib_names
lib_dicts = self.libs.get_dicts('hdl_lib_name', lib_names)
for lib_dict in cm.listify(lib_dicts):
......@@ -78,7 +115,7 @@ class ModelsimConfig(hdl_config.HdlConfig):
# Write [Library] section for all used libraries
fp.write('[Library]\n')
# . vendor technology libs
tech_dict = self.read_modelsim_technology_libraries_file(technology_name)
tech_dict = self.read_modelsim_technology_libraries_file(technologyName)
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
......@@ -152,7 +189,13 @@ class ModelsimConfig(hdl_config.HdlConfig):
fp.write('DefaultRadix = decimal\n')
def read_modelsim_technology_libraries_file(self, technologyName, filePath=None):
"""Read the list of technology libraries from a file."""
"""Read the list of technology libraries from a file.
Arguments:
- technologyName : refers to the modelsim_libraries_<technologyName>.txt file
- filePath : path to modelsim_libraries_<technologyName>.txt, when None then the file is
read in the default toolRootDir
"""
fileName = 'modelsim_libraries_' + technologyName + '.txt' # use fixed file name format
if filePath==None:
fileNamePath=os.path.join(self.toolRootDir, 'modelsim', fileName) # default file path
......@@ -162,7 +205,12 @@ class ModelsimConfig(hdl_config.HdlConfig):
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.
Arguments:
- filePath : path to modelsim_project_files.txt, when None then the file is written in the default toolRootDir
- lib_names : one or more HDL libraries
"""
fileName = 'modelsim_project_files.txt' # use fixed file name
if filePath==None:
fileNamePath=os.path.join(self.toolRootDir, 'modelsim', fileName) # default file path
......@@ -180,7 +228,7 @@ if __name__ == '__main__':
# Read the dictionary info from all HDL tool and library configuration files in the current directory and the sub directories
libRootDir = 'RADIOHDL'
#libRootDir = 'UNB'
technology_name = 'stratixiv'
technologyName = 'stratixiv'
msim = ModelsimConfig(libRootDir=os.environ[libRootDir], toolRootDir=os.path.expandvars('$RADIOHDL/tools'), libFileName='hdllib.cfg', toolFileName='hdltool.cfg')
print '#'
......@@ -208,8 +256,8 @@ if __name__ == '__main__':
msim.create_modelsim_project_files_file()
print ''
print 'Create modelsim project files for technology %s and all HDL libraries in $%s.' % (technology_name, libRootDir)
msim.create_modelsim_project_file(technology_name)
print 'Create modelsim project files for technology %s and all HDL libraries in $%s.' % (technologyName, libRootDir)
msim.create_modelsim_project_file(technologyName)
# 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
......
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