diff --git a/tools/oneclick/base/quartus_config.py b/tools/oneclick/base/quartus_config.py index de69ecb1bec6a41b7e40a834864ccd2cb371985d..deca445742b4fca21a673e165fd68af570337f3d 100644 --- a/tools/oneclick/base/quartus_config.py +++ b/tools/oneclick/base/quartus_config.py @@ -27,6 +27,7 @@ import hdl_config import sys import os import os.path +import shutil class QuartusConfig(hdl_config.HdlConfig): @@ -53,8 +54,12 @@ class QuartusConfig(hdl_config.HdlConfig): """Create the Quartus IP file <hdl_lib_name>_lib.qip for all HDL libraries. The <hdl_lib_name>_lib.qip file contains the list of files that is given by the synth_files key. - The postfix '_lib' is used to distinguish this qip file from a <hdl_lib_name>.qip that may be used for HDL libraries that have a - synth_top_level_entity. + Note: + . The postfix '_lib' is used to distinguish this qip file from a <hdl_lib_name>.qip that may be used for HDL libraries that have a + synth_top_level_entity. + . The HDL library qip files contain all files that are listed by the synth_files key. Hence when these qip files are included then + the Quartus project will analyse all files even if there entity is not instantiated in the design. This is fine, it is unnecessary + to parse the hierarchy of the synth_top_level_entity VHDL file to find and include only the source files that are actually used. Arguments: - lib_names : one or more HDL libraries @@ -81,6 +86,27 @@ class QuartusConfig(hdl_config.HdlConfig): fp.write('set_global_assignment -name VHDL_FILE %s\n' % filePathName) + def copy_quartus_sopc_file_to_build_synth_dir(self, lib_names=None): + """If it exisits then copy the Quartus SOPC file from quartus_sopc_file in the HDL library to the build_synth_dir for all HDL libraries that have a + toplevel entity key synth_top_level_entity. + """ + if lib_names==None: lib_names=self.lib_names + lib_dicts = self.libs.get_dicts(key='hdl_lib_name', values=lib_names) + syn_dicts = self.libs.get_dicts(key='synth_top_level_entity', values=None, dicts=lib_dicts) + for syn_dict in cm.listify(syn_dicts): + if 'quartus_sopc_file' in syn_dict: + lib_path = self.libs.get_filePath(syn_dict) + fpn = os.path.expandvars(syn_dict['quartus_sopc_file']) # support using environment variables in the file path + if os.path.isabs(fpn): + filePathName = fpn # use absolute path to file + else: + filePathName = os.path.join(lib_path, fpn) # derive absolute path to file from library path and local path to file + if os.path.isfile(filePathName): + build_path = self.get_lib_build_dirs('synth', lib_dicts=syn_dict) + cm.mkdir(build_path) + shutil.copy(filePathName, build_path) + + def create_quartus_project_file(self, lib_names=None): """Create the Quartus project file for all HDL libraries that have a toplevel entity key synth_top_level_entity. @@ -143,6 +169,10 @@ if __name__ == '__main__': print 'Create Quartus IP library qip files for all HDL libraries in $%s.' % libRootDir qsyn.create_quartus_ip_lib_file() + print '' + print 'Copy SOPC file from source tree to build_synth_dir for all HDL libraries with a top level entity for synthesis that are found in $%s.' % libRootDir + qsyn.copy_quartus_sopc_file_to_build_synth_dir() + print '' print 'Create Quartus project files for all HDL libraries with a top level entity for synthesis that are found in $%s.' % libRootDir qsyn.create_quartus_project_file()