From ad1fee451531de9f77e1bd73e602d4117bd65ecf Mon Sep 17 00:00:00 2001 From: donker <donker@astron.nl> Date: Thu, 22 Aug 2019 08:24:19 +0200 Subject: [PATCH] backup tools for unb2b not working yet --- .gitignore | 4 ++ config/hdl_tool_quartus.cfg | 2 +- core/check_config | 4 +- core/common_radiohdl.py | 11 ++++-- core/configfile.py | 1 + core/export_hdllib_variables.py | 2 +- core/generate_ip_libs | 9 +++-- core/hdl_libraries_wizard.py | 4 +- core/modelsim_config | 4 +- core/quartus_config | 5 ++- generic.sh | 2 +- init_radiohdl.sh | 4 +- modelsim/set_modelsim | 5 ++- quartus/compile_altera_simlibs | 2 +- quartus/run_qsys | 70 +++++++++++++++++++-------------- quartus/run_qsys_tool | 4 +- quartus/set_quartus | 6 +-- 17 files changed, 82 insertions(+), 57 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ce5c149 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*log +__pycache__ +*pyc +*# \ No newline at end of file diff --git a/config/hdl_tool_quartus.cfg b/config/hdl_tool_quartus.cfg index d1a8b00..8ae6d88 100644 --- a/config/hdl_tool_quartus.cfg +++ b/config/hdl_tool_quartus.cfg @@ -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] diff --git a/core/check_config b/core/check_config index 5945f1c..5ded6fd 100755 --- a/core/check_config +++ b/core/check_config @@ -104,7 +104,7 @@ if __name__ == '__main__': args = argparser.parse_args() # construct full name of buildsetfile and read the file - full_buildsetfile_name = expandvars("${HDL_CONFIG_DIR}/hdl_buildset_%s.cfg" % (args.buildset)) + full_buildsetfile_name = expandvars("${RADIOHDL_CONFIG}/hdl_buildset_%s.cfg" % (args.buildset)) print("Reading {}...".format(full_buildsetfile_name)) buildset_info = HdlBuildset(full_buildsetfile_name) @@ -135,7 +135,7 @@ if __name__ == '__main__': print("\n ERROR: Key {} is missing.".format(tool_dir), end=' ') else: os.environ[tool_dir.upper()] = buildset_info[tool_dir] - tool_configfile = expandvars("${HDL_CONFIG_DIR}/hdl_tool_%s.cfg" % (toolname)) + tool_configfile = expandvars("${RADIOHDL_CONFIG}/hdl_tool_%s.cfg" % (toolname)) if not isfile(tool_configfile): print("\n Warning: File {} is missing!".format(tool_configfile), end=' ') else: diff --git a/core/common_radiohdl.py b/core/common_radiohdl.py index a456b41..da37f6b 100644 --- a/core/common_radiohdl.py +++ b/core/common_radiohdl.py @@ -7,11 +7,16 @@ def listify(obj): """ Can be used to force method input to a list. """ - try: - return list(obj) - except TypeError: + if isinstance(obj, list): + return obj + else: return [obj] + # try: + # return list(obj) + # except TypeError: + # return [obj] + def unlistify(obj): """ diff --git a/core/configfile.py b/core/configfile.py index 572c473..4721f5f 100644 --- a/core/configfile.py +++ b/core/configfile.py @@ -264,6 +264,7 @@ class ConfigFile(object): """ ref_pattern = r"<(.+?)>" prog = re.compile(ref_pattern) + # print('__content__={}'.format(self.__content__.items())) # loop over all items of the dict for key, value in list(self.__content__.items()): # any reference in the value? diff --git a/core/export_hdllib_variables.py b/core/export_hdllib_variables.py index b7417f5..5eab184 100755 --- a/core/export_hdllib_variables.py +++ b/core/export_hdllib_variables.py @@ -37,7 +37,7 @@ if __name__ == '__main__': args = argparser.parse_args() # read the buildset file - full_buildsetfile_name = expandvars("${HDL_CONFIG_DIR}/hdl_buildset_%s.cfg" % (args.buildset)) + full_buildsetfile_name = expandvars("${RADIOHDL_CONFIG}/hdl_buildset_%s.cfg" % (args.buildset)) buildset_info = HdlBuildset(full_buildsetfile_name) buildset_info.resolve_key_references() diff --git a/core/generate_ip_libs b/core/generate_ip_libs index 204df8e..590aa4a 100755 --- a/core/generate_ip_libs +++ b/core/generate_ip_libs @@ -23,6 +23,7 @@ ############################################################################### import sys +import os from os.path import expandvars, dirname, basename from subprocess import call, STDOUT from common_radiohdl import listify, mkdir @@ -130,7 +131,8 @@ if __name__ == '__main__': args = argparser.parse_args() # resolve full name of buildsetfile and force it to be explicit absolute or relative. - full_buildsetfile_name = expandvars("${HDL_CONFIG_DIR}/hdl_buildset_%s.cfg" % (args.buildset)) + full_buildsetfile_name = os.path.join(os.getenv('RADIOHDL_CONFIG'), 'hdl_buildset_{}.cfg'.format(args.buildset)) + print('full_buildsetfile_name={}'.format(full_buildsetfile_name)) if full_buildsetfile_name[0] != '/': full_buildsetfile_name = "./" + full_buildsetfile_name # read the file @@ -143,7 +145,8 @@ if __name__ == '__main__': lib_tree = HdlLibTree(rootdirs=root_dirs, filename="hdllib.cfg", sections="generate_ip_libs") # read in the tool environment settings - tool_config_file = expandvars("${HDL_CONFIG_DIR}/hdl_tool_{}.cfg".format(buildset_info.synth_tool_name)) + tool_config_file = os.path.join(os.getenv('RADIOHDL_CONFIG'), 'hdl_tool_{}.cfg'.format(buildset_info.synth_tool_name)) + 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 != '' ] @@ -163,7 +166,7 @@ if __name__ == '__main__': if ip_lib_info.hdl_lib_technology == technology and ip_tool_key in ip_lib_info.content: # we have a match do the compilation print("==> Processing {} with {}".format(ip_lib_info.ID, ip_tool)) - outputdir = "${HDL_BUILD_DIR}/%s/%s" % (args.buildset, 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(" ") \ if name != '' ] diff --git a/core/hdl_libraries_wizard.py b/core/hdl_libraries_wizard.py index 348edb2..8032e7b 100644 --- a/core/hdl_libraries_wizard.py +++ b/core/hdl_libraries_wizard.py @@ -547,7 +547,7 @@ class HdlLibrariesWizard: if __name__ == '__main__': # Parse command line arguments - buildsetSelect = sorted([cfgfile[13:-4] for cfgfile in listdir(expandvars('$HDL_CONFIG_DIR')) + buildsetSelect = sorted([cfgfile[13:-4] for cfgfile in listdir(expandvars('$RADIOHDL_CONFIG')) if cfgfile.startswith("hdl_buildset_") and cfgfile.endswith(".cfg")]) argparser = ArgumentParser(description='Hdl_config shows several selections of all of your hdllib.cfg files.') argparser.add_argument('buildset', help='choose buildset %s' % (buildsetSelect)) @@ -562,7 +562,7 @@ if __name__ == '__main__': args.buildsetFile = 'hdl_buildset_' + args.buildset + '.cfg' # Read the dictionary info from all HDL tool and library configuration files in the current directory and the sub directories - hdl = HdlLibrariesWizard(toolRootDir = expandvars('${HDL_CONFIG_DIR}'), + hdl = HdlLibrariesWizard(toolRootDir = expandvars('${RADIOHDL_CONFIG}'), toolFileName = args.buildsetFile, libFileName = 'hdllib.cfg') diff --git a/core/modelsim_config b/core/modelsim_config index 5271d4c..b6e4310 100755 --- a/core/modelsim_config +++ b/core/modelsim_config @@ -382,7 +382,7 @@ if __name__ == '__main__': # hdllib.cfg. The hdllib.cfg still does need some manual editing to set the proper key and paths. mode = 0 - buildsetSelect = sorted([cfgfile[13:-4] for cfgfile in listdir(os.path.expandvars('$HDL_CONFIG_DIR')) + buildsetSelect = sorted([cfgfile[13:-4] for cfgfile in listdir(os.path.expandvars('$RADIOHDL_CONFIG')) if cfgfile.startswith("hdl_buildset_") and cfgfile.endswith(".cfg")]) # Parse command line arguments argparser = ArgumentParser(description='Modelsim creates/updates all your modelsim environment(s).') @@ -398,7 +398,7 @@ if __name__ == '__main__': args.buildsetFile = 'hdl_buildset_' + args.buildset + '.cfg' # Read the dictionary info from all HDL tool and library configuration files in the current directory and the sub directories - msim = ModelsimConfig(toolRootDir = os.path.expandvars('$HDL_CONFIG_DIR'), + msim = ModelsimConfig(toolRootDir = os.path.expandvars('$RADIOHDL_CONFIG'), buildsetFile = args.buildsetFile, libFileName = 'hdllib.cfg') diff --git a/core/quartus_config b/core/quartus_config index f7d233e..9ced319 100755 --- a/core/quartus_config +++ b/core/quartus_config @@ -232,7 +232,7 @@ class QuartusConfig(hdl_libraries_wizard.HdlLibrariesWizard): if __name__ == '__main__': # Parse command line arguments - buildsetSelect = sorted([cfgfile[13:-4] for cfgfile in listdir(os.path.expandvars('$HDL_CONFIG_DIR')) + buildsetSelect = sorted([cfgfile[13:-4] for cfgfile in listdir(os.getenv('RADIOHDL_CONFIG')) if cfgfile.startswith("hdl_buildset_") and cfgfile.endswith(".cfg")]) argparser = ArgumentParser(description='Quartus_config creates/updates all your quartus projectfiles.') argparser.add_argument('buildset', help='choose buildset %s' % (buildsetSelect)) @@ -247,7 +247,7 @@ if __name__ == '__main__': args.buildsetFile = 'hdl_buildset_' + args.buildset + '.cfg' # Read the dictionary info from all HDL tool and library configuration files in the current directory and the sub directories - qsyn = QuartusConfig(toolRootDir = os.path.expandvars('${HDL_CONFIG_DIR}'), + qsyn = QuartusConfig(toolRootDir = os.getenv('RADIOHDL_CONFIG'), toolFileName= args.buildsetFile, libFileName = 'hdllib.cfg') @@ -271,6 +271,7 @@ 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) qsyn.create_quartus_ip_lib_file() diff --git a/generic.sh b/generic.sh index 90987ba..6e53f89 100755 --- a/generic.sh +++ b/generic.sh @@ -138,7 +138,7 @@ hdl_exec() { if [ $exit_on_err ]; then set -e fi - + echo "exitcode=${exitcode}" # Finally check if the exitcode of the command we executed is the expected one. if [ "${exitcode}" -ne "${expect}" ]; then if [ "${msg}" == "no" ]; then diff --git a/init_radiohdl.sh b/init_radiohdl.sh index 4de36d3..09c8b23 100644 --- a/init_radiohdl.sh +++ b/init_radiohdl.sh @@ -38,7 +38,7 @@ export RADIOHDL_GEAR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" #export RADIOHDL_GEAR=${RADIOHDL_GEAR} # setup paths to build and config dir if not already defined by the user. #export HDL_BUILD_DIR=${HDL_BUILD_DIR:-${RADIOHDL_WORK}/build} -export HDL_CONFIG_DIR=${HDL_CONFIG_DIR:-${RADIOHDL_GEAR}/config} +export RADIOHDL_CONFIG=${RADIOHDL_CONFIG:-${RADIOHDL_GEAR}/config} echo "RadioHDL environment will be setup for" $RADIOHDL_GEAR # Define function to add directories to a given environment variable @@ -55,6 +55,6 @@ pathadd() { } # Extend the PATH and PYTHONPATH variables -pathadd "PATH" ${RADIOHDL_GEAR}/quartus ${RADIOHDL_GEAR}/ise ${RADIOHDL_GEAR}/modelsim +pathadd "PATH" ${RADIOHDL_GEAR}/quartus ${RADIOHDL_GEAR}/ise ${RADIOHDL_GEAR}/modelsim ${RADIOHDL_GEAR}/core pathadd "PYTHONPATH" ${RADIOHDL_GEAR}/core ${RADIOHDL_GEAR}/components diff --git a/modelsim/set_modelsim b/modelsim/set_modelsim index 09d9fb8..2f5d037 100755 --- a/modelsim/set_modelsim +++ b/modelsim/set_modelsim @@ -40,7 +40,7 @@ if [ "${BUILDSET}" = "" ]; then fi # Select output directory for the library compilation results -buildset_config_file="${HDL_CONFIG_DIR}/hdl_buildset_${BUILDSET}.cfg" +buildset_config_file="${RADIOHDL_CONFIG}/hdl_buildset_${BUILDSET}.cfg" if [ ! -f $buildset_config_file ]; then hdl_error $0 "File '$buildset_config_file' does not exist" fi @@ -52,9 +52,10 @@ echo "Setting up modelsim for: ${BUILDSET}" . ${RADIOHDL_GEAR}/set_config_variable $verbose $buildset_config_file modelsim_dir,modelsim_platform # Adopt quartus installation dependend directories -modelsim_config_file="${HDL_CONFIG_DIR}/hdl_tool_modelsim.cfg" +modelsim_config_file="${RADIOHDL_CONFIG}/hdl_tool_modelsim.cfg" . ${RADIOHDL_GEAR}/set_config_variable $verbose $modelsim_config_file model_tech_altera_lib +# TODO, load only for modelsim 10.4 export LD_PRELOAD=/home/software/freetype2/usr/lib/libfreetype.so unset buildset_config_file modelsim_config_file verbose diff --git a/quartus/compile_altera_simlibs b/quartus/compile_altera_simlibs index cbcff91..e1a16d4 100755 --- a/quartus/compile_altera_simlibs +++ b/quartus/compile_altera_simlibs @@ -50,7 +50,7 @@ buildset=$1 . ${RADIOHDL_GEAR}/modelsim/set_modelsim ${buildset} # Select output directory for the library compilation results -buildset_config_file="${HDL_CONFIG_DIR}/hdl_buildset_${buildset}.cfg" +buildset_config_file="${RADIOHDL_CONFIG}/hdl_buildset_${buildset}.cfg" . ${RADIOHDL_GEAR}/set_config_variable $buildset_config_file synth_tool_name,synth_tool_version OUTPUT_DIR=${HDL_BUILD_DIR}/${SYNTH_TOOL_NAME}/${SYNTH_TOOL_VERSION} mkdir -p ${OUTPUT_DIR} diff --git a/quartus/run_qsys b/quartus/run_qsys index 5277c2b..c7883a7 100755 --- a/quartus/run_qsys +++ b/quartus/run_qsys @@ -85,36 +85,46 @@ txt="Generating QSYS system for project ${project}." # Note: ip-generate does NOT look in user_components.ipx in the users home directory! -hdl_info $0 "generate files for simulation" -hdl_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \ - --output-directory=${quartusdir}/${qsysfilebase}/simulation/ \ - --file-set=SIM_VHDL \ - --report-file=sopcinfo:${quartusdir}/${qsysfilebase}.sopcinfo \ - --report-file=html:${quartusdir}/${qsysfilebase}.html \ - --report-file=csv:${quartusdir}/${qsysfilebase}.csv \ - --report-file=spd:${quartusdir}/${qsysfilebase}.spd \ - --component-file=${quartusdir}/${qsysfile} - -hdl_info $0 "create modelsim project" -hdl_exec $0 msg="${txt}" expect=0 sim-script-gen --spd=${quartusdir}/${qsysfilebase}.spd \ - --output-directory=${quartusdir}/${qsysfilebase}/simulation/ - - -hdl_info $0 "generate .bsf" -hdl_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \ - --output-directory=${quartusdir}/${qsysfilebase}/ \ - --report-file=bsf:${quartusdir}/${qsysfilebase}.bsf \ - --component-file=${quartusdir}/${qsysfile} - -hdl_info $0 "generate HDL files for synthesis" -hdl_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \ - --output-directory=${quartusdir}/${qsysfilebase}/synthesis/ \ - --file-set=QUARTUS_SYNTH \ - --report-file=sopcinfo:${quartusdir}/${qsysfilebase}.sopcinfo \ - --report-file=html:${quartusdir}/${qsysfilebase}.html \ - --report-file=qip:${quartusdir}/${qsysfilebase}/synthesis/${qsysfilebase}.qip \ - --component-file=${quartusdir}/${qsysfile} - +if [ "${buildset}" = "unb2b" ]; then + hdl_info $0 "generating QSYS system for unb2b project" + hdl_exec $0 msg="${txt}" expect=0 qsys-generate ${quartusdir}/${qsysfile} \ + --search-path=${quartusdir}/ip/${qsysfilebase},$ \ + --synthesis=VHDL \ + --block-symbol-file \ + --quartus-project=${quartusdir}/${project}.qpf + cp ${quartusdir}/${qsysfilebase}/${qsysfilebase}.sopcinfo ${quartusdir} + cp ${quartusdir}/${qsysfilebase}/${qsysfilebase}.bsf ${quartusdir} +else + hdl_info $0 "generate files for simulation" + hdl_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \ + --output-directory=${quartusdir}/${qsysfilebase}/simulation/ \ + --file-set=SIM_VHDL \ + --report-file=sopcinfo:${quartusdir}/${qsysfilebase}.sopcinfo \ + --report-file=html:${quartusdir}/${qsysfilebase}.html \ + --report-file=csv:${quartusdir}/${qsysfilebase}.csv \ + --report-file=spd:${quartusdir}/${qsysfilebase}.spd \ + --component-file=${quartusdir}/${qsysfile} + + hdl_info $0 "create modelsim project" + hdl_exec $0 msg="${txt}" expect=0 sim-script-gen --spd=${quartusdir}/${qsysfilebase}.spd \ + --output-directory=${quartusdir}/${qsysfilebase}/simulation/ + + + hdl_info $0 "generate .bsf" + hdl_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \ + --output-directory=${quartusdir}/${qsysfilebase}/ \ + --report-file=bsf:${quartusdir}/${qsysfilebase}.bsf \ + --component-file=${quartusdir}/${qsysfile} + + hdl_info $0 "generate HDL files for synthesis" + hdl_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \ + --output-directory=${quartusdir}/${qsysfilebase}/synthesis/ \ + --file-set=QUARTUS_SYNTH \ + --report-file=sopcinfo:${quartusdir}/${qsysfilebase}.sopcinfo \ + --report-file=html:${quartusdir}/${qsysfilebase}.html \ + --report-file=qip:${quartusdir}/${qsysfilebase}/synthesis/${qsysfilebase}.qip \ + --component-file=${quartusdir}/${qsysfile} +fi hdl_info $0 "QSYS generated successfully." # Additionally build the UNBOS App here as well: diff --git a/quartus/run_qsys_tool b/quartus/run_qsys_tool index 23c8a7a..5240285 100755 --- a/quartus/run_qsys_tool +++ b/quartus/run_qsys_tool @@ -32,7 +32,7 @@ if [ "${BUILDSET}" = "" ]; then fi # Select output directory for the library compilation results -buildset_config_file="${HDL_CONFIG_DIR}/hdl_buildset_${BUILDSET}.cfg" +buildset_config_file="${RADIOHDL_CONFIG}/hdl_buildset_${BUILDSET}.cfg" if [ ! -f $buildset_config_file ]; then hdl_error $0 "File '$buildset_config_file' does not exist" fi @@ -42,7 +42,7 @@ echo "Setting up environment for: ${BUILDSET}" . ${RADIOHDL_GEAR}/set_config_variable $verbose $buildset_config_file quartus_dir # Adopt quartus installation dependend directories -quartus_config_file="${HDL_CONFIG_DIR}/hdl_tool_quartus.cfg" +quartus_config_file="${RADIOHDL_CONFIG}/hdl_tool_quartus.cfg" . ${RADIOHDL_GEAR}/set_config_variable $verbose $quartus_config_file sopc_paths hdl_info $0 "Starting ${SOPC_PATHS}/qsys_edit" diff --git a/quartus/set_quartus b/quartus/set_quartus index 111d91c..cdfa84d 100755 --- a/quartus/set_quartus +++ b/quartus/set_quartus @@ -40,7 +40,7 @@ if [ "${BUILDSET}" = "" ]; then fi # Select output directory for the library compilation results -buildset_config_file="${HDL_CONFIG_DIR}/hdl_buildset_${BUILDSET}.cfg" +buildset_config_file="${RADIOHDL_CONFIG}/hdl_buildset_${BUILDSET}.cfg" if [ ! -f $buildset_config_file ]; then hdl_error $0 "File '$buildset_config_file' does not exist" fi @@ -52,7 +52,7 @@ echo "Setting up quartus for: ${BUILDSET}" . ${RADIOHDL_GEAR}/set_config_variable $verbose $buildset_config_file ${SYNTH_TOOL_NAME}_dir # Adopt quartus installation dependend directories -quartus_config_file="${HDL_CONFIG_DIR}/hdl_tool_quartus.cfg" +quartus_config_file="${RADIOHDL_CONFIG}/hdl_tool_quartus.cfg" . ${RADIOHDL_GEAR}/set_config_variable $verbose $quartus_config_file quartus_rootdir,quartus_rootdir_override,niosdir # Extend the PATH for quartus @@ -88,7 +88,7 @@ done # TODO: move to hdl_tool_quartus.cfg : user_environment_variables ??? -export HDL_SVN_REVISION=`svn info $RADIOHDL_WORK | grep Revision` +export RADIOHDL_GIT_REVISION=`cd $RADIOHDL_WORK; git describe; cd - | grep V` export UNB_COMPILE_STAMPS=1 unset buildset_config_file quartus_config_file bd_name verbose -- GitLab