Skip to content
Snippets Groups Projects
Commit 8a2a7c4b authored by Pieter Donker's avatar Pieter Donker
Browse files

backup after debug sesion

parent 57d12804
No related branches found
No related tags found
No related merge requests found
Showing
with 436 additions and 406 deletions
......@@ -24,7 +24,7 @@ qsys_paths =
[ip generation]
ip_tools = qmegawiz qsys-generate quartus_sh
qmegawiz_default_options = -silent
qsys_generate_default_options = --synthesis=VHDL --simulation=VHDL --allow-mixed-language-simulation
qsys-generate_default_options = --synthesis=VHDL --simulation=VHDL --allow-mixed-language-simulation
quartus_sh_default_options =
[user settings]
......
......@@ -28,6 +28,7 @@ from argparse import ArgumentParser
from hdl_configfile import HdlBuildset, HdlTool
from configfile import ConfigFileException
def _do_basic_key_checking(cfgfile, indent=""):
# Check that all key references are solved
print("{}Checking references...".format(indent), end=' ')
......@@ -48,11 +49,21 @@ def _do_basic_key_checking(cfgfile, indent=""):
else:
print("\n{}ERROR: The following required keys don't have a value: {}".format(indent, empty_keys))
def expand_all_vars(dir_name):
_dirname = dir_name
while '$' in _dirname:
# print(_dirname)
_dirname = expandvars(_dirname)
return _dirname
def _check_quartus_configfile(cfgfile, tool_types):
# check required dirs
for required_dir in ["quartus_rootdir", "quartus_rootdir_override", "niosdir"]:
print(" Checking {}...".format(required_dir), end=' ')
if isdir(expandvars(cfgfile[required_dir])):
if isdir(expand_all_vars(cfgfile[required_dir])):
print("OK")
else:
print("\n ERROR: path {} does not exist!".format(cfgfile[required_dir]))
......@@ -60,7 +71,7 @@ def _check_quartus_configfile(cfgfile, tool_types):
# check _paths variables
required_paths = ["{}_paths".format(tool) for tool in tool_types]
for path_key in [key for key in list(cfgfile.content.keys()) if key.endswith("_paths")]:
paths = [ expandvars(pathname) for pathname in cfgfile[path_key].replace("\t"," ").split(" ") if pathname != "" ]
paths = [expand_all_vars(pathname) for pathname in cfgfile[path_key].replace("\t", " ").split(" ") if pathname != ""]
print(" Checking {}...".format(path_key))
if not paths:
print(" no paths defined.")
......@@ -79,7 +90,7 @@ def _check_quartus_configfile(cfgfile, tool_types):
ip_tools = [tool for tool in cfgfile.ip_tools.replace("\t", " ").split(" ") if tool != '']
for ip_tool in ip_tools:
opt_key = "{}_default_options".format(ip_tool)
if not opt_key in list(cfgfile.content.keys()):
if opt_key not in list(cfgfile.content.keys()):
print(" {}: key is MISSING!".format(opt_key))
else:
print(" {}: OK".format(opt_key))
......@@ -98,6 +109,12 @@ def _check_quartus_configfile(cfgfile, tool_types):
if __name__ == '__main__':
keys = ['QUARTUS_DIR', 'ALTERA_DIR', 'MENTOR_DIR', 'MODELSIM_ALTERA_LIBS_DIR']
for key in keys:
if key not in os.environ:
print("{} not in os.environ".format(key))
# setup parser and parse the arguments.
argparser = ArgumentParser(description='Check to content of your hdl_buildset file and the corresponding hdl_tool file.')
argparser.add_argument('buildset', help="Filename like 'hdl_buildset_<buildset>.cfg'")
......@@ -112,7 +129,7 @@ if __name__ == '__main__':
# check if lib_root_dirs exist
print("Checking defined library directories...", end=' ')
lib_dirs = [ expandvars(libdir) for libdir in buildset_info.lib_root_dirs.replace("\t"," ").split(" ")
lib_dirs = [expand_all_vars(libdir) for libdir in buildset_info.lib_root_dirs.replace("\t", " ").split(" ")
if libdir != '']
wrong_dirs = []
for libdir in lib_dirs:
......@@ -128,10 +145,10 @@ if __name__ == '__main__':
toolnames = [buildset_info.synth_tool_name, buildset_info.sim_tool_name]
for toolname in toolnames:
print("Checking tool {}...".format(toolname), end=' ')
if not toolname in buildset_info.section_headers:
if toolname not in buildset_info.section_headers:
print("\n Warning: No sectionheader found.", end=' ')
tool_dir = "{}_dir".format(toolname)
if not tool_dir in list(buildset_info.content.keys()):
if tool_dir not in list(buildset_info.content.keys()):
print("\n ERROR: Key {} is missing.".format(tool_dir), end=' ')
else:
os.environ[tool_dir.upper()] = buildset_info[tool_dir]
......@@ -148,5 +165,3 @@ if __name__ == '__main__':
if toolname == "quartus":
_check_quartus_configfile(tool_info, toolnames+subtoolnames)
......@@ -29,6 +29,7 @@ def unlistify(obj):
return obj[0]
return obj
def remove_from_list_string(list_str, item_str, sep=' '):
"""Treat the string list_str as a list of items that are separated by sep and then
remove the specified item_str string from the list and return the list as a
......@@ -39,6 +40,7 @@ def remove_from_list_string(list_str, item_str, sep=' '):
_list_str.remove(item_str)
return sep.join(_list_str)
def unique(in_list):
"""
Extract unique list elements (without changing the order like set() does)
......@@ -50,6 +52,7 @@ def unique(in_list):
result.append(item)
return result
def method_name(caller_depth=0):
"""
Returns the name of the caller method.
......@@ -57,6 +60,7 @@ def method_name(caller_depth=0):
# Note: inspect.stack()[0][3] would return the name of this method.
return inspect.stack()[caller_depth+1][3]
def mkdir(path):
"""Recursively create leave directory and intermediate directories if they do not already exist."""
expand_path = os.path.expandvars(path) # support using environment variables in the file path
......@@ -64,6 +68,7 @@ def mkdir(path):
if not os.path.exists(expand_path):
os.makedirs(expand_path)
def expand_file_path_name(fpn, dir_path=''):
""" Expand environment variables in fpn to get file_path_name.
- if it is an absolute path return file_path_name else
......
......@@ -139,10 +139,9 @@ class ConfigFile(object):
# Check if all required keys are available
for required_key in self.required_keys:
if not required_key in self.__content__:
if required_key not in self.__content__:
raise ConfigFileException("configfile '%s' missing key '%s'" % (filename, required_key))
def __getattr__(self, name):
"""
Catch read-access to attributes to fetch values from the content dictionary.
......@@ -154,10 +153,12 @@ class ConfigFile(object):
if name in self.__dict__['_own_attr_']['__content__']:
return self.__dict__['_own_attr_']['__content__'][name]
print('%s object has no attribute %s' % (str(self.__class__.__name__), str(name)))
if not hasattr(self, name):
raise AttributeError("%r object has no attribute %r" % (self.__class__.__name__, name))
return getattr(self, name)
return getattr(self, name)
def __setattr__(self, name, value):
"""
......@@ -181,11 +182,11 @@ class ConfigFile(object):
"Also allow access to the information as item."
self.__setattr__(key, value)
def _add_kv_pair(self, key, value, include_in_section):
"""
Internal function for adding a key-value pair in a neat way.
"""
# print("add_kv_pair: key={}, value={}\n".format(key, value))
if not include_in_section:
return
if key.find(' ') > 0:
......@@ -223,7 +224,7 @@ class ConfigFile(object):
section_header = ln[1:section_end].strip() # new section header
self.section_headers.append(section_header)
include_section = True # default include this new section
if self.sections!=None:
if self.sections is not None:
if section_header not in self.sections:
include_section = False # skip this section
else:
......@@ -245,9 +246,9 @@ class ConfigFile(object):
if self.warnings != '':
raise ConfigFileException(self.warnings)
@property
def content(self):
# print(self.__content__)
"The content of the configfile as ordered dictionary."
return self.__content__
......@@ -256,7 +257,6 @@ class ConfigFile(object):
"Returns uniq ID (string) to identify this particular file. Fullfilename is used."
return "{}/{}".format(self.location, self.filename)
def resolve_key_references(self):
"""
Replaces in all values the references to keys (<key>) with the value of that key.
......@@ -277,7 +277,6 @@ class ConfigFile(object):
self.unresolved_refs.append("<{}>".format(reference))
return len(self.unresolved_refs) == 0
def get_value(self, key, must_exist=False):
"""
Get the value of a key. If the key does not exist and that is allowed 'None' is returned, in case the
......@@ -290,4 +289,3 @@ class ConfigFile(object):
raise ConfigFileException("Key '%s' does not exist in configfile %s/%s." % (key, self.location, self.filename))
return None
......@@ -27,6 +27,7 @@ import re
from common_radiohdl import listify
from configfile import ConfigFile, ConfigFileException
class ConfigTree(object):
def __init__(self, rootdirs, filename, sections=None):
......@@ -59,8 +60,8 @@ class ConfigTree(object):
cfgfile = self._factory_constructor("{}/{}".format(root, some_filename))
# check for duplicates
if cfgfile.ID in list(self._configfiles.keys()):
raise ConfigFileException("File with id '%s' found twice (at '%s' and '%s')" %
(cfgfile.ID, self._configfiles[cfgfile.ID].location, cfgfile.location))
raise ConfigFileException("File with id '%s' found twice (at '%s' and '%s')"
% (cfgfile.ID, self._configfiles[cfgfile.ID].location, cfgfile.location))
self._configfiles[cfgfile.ID] = cfgfile
def _factory_constructor(self, full_filename):
......@@ -81,7 +82,6 @@ class ConfigTree(object):
for cfgfileID in files_to_remove:
self._configfiles.pop(cfgfileID)
def limit_tree_to(self, files_to_keep):
"""
Limit the configfile collection in our admin to the ones given in the files_to_keep argument.
......@@ -99,7 +99,7 @@ class ConfigTree(object):
:return List of values
:raises ConfigFileException
"""
if configfiles == None:
if configfiles is None:
configfiles = self._configfiles
result = []
......@@ -107,8 +107,6 @@ class ConfigTree(object):
result.append(cfgfile.get_value(key, must_exist))
return result
def get_configfiles(self, key, values=None, user_configfiles=None):
"""
Get a list with all configfiles that contain the key with a value specified in values.
......@@ -120,6 +118,6 @@ class ConfigTree(object):
result = []
for cfgfile in file_list:
if cfgfile not in result and key in cfgfile.content:
if values == None or cfgfile.content[key] in values:
if values is None or cfgfile.content[key] in values:
result.append(cfgfile)
return result
......@@ -46,7 +46,8 @@ if __name__ == '__main__':
if rootdir != '']
lib_tree = HdlLibTree(rootdirs=root_dirs, filename="hdllib.cfg")
for key in args.keys.split(','):
print("export {}='{}'\n".format(key.lower(),
print("export {}='{}'\n".format(
key.lower(),
os.path.expandvars(lib_tree.configfiles[args.libname].get_value(key=key, must_exist=True))))
......@@ -31,6 +31,7 @@ from argparse import ArgumentParser
from hdl_configfile import HdlBuildset, HdlTool
from hdl_configtree import HdlLibTree
def run_qmegawiz(buildset, outputdir, hdllib, vhdl_files, options):
"""
Run qmegawiz for the configuration in the given hdllib.
......@@ -124,6 +125,14 @@ def run_quartus_sh(buildset, outputdir, hdllib, tcl_files, options):
return error_code
def expand_all_vars(dir_name):
_dirname = dir_name
while '$' in _dirname:
# print(_dirname)
_dirname = expandvars(_dirname)
return _dirname
if __name__ == '__main__':
# setup parser and parse the arguments.
argparser = ArgumentParser(description='Generate the IP libraries for all technologies of the given buildset')
......@@ -140,7 +149,7 @@ if __name__ == '__main__':
buildset_info.resolve_key_references()
# read in all hdllib configfiles
root_dirs = [ expandvars(rootdir) for rootdir in buildset_info.lib_root_dirs.replace("\t"," ").split(" ")
root_dirs = [expand_all_vars(rootdir) for rootdir in buildset_info.lib_root_dirs.replace("\t", " ").split(" ")
if rootdir != '']
lib_tree = HdlLibTree(rootdirs=root_dirs, filename="hdllib.cfg", sections="generate_ip_libs")
......@@ -149,7 +158,8 @@ if __name__ == '__main__':
print('tool_config_file={}'.format(tool_config_file))
tool_info = HdlTool(tool_config_file)
tool_info.resolve_key_references()
ip_tools = [ tool for tool in tool_info.ip_tools.replace("\t"," ").split(" ") if tool != '' ]
ip_tools = [tool for tool in tool_info.ip_tools.replace("\t", " ").split(" ")
if tool != '']
files_with_errors = []
for technology in listify(buildset_info.technology_names):
......@@ -168,7 +178,7 @@ if __name__ == '__main__':
print("==> Processing {} with {}".format(ip_lib_info.ID, ip_tool))
outputdir = os.path.join(os.getenv('HDL_BUILD_DIR'), '{}/{}'.format(args.buildset, ip_tool))
mkdir(outputdir)
vhdl_files = [ name for name in ip_lib_info[ip_tool_key].replace("\t"," ").split(" ") \
vhdl_files = [name for name in ip_lib_info[ip_tool_key].replace("\t", " ").split(" ")
if name != '']
if ip_tool == 'qmegawiz':
err_code = run_qmegawiz(args.buildset, outputdir, ip_lib_info, vhdl_files, tool_options)
......@@ -187,4 +197,3 @@ if __name__ == '__main__':
print(" ", files_with_errors)
else:
print("+++++ No errors during compilation! +++++\n")
......@@ -80,6 +80,3 @@ class HdlLib(ConfigFile):
def ID(self):
"Returns uniq ID (string) to identify this particular file."
return self.hdl_lib_name
......@@ -73,6 +73,3 @@ class HdlLibTree(ConfigTree):
def _factory_constructor(self, full_filename):
"Function for returning the readin configfile."
return HdlLib(full_filename)
......@@ -61,6 +61,7 @@ from hdl_configtree import HdlLibTree
__all__ = ['HdlLibrariesWizard']
class HdlLibrariesWizard:
def __init__(self, toolRootDir, toolFileName, libFileName='hdllib.cfg', libFileSections=None):
......@@ -102,8 +103,8 @@ class HdlLibrariesWizard:
- self.disclosed_library_clause_names
"""
print("HdlLibrariesWizard(toolRootDir=%s, toolFileName=%s, libFileName=%s, libFileSections=%s)" % \
(toolRootDir, toolFileName, libFileName, libFileSections))
print("HdlLibrariesWizard(toolRootDir=%s, toolFileName=%s, libFileName=%s, libFileSections=%s)"
% (toolRootDir, toolFileName, libFileName, libFileSections))
self.toolRootDir = toolRootDir # TODO almost obsolete
# read the buildset file. This file contains major information about paths, technologies, and so on
......@@ -125,6 +126,9 @@ class HdlLibrariesWizard:
# Substitute key words occurring in hdllib.cfg files with their value.
self.substitute_key_words()
self.familyNames = self.buildset['family_names'].split()
print("### self.familyNames = ", self.familyNames)
# Keep the generic HDL libraries and remove those that do not match the specified IP technologies
self.technologyNames = self.buildset['technology_names'].split()
print("### self.technologyNames = ", self.technologyNames)
......@@ -221,12 +225,12 @@ class HdlLibrariesWizard:
The list of library names can be specified via the argument lib_names, or it defaults to the list of
self.lib_names of HDL libraries that were found in the toolRootDir for the libFileName of this object.
"""
if lib_names==None: lib_names=self.lib_names
if lib_names is None:
lib_names = self.lib_names
for check_lib_name in cm.listify(check_lib_names):
if check_lib_name not in cm.listify(lib_names):
sys.exit('Error : Unknown HDL library name %s found with %s' % (check_lib_name, cm.method_name()))
def get_used_libs(self, build_type, lib_dict, arg_include_ip_libs=[]):
"""Get the list of used HDL libraries from the lib_dict that this library directly depends on, so only at this HDL library hierachy level.
......@@ -286,7 +290,6 @@ class HdlLibrariesWizard:
return use_libs, include_ip_libs
def derive_all_use_libs(self, build_type, lib_name, arg_include_ip_libs=[]):
"""Recursively derive a complete list of all HDL libraries that the specified HDL lib_name library depends on, so from this
HDL library down the entire hierachy.
......@@ -323,11 +326,10 @@ class HdlLibrariesWizard:
else:
sys.exit('Error : Unknown HDL library name %s in %s()' % (lib_name, cm.method_name()))
def derive_lib_order(self, build_type, lib_name, lib_names=None):
"""Derive the dependency order for all HDL libraries in lib_names that HDL library lib_name depends on.
"""
if lib_names==None:
if lib_names is None:
# At first entry derive the list of all HDL libraries that lib_name depends on
lib_names = self.derive_all_use_libs(build_type, lib_name)
......@@ -348,11 +350,10 @@ class HdlLibrariesWizard:
lib_order = self.derive_lib_order(build_type, lib_name, lib_order)
return lib_order
def get_lib_dicts_from_lib_names(self, lib_names=None):
"""Get list the HDL libraries lib_dicts from list of HDL libraries lib_names and preseve the library order.
"""
if lib_names==None:
if lib_names is None:
lib_names = self.lib_names
# Cannot use:
......@@ -363,14 +364,12 @@ class HdlLibrariesWizard:
lib_dicts.append(self.libs.configfiles[lib_name])
return lib_dicts
def get_lib_names_from_lib_dicts(self, lib_dicts=None):
"""Get list the HDL libraries lib_names from list of HDL libraries lib_dicts and preseve the library order.
"""
lib_names = self.libs.get_key_values('hdl_lib_name', lib_dicts)
return lib_names
def get_tool_build_dir(self, build_type):
"""Get the central tool build directory.
......@@ -418,7 +417,6 @@ class HdlLibrariesWizard:
return build_maindir, build_buildset_dir, build_tooldir, project_deeper_subdir
def get_lib_build_dirs(self, build_type, lib_dicts=None):
"""Get the subdirectories within the central tool build directory for all HDL libraries in the specified list of lib_dicts.
......@@ -433,7 +431,7 @@ class HdlLibrariesWizard:
- the library name as library subdirectory
- zero or more extra subdirectory levels to allow for relative file reference from project file location
"""
if lib_dicts==None:
if lib_dicts is None:
lib_dicts = list(self.libs.configfiles.values())
build_maindir, build_buildset_dir, build_tooldir, project_deeper_subdir = self.get_tool_build_dir(build_type)
build_dirs = []
......@@ -442,14 +440,13 @@ class HdlLibrariesWizard:
build_dirs.append(join(build_maindir, build_buildset_dir, build_tooldir, lib_name, project_deeper_subdir)) # central build main directory with subdirectory per library
return cm.unlistify(build_dirs)
def create_lib_order_files(self, build_type, lib_names=None):
"""Create the compile order file '<lib_name>_lib_order.txt' for all HDL libraries in the specified list of lib_names.
The file is stored in the sim build directory of the HDL library.
The file is read by commands.do in Modelsim to avoid having to derive the library compile order in TCL.
"""
if lib_names==None:
if lib_names is None:
lib_names = self.lib_names
lib_dicts = self.libs.get_configfiles(key='hdl_lib_name', values=lib_names)
......@@ -490,7 +487,7 @@ class HdlLibrariesWizard:
def create_sub_directory_in_build_lib_dir(self, build_type, subdir_name, lib_names=None):
"""Create <subdir_name>/ in project local build directory <lib_name>/ for all HDL libraries in the specified list of lib_names.
"""
if lib_names==None:
if lib_names is None:
lib_names = self.lib_names
lib_dicts = self.libs.get_configfiles('hdl_lib_name', values=lib_names)
for lib_dict in lib_dicts:
......@@ -513,7 +510,7 @@ class HdlLibrariesWizard:
Arguments:
- lib_names : zero or more HDL libraries
"""
if lib_names==None:
if lib_names is None:
lib_names = self.lib_names
lib_dicts = self.libs.get_configfiles(key='hdl_lib_name', values=lib_names)
......@@ -620,10 +617,10 @@ if __name__ == '__main__':
if args.toplib:
for build_type in ['sim', 'synth']:
print('')
print('derive_all_use_libs for %s of %s = \n' % (build_type, args.toplib), \
hdl.derive_all_use_libs(build_type, args.toplib))
print('derive_all_use_libs for %s of %s = \n'
% (build_type, args.toplib), hdl.derive_all_use_libs(build_type, args.toplib))
print('')
print('derive_lib_order for %s of %s = \n' % (build_type, args.toplib), \
hdl.derive_lib_order(build_type, args.toplib))
print('derive_lib_order for %s of %s = \n'
% (build_type, args.toplib), hdl.derive_lib_order(build_type, args.toplib))
......@@ -34,6 +34,7 @@ intention to modify the keys and/or values in those configfiles. So the content
the configfiels is kept as raw as possible.
"""
class RawConfigFile(object):
"""
Class that holds the raw content of a configfile. To simplify the manipulation of the
......@@ -66,7 +67,6 @@ class RawConfigFile(object):
if verbose:
print(self.filename)
def change_value(self, key, new_value, verbose):
"""
Change the value of the given key. The old value may be empty, be on one or multiple lines.
......@@ -89,8 +89,7 @@ class RawConfigFile(object):
# sectionheader|other key|empty line or are at the end of the file
linenr += 1
while linenr < len(self.content):
if not re.match(r"(\[[a-zA-Z0-9_]+\]|[a-zA-Z0-9_]+[ \t]*{}|^[ \t]*$)".format(CFG_ASSIGNMENT_CHAR),
self.content[linenr]):
if not re.match(r"(\[[a-zA-Z0-9_]+\]|[a-zA-Z0-9_]+[ \t]*{}|^[ \t]*$)".format(CFG_ASSIGNMENT_CHAR), self.content[linenr]):
self.content.pop(linenr)
else:
break
......@@ -98,7 +97,6 @@ class RawConfigFile(object):
self._save_content(verbose)
break
def append_key_value(self, key, value, verbose):
"""
Append the given key and value to the end of the configfile.
......@@ -109,7 +107,6 @@ class RawConfigFile(object):
value.replace("\\n", "\n")))
self._save_content(verbose)
def rename_key(self, old_key, new_key, verbose):
"""
Change the name of a key.
......@@ -161,7 +158,6 @@ class RawConfigFile(object):
del self.content[first_line:last_line]
self._save_content(verbose)
def insert_key_at_linenr(self, new_key, new_value, linenumber, verbose):
"""
Insert a new key = value pair in the configfile at linenumber. The first line has number 1.
......@@ -174,7 +170,6 @@ class RawConfigFile(object):
self.content.insert(linenumber-1, new_line)
self._save_content(verbose)
def insert_key_value_before_key(self, new_key, new_value, before_key, verbose):
"""
Insert a new key = value pair in the configfile just before another key..
......@@ -204,6 +199,3 @@ class RawConfigTree(ConfigTree):
def _factory_constructor(self, full_filename):
"Function for returning the readin configfile."
return RawConfigFile(full_filename)
......@@ -34,6 +34,7 @@ import common_radiohdl as cm
import hdl_libraries_wizard
from configfile import ConfigFile
class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
def __init__(self, toolRootDir, buildsetFile, libFileName):
......@@ -81,7 +82,7 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
with open(mpfPathName, 'r') as fp:
for line in fp:
words = line.split()
if len(words)>0:
if words:
key = words[0]
if key.find('Project_File_') >= 0 and key.find('Project_File_P_') == -1:
project_file_indices.append(key[len('Project_File_'):])
......@@ -91,7 +92,7 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
with open(mpfPathName, 'r') as fp:
for line in fp:
words = line.split()
if len(words)>0:
if words:
key = words[0]
if key.find('Project_File_P_') >= 0:
project_file_index = project_file_indices.index(key[len('Project_File_P_'):])
......@@ -109,8 +110,8 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
- filePath : path to hdl_libraries_<technologyName>.txt, when None then the file is
read in the default toolRootDir
"""
fileName = 'hdl_libraries_' + technologyName + '.txt' # use fixed file name format
if filePath==None:
fileName = 'hdl_libraries_ip_' + technologyName + '.txt' # use fixed file name format
if filePath is None:
toolDir = os.path.expandvars('$HDL_BUILD_DIR')
toolSubDir = self.buildset['buildset_name']
fileNamePath = os.path.join(toolDir, toolSubDir, fileName) # default file path
......@@ -119,14 +120,13 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
tech_dict = ConfigFile(fileNamePath).content
return tech_dict
def create_modelsim_lib_compile_ip_files(self, lib_names=None):
"""
Create the '<lib_name>_lib_compile_ip.txt' 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.
The file is read by commands.do in Modelsim to know which IP needs to be compiled before the library is compiled.
"""
if lib_names==None:
if lib_names is None:
lib_names = self.lib_names
count = 0
......@@ -148,7 +148,6 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
fp.write('%s ' % efpn)
print("Created {} compile-ip files".format(count))
def simulation_configuration(self, list_mode=False):
"""Prepare settings for simulation configuration.
The output format is string or list, dependent on list_mode.
......@@ -189,7 +188,6 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
return project_sim_p_defaults, project_sim_p_search_libraries, project_sim_p_otherargs, project_sim_p_optimization
def create_modelsim_project_file(self, lib_names=None):
"""
Create the Modelsim project file for all technology libraries and RTL HDL libraries.
......@@ -206,7 +204,7 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
VHDL for the unavailable HDL library. unavailable library names occur when e.g. a technology IP library
is not available in the toolRootDir because it is not needed, or it may indicate a spelling error.
"""
if lib_names==None:
if lib_names is None:
lib_names = self.lib_names
lib_dicts = self.libs.get_configfiles(key='hdl_lib_name', values=lib_names)
......@@ -223,8 +221,13 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
fp.write('[Library]\n')
# . map used vendor technology libs to their target directory
for technologyName in self.technologyNames:
tech_dict = self.read_hdl_libraries_technology_file(technologyName)
# for technologyName in self.technologyNames:
# tech_dict = self.read_hdl_libraries_technology_file(technologyName)
# for lib_clause, lib_work in tech_dict.items():
# fp.write('%s = %s\n' % (lib_clause, lib_work))
for familyName in self.familyNames:
tech_dict = self.read_hdl_libraries_technology_file(familyName)
for lib_clause, lib_work in tech_dict.items():
fp.write('%s = %s\n' % (lib_clause, lib_work))
......@@ -298,7 +301,8 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
print('\nERROR - Undefined file extension in synth_files:', lib_name, synth_files[i])
sys.exit()
fp.write('Project_File_P_%d = folder %s compile_order %d %s\n' % (offset+i, project_folders[-1], offset+i, project_file_p_defaults_hdl+' '+project_file_p_defaults_file_specific))
fp.write('Project_File_P_%d = folder %s compile_order %d %s\n' % (
offset+i, project_folders[-1], offset+i, project_file_p_defaults_hdl+' '+project_file_p_defaults_file_specific))
offset = nof_synth_files
nof_test_bench_files = len(test_bench_files)
......@@ -316,7 +320,8 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
print('\nERROR - Undefined file extension in test_bench_files:', lib_name, test_bench_files[i])
sys.exit()
fp.write('Project_File_P_%d = folder %s compile_order %d %s\n' % (offset+i, project_folders[-1], offset+i, project_file_p_defaults_hdl+' '+project_file_p_defaults_file_specific))
fp.write('Project_File_P_%d = folder %s compile_order %d %s\n' % (
offset+i, project_folders[-1], offset+i, project_file_p_defaults_hdl+' '+project_file_p_defaults_file_specific))
offset += nof_test_bench_files
if 'modelsim_compile_ip_files' in lib_dict.content:
......@@ -324,7 +329,8 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
if nof_compile_ip_files > 0:
project_folders.append('compile_ip_files')
for i in range(nof_compile_ip_files):
fp.write('Project_File_P_%d = folder %s compile_order %d %s\n' % (offset+i, project_folders[-1], offset+i, project_file_p_defaults_tcl))
fp.write('Project_File_P_%d = folder %s compile_order %d %s\n' % (
offset + i, project_folders[-1], offset + i, project_file_p_defaults_tcl))
offset += nof_compile_ip_files
# - project folders
......@@ -343,7 +349,8 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
for i, fn in enumerate(test_bench_files):
fName = os.path.basename(fn)
tbName = os.path.splitext(fName)[0]
fp.write('Project_Sim_P_%d = folder {Top Level} additional_dus work.%s %s %s %s %s\n' % (i, tbName, project_sim_p_defaults, project_sim_p_search_libraries, project_sim_p_otherargs, project_sim_p_optimization))
fp.write('Project_Sim_P_%d = folder {Top Level} additional_dus work.%s %s %s %s %s\n' % (
i, tbName, project_sim_p_defaults, project_sim_p_search_libraries, project_sim_p_otherargs, project_sim_p_optimization))
# Write [vsim] section
fp.write('[vsim]\n')
......@@ -362,7 +369,7 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
fileName = 'modelsim_project_files.txt' # use fixed file name
build_maindir, build_buildsetdir, build_tooldir, project_deeper_subdir = self.get_tool_build_dir('sim')
fileNamePath = os.path.join(build_maindir, build_buildsetdir, build_tooldir, fileName) # and use too build dir for file path
if lib_names==None:
if lib_names is None:
lib_names = self.lib_names
with open(fileNamePath, 'w') as fp:
lib_dicts = self.libs.get_configfiles(key='hdl_lib_name', values=lib_names)
......@@ -422,7 +429,7 @@ if __name__ == '__main__':
print('')
print('Create library compile order files for simulation...')
msim.create_lib_order_files('sim')
sys.exit(0)
# sys.exit(0)
print('')
print('Create library compile ip files...')
......@@ -443,6 +450,7 @@ if __name__ == '__main__':
print('')
print('Create Modelsim Project Files for technology %s and all HDL libraries in %s...' % (msim.technologyNames, msim.libRootDirs))
msim.create_modelsim_project_file()
# sys.exit(0)
if mode == 1:
# for lib_name in ['ado','ap','bf','bist','blp','bp','cdo','cim','cir','cp','cr','dc','eth','fmf','i2c','lvds','pfs','pft2','rcuh','ri','rsp','rsr','rsu','sens','serdes','si','st','tbbi','tdsh']:
......@@ -462,4 +470,3 @@ if __name__ == '__main__':
print('')
print('Save modelsim compile order for', lib_name, 'in HDL library config file', filePathName)
msim.libs.append_key_to_dict_file(filePathName, 'files', compile_order)
......@@ -36,6 +36,7 @@ from hdl_raw_access import RawConfigTree
# the remaining elememts (if any) are the arguments to ask the user
# All arguments are stored in a kwargs structure and passed to the functions that is called.
def get_menu_choice(menu, title):
"""
Iterate over the menu dict, show the menu choices and ask for input till valid input is received.
......@@ -53,6 +54,7 @@ def get_menu_choice(menu, title):
input_ok = True
return menu[choice]
def execute_menu_line(line_spec, verbose):
"""
Given a menu line specification it asks the user for the specified arguments, stores the values in a
......@@ -83,6 +85,7 @@ def change_value_of_key(**kwargs):
for filename in sorted(tree.configfiles.keys()):
tree.configfiles[filename].change_value(key, new_value, verbose)
def append_key_value(**kwargs):
key = kwargs.pop("new_key")
new_value = kwargs.pop("new_value")
......@@ -91,6 +94,7 @@ def append_key_value(**kwargs):
for filename in sorted(tree.configfiles.keys()):
tree.configfiles[filename].append_key_value(key, new_value, verbose)
def insert_key_at_linenr(**kwargs):
new_key = kwargs.pop("new_key")
new_value = kwargs.pop("new_value")
......@@ -100,6 +104,7 @@ def insert_key_at_linenr(**kwargs):
for filename in sorted(tree.configfiles.keys()):
tree.configfiles[filename].insert_key_at_linenr(new_key, new_value, linenumber, verbose)
def insert_key_value_before_key(**kwargs):
new_key = kwargs.pop("new_key")
new_value = kwargs.pop("new_value")
......@@ -109,6 +114,7 @@ def insert_key_value_before_key(**kwargs):
for filename in sorted(tree.configfiles.keys()):
tree.configfiles[filename].insert_key_value_before_key(new_key, new_value, before_key, verbose)
def rename_key(**kwargs):
old_key = kwargs.pop("old_key")
new_key = kwargs.pop("new_key")
......@@ -117,6 +123,7 @@ def rename_key(**kwargs):
for filename in sorted(tree.configfiles.keys()):
tree.configfiles[filename].rename_key(old_key, new_key, verbose)
def remove_key(**kwargs):
key = kwargs.pop("key")
verbose = kwargs.pop("verbose")
......@@ -124,6 +131,7 @@ def remove_key(**kwargs):
for filename in sorted(tree.configfiles.keys()):
tree.configfiles[filename].remove_key(key, verbose)
def end_menu():
global running
running = False
......
......@@ -33,6 +33,7 @@ from argparse import ArgumentParser
import common_radiohdl as cm
import hdl_libraries_wizard
class QuartusConfig(hdl_libraries_wizard.HdlLibrariesWizard):
def __init__(self, toolRootDir, toolFileName, libFileName='hdllib.cfg'):
......@@ -79,7 +80,7 @@ class QuartusConfig(hdl_libraries_wizard.HdlLibrariesWizard):
Arguments:
- lib_names : one or more HDL libraries
"""
if lib_names==None:
if lib_names is None:
lib_names = self.lib_names
lib_dicts = self.libs.get_configfiles('hdl_lib_name', values=lib_names)
......@@ -151,7 +152,6 @@ class QuartusConfig(hdl_libraries_wizard.HdlLibrariesWizard):
fp.write('set_global_assignment -name SDC_FILE %s\n' % filePathName)
print("Created {} .qip files".format(len(lib_dicts)))
def create_quartus_project_file(self, lib_names=None):
"""Create the Quartus project file (QPF) for all HDL libraries that have a toplevel entity key synth_top_level_entity.
......@@ -167,7 +167,8 @@ class QuartusConfig(hdl_libraries_wizard.HdlLibrariesWizard):
Arguments:
- lib_names : one or more HDL libraries
"""
if lib_names==None: lib_names=self.lib_names
if lib_names is None:
lib_names = self.lib_names
lib_dicts = self.libs.get_configfiles(key='hdl_lib_name', values=lib_names)
syn_dicts = self.libs.get_configfiles(key='synth_top_level_entity', values=None, user_configfiles=lib_dicts)
for syn_dict in syn_dicts:
......@@ -181,7 +182,6 @@ class QuartusConfig(hdl_libraries_wizard.HdlLibrariesWizard):
fp.write('PROJECT_REVISION = "%s"\n' % lib_name)
print("Created {} .qpf files".format(len(syn_dicts)))
def create_quartus_settings_file(self, lib_names=None):
"""Create the Quartus settings file (QSF) for all HDL libraries that have a toplevel entity key synth_top_level_entity.
......@@ -191,7 +191,8 @@ class QuartusConfig(hdl_libraries_wizard.HdlLibrariesWizard):
Arguments:
- lib_names : one or more HDL libraries
"""
if lib_names==None: lib_names=self.lib_names
if lib_names is None:
lib_names = self.lib_names
lib_dicts = self.libs.get_configfiles(key='hdl_lib_name', values=lib_names)
syn_dicts = self.libs.get_configfiles(key='synth_top_level_entity', values=None, user_configfiles=lib_dicts)
for syn_dict in syn_dicts:
......@@ -271,19 +272,22 @@ if __name__ == '__main__':
else:
print(' %-40s' % d['hdl_lib_name'], ':', d['synth_top_level_entity'])
print('')
print('Create Quartus IP library qip files for all HDL libraries in $%s.' % qsyn.libRootDirs)
print('Create Quartus IP library qip files for all HDL libraries in $%s.'
% qsyn.libRootDirs)
qsyn.create_quartus_ip_lib_file()
print('')
print('Copy Quartus directories and files from HDL library source tree to build_dir for all HDL libraries that are found in $%s.' % qsyn.libRootDirs)
print('Copy Quartus directories and files from HDL library source tree to build_dir for all HDL libraries that are found in $%s.'
% qsyn.libRootDirs)
qsyn.copy_files('synth')
print('')
print('Create Quartus project files (QPF) for technology %s and all HDL libraries with a top level entity for synthesis that are found in $%s.' % (qsyn.technologyNames, qsyn.libRootDirs))
print('Create Quartus project files (QPF) for technology %s and all HDL libraries with a top level entity for synthesis that are found in $%s.'
% (qsyn.technologyNames, qsyn.libRootDirs))
qsyn.create_quartus_project_file()
print('')
print('Create Quartus settings files (QSF) for technology %s and all HDL libraries with a top level entity for synthesis that are found in $%s.' % (qsyn.technologyNames, qsyn.libRootDirs))
print('Create Quartus settings files (QSF) for technology %s and all HDL libraries with a top level entity for synthesis that are found in $%s.'
% (qsyn.technologyNames, qsyn.libRootDirs))
qsyn.create_quartus_settings_file()
......@@ -2,6 +2,7 @@ import unittest
from configfile import *
from hdl_configfile import *
class Test_construction(unittest.TestCase):
"Class to the various ways of construction"
......@@ -40,8 +41,7 @@ class Test_key_value_spacing(unittest.TestCase):
self.assertEqual(cfg.tricky_key_2, "tricky_value_2")
self.assertEqual(cfg.tricky_key_3, "")
self.assertEqual(cfg.section_headers, ['"my_section"'])
self.assertEqual(cfg.warning_key_1,
"Be aware that multiline values can be tricky: this also belongs to previous key 'warning_key_1'")
self.assertEqual(cfg.warning_key_1, "Be aware that multiline values can be tricky: this also belongs to previous key 'warning_key_1'")
# also test attribute access versus item access
self.assertEqual(cfg.multi_key_2, cfg['multi_key_2'])
print(cfg.content)
......@@ -142,6 +142,6 @@ class Test_hdllib_file(unittest.TestCase):
def test_read_wrong_hdllib_file(self):
self.assertRaises(ConfigFileException, HdlLib, "./cdf_dir/hdllib_files/hdllib_wrong.cfg")
if __name__ == '__main__':
unittest.main(verbosity=2)
......@@ -2,6 +2,7 @@ import unittest
from configtree import *
from hdl_configtree import *
class Test_construction(unittest.TestCase):
"Class to the various ways of construction"
......@@ -63,6 +64,7 @@ class Test_tree_behaviour(unittest.TestCase):
quartus = tree.configfiles['./cdf_dir/tree/hdltool/hdl_tool_quartus.cfg']
self.assertEqual(quartus.quartus_rootdir, "${QUARTUS_DIR}/quartus")
if __name__ == '__main__':
unittest.main(verbosity=2)
......@@ -71,7 +71,7 @@ do
done
# TODO: move to hdl_tool_quartus.cfg : user_environment_variables ???
export RADIOHDL_GIT_REVISION=`cd $RADIOHDL_GEAR; git describe; cd - | grep V`
#export RADIOHDL_GIT_REVISION=`cd $RADIOHDL_GEAR; git describe; cd - | grep V`
export UNB_COMPILE_STAMPS=1
unset buildset_config_file quartus_config_file bd_name verbose
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment