Skip to content
Snippets Groups Projects

Resolve L2SDP-560

Merged Pieter Donker requested to merge L2SDP-560 into master
3 files
+ 88
61
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 41
27
#!/bin/bash -eu
# -------------------------------------------------------------------------- #
#
# Copyright (C) 2012
# Copyright (C) 2012
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/>
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/>
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# -------------------------------------------------------------------------- #
@@ -87,8 +87,8 @@ for prj in ${PRJS}
do
if [ -d "${prj}/${buildset}/quartus/${project}" ]; then
PRJ=${prj}
fi
done
fi
done
if [ -z "${project}" -o -z "${PRJ}" ]; then
hdl_error $0 "Please enter a valid project name"
fi
@@ -124,7 +124,7 @@ if [ -f "${args_c_dir}/${project}.mmap" ]; then
# keep \n char after each line.
else
echo "DEPTH = 1024;" > ${quartusdir}/${project_rev}.mif
tr '\n' '\0' < ${quartusdir}/${project_rev}.reg > ${quartusdir}/${project_rev}.reg_tmp
cat ${quartusdir}/${project_rev}.reg_tmp > ${quartusdir}/${project_rev}.reg
rm -f ${quartusdir}/${project_rev}.reg_tmp
@@ -134,28 +134,42 @@ echo "ADDRESS_RADIX = DEC;" >> ${quartusdir}/${project_rev}.mif
echo "DATA_RADIX = HEX;" >> ${quartusdir}/${project_rev}.mif
echo "CONTENT BEGIN" >> ${quartusdir}/${project_rev}.mif
hdl_info $0 "Writing ${quartusdir}/${project_rev}.reg contents to ${quartusdir}/${project_rev}.mif"
hdl_info $0 "Compressing ${quartusdir}/${project_rev}.reg contents to ${quartusdir}/${project_rev}.reg.zip"
run_zip.py -f ${quartusdir}/${project_rev}.reg
reg_file=${quartusdir}/${project_rev}.reg.z
hdl_info $0 "Writing ${quartusdir}/${project_rev}.reg.zip contents to ${quartusdir}/${project_rev}.mif"
address=0
charcnt=0
while IFS= read -r -d $'\0' -n1 char
while read char
do
# 4 bytes per word address: print one address per 4 chars
if [ $charcnt -eq 0 ] ; then
if [ $(( $charcnt % 4 )) -eq 0 ] ; then
printf "%s" "$address" >> ${quartusdir}/${project_rev}.mif
printf " : " >> ${quartusdir}/${project_rev}.mif
fi
ord "${char}" >> ${quartusdir}/${project_rev}.mif
charcnt=`expr $charcnt + 1`
printf "%02x" ${char} >> ${quartusdir}/${project_rev}.mif
export charcnt=`expr $charcnt + 1`
# last char of word, print semicolon and newline, increment word address
if [ $(( $charcnt % 4 )) -eq 0 ] ; then
printf ";\n" >> ${quartusdir}/${project_rev}.mif
address=`expr $address + 1`
charcnt=0
fi
done < "${reg_file}"
done <<< "$(hexdump -v -e '/1 "%u\n"' "${reg_file}")"
# if not word alligned ad last bytes
while [ $(( $charcnt % 4 )) -ne 0 ]
do
printf "%02x" 0 >> ${quartusdir}/${project_rev}.mif
charcnt=`expr $charcnt + 1`
if [ $(( $charcnt % 4 )) -eq 0 ] ; then
printf ";\n" >> ${quartusdir}/${project_rev}.mif
fi
done
printf "\n" >> ${quartusdir}/${project_rev}.mif
echo "END;" >> ${quartusdir}/${project_rev}.mif
Loading