URL
https://opencores.org/ocsvn/radiohdl/radiohdl/trunk
Subversion Repositories radiohdl
[/] [radiohdl/] [trunk/] [quartus/] [run_reg] - Rev 7
Go to most recent revision | Compare with Previous | Blame | View Log
#!/bin/bash -eu
# -------------------------------------------------------------------------- #
#
# 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/>.
#
# -------------------------------------------------------------------------- #
# Run this tool with at least the commandline arguments:
# run_reg buildset design_name
# example:
# run_reg unb2 unb2_minimal
# read generic functions/definitions
. ${RADIOHDL_GEAR}/generic.sh
# helper function for command parsing
exit_with_error() {
hdl_error_noexit $0 "$@"
cat <<@EndOfHelp@
Usage: $(basename $0) buildset project [options]
Arguments: buildset Name of the buildset to create the registermap for.
project Project file to use.
Options: --rev=* which revision to use.
--> Note: It does not matter where the options are placed: before, in between or after the arguments.
@EndOfHelp@
exit 1
}
# parse cmdline
POSITIONAL=()
rev=
while [[ $# -gt 0 ]]
do
case $1 in
--rev=*)
rev=${1#*=}
;;
-*|--*)
exit_with_error "Unknown option: "$1
;;
*) POSITIONAL+=("$1")
;;
esac
shift
done
if [ ${#POSITIONAL[@]} -gt 0 ]; then
set -- "${POSITIONAL[@]}"
fi
# check the positional parameters
if [ $# -ne 2 ]; then
exit_with_error "Wrong number of arguments specified."
fi
buildset=$1
project=$2
# read in the configuration based on the user arguments
. ${RADIOHDL_GEAR}/quartus/set_quartus ${buildset}
# check projectfile
PRJS="${RADIOHDL_BUILD_DIR}"
PRJ=
for prj in ${PRJS}
do
if [ -d "${prj}/${buildset}/quartus/${project}" ]; then
PRJ=${prj}
fi
done
if [ -z "${project}" -o -z "${PRJ}" ]; then
hdl_error $0 "Please enter a valid project name"
fi
quartusdir="${PRJ}/${buildset}/quartus/${project}"
builddir="${quartusdir}/software"
bspdstdir="${builddir}/bsp"
if [ -z "${rev}" ]; then
project_rev="${project}"
hdl_info $0 "No project revision passed, defaulting to ${project_rev}"
else
if [ -f "${quartusdir}/${rev}.qsf" ]; then
project_rev="${rev}"
hdl_info $0 "Selecting project revision ${project_rev}"
else
hdl_error $0 "Invalid project revision"
fi
fi
system_h=${bspdstdir}/system.h
if [ ! -f "${system_h}" ]; then
hdl_error $0 "system.h file not found in [${bspdstdir}]"
fi
hdl_info $0 "Extracting peripherals from ${bspdstdir}/system.h:"
# Extract lines with 'BASE' or 'SPAN', remove ALT* stuff etc., remove '0x' prefix, remove '#define' and peripheral name preceding '_SPAN', remove '_BASE', finally replace newlines with spaces.
egrep "BASE|SPAN" ${system_h} | egrep -v 'ALT|TIMER|SYSTEM_INFO|ONCHIP_MEMORY2_0|JTAG_UART' | sed -e "s/\0x//g" | sed 's/^#define //' | sed 's/^.*_SPAN //' | sed -e "s/\_BASE//g" | sed ':a;N;$!ba;s/\n/ /g' > ${quartusdir}/${project_rev}.reg
cat ${quartusdir}/${project_rev}.reg
# Add a null character to the end of the file.
printf '\0' >> ${quartusdir}/${project_rev}.reg
# sed: extract first number on the line (returned by wc) = size
size=`wc -c ${quartusdir}/${project_rev}.reg | sed 's/\([0-9]*\).*/\1/'`
# See if byte size happens to be on word boundary, if not pad with more null characters
while [ $(( $size % 4 )) -ne 0 ]
do
printf '\0' >> ${quartusdir}/${project_rev}.reg
size=`wc -c ${quartusdir}/${project_rev}.reg | sed 's/\([0-9]*\).*/\1/'`
done
hdl_info $0 "Created ${quartusdir}/${project_rev}.reg"
hdl_info $0 "Size of ${project_rev}.reg: ${size} bytes"
hdl_exec $0 msg="Calling run_mif to convert ${project_rev}.reg to ${project_rev}.mif" run_mif ${buildset} ${project} ${rev}
hdl_info $0 "Done"
Go to most recent revision | Compare with Previous | Blame | View Log