1 |
4 |
danv |
#!/bin/bash -eu
|
2 |
|
|
# -------------------------------------------------------------------------- #
|
3 |
|
|
#
|
4 |
|
|
# Copyright (C) 2010
|
5 |
|
|
# ASTRON (Netherlands Institute for Radio Astronomy)
|
6 |
|
|
# JIVE (Joint Institute for VLBI in Europe)
|
7 |
|
|
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
8 |
|
|
#
|
9 |
|
|
# This program is free software: you can redistribute it and/or modify
|
10 |
|
|
# it under the terms of the GNU General Public License as published by
|
11 |
|
|
# the Free Software Foundation, either version 3 of the License, or
|
12 |
|
|
# (at your option) any later version.
|
13 |
|
|
#
|
14 |
|
|
# This program is distributed in the hope that it will be useful,
|
15 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
|
|
# GNU General Public License for more details.
|
18 |
|
|
#
|
19 |
|
|
# You should have received a copy of the GNU General Public License
|
20 |
|
|
# along with this program. If not, see .
|
21 |
|
|
#
|
22 |
|
|
# -------------------------------------------------------------------------- #
|
23 |
|
|
|
24 |
|
|
# Run this tool with the commandline arguments:
|
25 |
|
|
# run_qsys buildset design_name
|
26 |
|
|
# example:
|
27 |
|
|
# run_qsys unb2 unb2_minimal_qsys
|
28 |
|
|
|
29 |
|
|
# read generic functions/definitions
|
30 |
|
|
. ${RADIOHDL_GEAR}/generic.sh
|
31 |
|
|
|
32 |
|
|
if [ $# -ne 2 ] && [ $# -ne 3 ]; then
|
33 |
|
|
hdl_error $0 "Syntax: run_qsys []"
|
34 |
|
|
fi
|
35 |
|
|
|
36 |
|
|
buildset=$1
|
37 |
|
|
project=$2
|
38 |
|
|
qsysfile=${3:+$3}
|
39 |
|
|
|
40 |
|
|
# read in the configuration based on the user arguments
|
41 |
|
|
. ${RADIOHDL_GEAR}/quartus/set_quartus ${buildset}
|
42 |
|
|
|
43 |
|
|
# search for existing project directory
|
44 |
|
|
PRJS="${RADIOHDL_BUILD_DIR}"
|
45 |
|
|
PRJ=
|
46 |
|
|
for prj in ${PRJS}
|
47 |
|
|
do
|
48 |
|
|
if [ -d "${prj}/${buildset}/quartus/${project}" ]; then
|
49 |
|
|
PRJ=${prj}
|
50 |
|
|
fi
|
51 |
|
|
done
|
52 |
|
|
if [ -z "${project}" -o -z "${PRJ}" ]; then
|
53 |
|
|
hdl_error $0 "Please enter a valid project name"
|
54 |
|
|
fi
|
55 |
|
|
|
56 |
|
|
# Fconstruct the name of quartusdir and check if it exists
|
57 |
|
|
quartusdir="${PRJ}/${buildset}/quartus/${project}"
|
58 |
|
|
hdl_exec $0 msg=no test -d ${quartusdir}
|
59 |
|
|
|
60 |
|
|
# The QSYS file is optional. If it is omitted choose the first
|
61 |
|
|
# one we find. Let user know we do this
|
62 |
|
|
set +e
|
63 |
|
|
if [ -z "${qsysfile}" ]; then
|
64 |
|
|
qsysfile=$(ls ${quartusdir}/*qsys 2>/dev/null | sed -n 1p)
|
65 |
|
|
if [ -z "${qsysfile}" ]; then
|
66 |
|
|
hdl_error $0 "No QSYS files found in ${quartusdir}"
|
67 |
|
|
fi
|
68 |
|
|
fi
|
69 |
|
|
set -e
|
70 |
|
|
qsysfile=`basename ${qsysfile}`
|
71 |
|
|
qsysfilebase=`basename ${qsysfile} .qsys`
|
72 |
|
|
if [ "${3:+$3}" != "${qsysfile}" ]; then
|
73 |
|
|
hdl_info $0 "SELECTING DEFAULT QSYS FILE ${qsysfile} (${qsysfilebase})"
|
74 |
|
|
fi
|
75 |
|
|
if [ ! -f "${quartusdir}/${qsysfile}" ]; then
|
76 |
|
|
hdl_error $0 "QSYS file '${qsysfile}' not found in ${quartusdir}"
|
77 |
|
|
fi
|
78 |
|
|
|
79 |
|
|
# Great. Having asserted our preconditions, let's do it!
|
80 |
|
|
# note: we want hdl_exec to display a slightly different msg
|
81 |
|
|
# AND ip-generate returns exitcode 4 on succesfull completion
|
82 |
|
|
# rather than the standard 0 ...
|
83 |
|
|
cd ${quartusdir}
|
84 |
|
|
txt="Generating QSYS system for project ${project}."
|
85 |
|
|
|
86 |
|
|
# Note: ip-generate does NOT look in user_components.ipx in the users home directory!
|
87 |
|
|
|
88 |
|
|
if [ "${buildset}" = "unb2b" ]; then
|
89 |
|
|
hdl_info $0 "generating QSYS system for unb2b project"
|
90 |
|
|
hdl_exec $0 msg="${txt}" expect=0 qsys-generate ${quartusdir}/${qsysfile} \
|
91 |
|
|
--search-path=${quartusdir}/ip/${qsysfilebase},$ \
|
92 |
|
|
--synthesis=VHDL \
|
93 |
|
|
--block-symbol-file \
|
94 |
|
|
--quartus-project=${quartusdir}/${project}.qpf
|
95 |
|
|
cp ${quartusdir}/${qsysfilebase}/${qsysfilebase}.sopcinfo ${quartusdir}
|
96 |
|
|
cp ${quartusdir}/${qsysfilebase}/${qsysfilebase}.bsf ${quartusdir}
|
97 |
|
|
else
|
98 |
|
|
hdl_info $0 "generate files for simulation"
|
99 |
|
|
hdl_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \
|
100 |
|
|
--output-directory=${quartusdir}/${qsysfilebase}/simulation/ \
|
101 |
|
|
--file-set=SIM_VHDL \
|
102 |
|
|
--report-file=sopcinfo:${quartusdir}/${qsysfilebase}.sopcinfo \
|
103 |
|
|
--report-file=html:${quartusdir}/${qsysfilebase}.html \
|
104 |
|
|
--report-file=csv:${quartusdir}/${qsysfilebase}.csv \
|
105 |
|
|
--report-file=spd:${quartusdir}/${qsysfilebase}.spd \
|
106 |
|
|
--component-file=${quartusdir}/${qsysfile}
|
107 |
|
|
|
108 |
|
|
hdl_info $0 "create modelsim project"
|
109 |
|
|
hdl_exec $0 msg="${txt}" expect=0 sim-script-gen --spd=${quartusdir}/${qsysfilebase}.spd \
|
110 |
|
|
--output-directory=${quartusdir}/${qsysfilebase}/simulation/
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
hdl_info $0 "generate .bsf"
|
114 |
|
|
hdl_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \
|
115 |
|
|
--output-directory=${quartusdir}/${qsysfilebase}/ \
|
116 |
|
|
--report-file=bsf:${quartusdir}/${qsysfilebase}.bsf \
|
117 |
|
|
--component-file=${quartusdir}/${qsysfile}
|
118 |
|
|
|
119 |
|
|
hdl_info $0 "generate HDL files for synthesis"
|
120 |
|
|
hdl_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \
|
121 |
|
|
--output-directory=${quartusdir}/${qsysfilebase}/synthesis/ \
|
122 |
|
|
--file-set=QUARTUS_SYNTH \
|
123 |
|
|
--report-file=sopcinfo:${quartusdir}/${qsysfilebase}.sopcinfo \
|
124 |
|
|
--report-file=html:${quartusdir}/${qsysfilebase}.html \
|
125 |
|
|
--report-file=qip:${quartusdir}/${qsysfilebase}/synthesis/${qsysfilebase}.qip \
|
126 |
|
|
--component-file=${quartusdir}/${qsysfile}
|
127 |
|
|
fi
|
128 |
|
|
hdl_info $0 "QSYS generated successfully."
|
129 |
|
|
|
130 |
|
|
# Additionally build the UNBOS App here as well:
|
131 |
|
|
. ${RADIOHDL_GEAR}/set_hdllib_variable ${buildset} ${project} nios2_app_userflags
|
132 |
|
|
if [ -n "${nios2_app_userflags}" ]; then
|
133 |
|
|
hdl_info $0 "Additionally building the UNBOS App."
|
134 |
|
|
${RADIOHDL_GEAR}/quartus/run_app_clean ${buildset} ${project}
|
135 |
|
|
${RADIOHDL_GEAR}/quartus/run_app ${buildset} ${project} --userflags=${nios2_app_userflags}
|
136 |
|
|
fi
|
137 |
|
|
|