OpenCores
URL https://opencores.org/ocsvn/radiohdl/radiohdl/trunk

Subversion Repositories radiohdl

[/] [radiohdl/] [trunk/] [quartus/] [run_qsys] - Rev 4

Compare with Previous | Blame | View Log

#!/bin/bash -eu
# -------------------------------------------------------------------------- #
#
# Copyright (C) 2010                                                        
# 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 the commandline arguments:
#   run_qsys buildset design_name
# example:
#   run_qsys unb2 unb2_minimal_qsys

# read generic functions/definitions
. ${RADIOHDL_GEAR}/generic.sh

if [ $# -ne 2 ] && [ $# -ne 3 ]; then
    hdl_error $0 "Syntax: run_qsys <buildset> <project> [<qsysfile>]"
fi

buildset=$1
project=$2
qsysfile=${3:+$3}

# read in the configuration based on the user arguments
. ${RADIOHDL_GEAR}/quartus/set_quartus ${buildset}

# search for existing project directory
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

# Fconstruct the name of quartusdir and check if it exists
quartusdir="${PRJ}/${buildset}/quartus/${project}"
hdl_exec $0 msg=no test -d ${quartusdir}

# The QSYS file is optional. If it is omitted choose the first
# one we find. Let user know we do this
set +e
if [ -z "${qsysfile}" ]; then
    qsysfile=$(ls ${quartusdir}/*qsys 2>/dev/null | sed -n 1p)
    if [ -z "${qsysfile}" ]; then
        hdl_error $0 "No QSYS files found in ${quartusdir}"
    fi
fi 
set -e
qsysfile=`basename ${qsysfile}`
qsysfilebase=`basename ${qsysfile} .qsys`
if [ "${3:+$3}" != "${qsysfile}" ]; then
    hdl_info $0 "SELECTING DEFAULT QSYS FILE ${qsysfile} (${qsysfilebase})"
fi
if [ ! -f "${quartusdir}/${qsysfile}" ]; then
    hdl_error $0 "QSYS file '${qsysfile}' not found in ${quartusdir}"
fi

# Great. Having asserted our preconditions, let's do it!
# note: we want hdl_exec to display a slightly different msg
#       AND ip-generate returns exitcode 4 on succesfull completion
#           rather than the standard 0 ...
cd ${quartusdir}
txt="Generating QSYS system for project ${project}."

# Note: ip-generate does NOT look in user_components.ipx in the users home directory!

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:
. ${RADIOHDL_GEAR}/set_hdllib_variable ${buildset} ${project} nios2_app_userflags
if [ -n "${nios2_app_userflags}" ]; then
    hdl_info $0 "Additionally building the UNBOS App."
    ${RADIOHDL_GEAR}/quartus/run_app_clean ${buildset} ${project}
    ${RADIOHDL_GEAR}/quartus/run_app ${buildset} ${project} --userflags=${nios2_app_userflags}
fi

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.