2) added qip files from pei and changed folder structure 3) added files generic_ip, .qip and related files
142 lines
3.5 KiB
Bash
142 lines
3.5 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
BUILD_DIR="${ROOT_DIR}/build"
|
|
TCL_SCRIPT="${SCRIPT_DIR}/create_project.tcl"
|
|
PROJECT_NAME="pei_fpga_project"
|
|
REVISION_NAME="pei_fpga_top"
|
|
OUTPUT_DIR="${BUILD_DIR}/output_files"
|
|
SOF_FILE="${OUTPUT_DIR}/${REVISION_NAME}.sof"
|
|
RBF_FILE="${OUTPUT_DIR}/${REVISION_NAME}.rbf"
|
|
|
|
clean() {
|
|
echo "Cleaning build artefacts..."
|
|
rm -rf "${BUILD_DIR}"
|
|
rm -rf "${ROOT_DIR}/db"
|
|
rm -rf "${ROOT_DIR}/incremental_db"
|
|
rm -rf "${ROOT_DIR}/output_files"
|
|
rm -f "${ROOT_DIR}/${PROJECT_NAME}.qpf"
|
|
rm -f "${ROOT_DIR}/${REVISION_NAME}.qsf"
|
|
rm -f "${ROOT_DIR}/${REVISION_NAME}.qpf"
|
|
echo "Clean complete."
|
|
}
|
|
|
|
sync_generic_ip() {
|
|
mkdir -p "${ROOT_DIR}/generic_ip"
|
|
|
|
if [[ -n "${GENERIC_IP_SRC:-}" ]]; then
|
|
if [[ -d "${GENERIC_IP_SRC}" ]]; then
|
|
echo "Copying generic IP from: ${GENERIC_IP_SRC}"
|
|
cp -a "${GENERIC_IP_SRC}/." "${ROOT_DIR}/generic_ip/"
|
|
else
|
|
echo "Error: GENERIC_IP_SRC does not exist: ${GENERIC_IP_SRC}" >&2
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "GENERIC_IP_SRC not set. Using existing ${ROOT_DIR}/generic_ip content."
|
|
fi
|
|
}
|
|
|
|
require_tool() {
|
|
local tool="$1"
|
|
if ! command -v "${tool}" >/dev/null 2>&1; then
|
|
echo "Error: ${tool} not found in PATH" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
create_project() {
|
|
mkdir -p "${BUILD_DIR}"
|
|
sync_generic_ip
|
|
cd "${BUILD_DIR}"
|
|
require_tool quartus_sh
|
|
|
|
echo "Generating/updating Quartus project..."
|
|
quartus_sh -t "${TCL_SCRIPT}"
|
|
}
|
|
|
|
compile_flow() {
|
|
cd "${BUILD_DIR}"
|
|
require_tool quartus_map
|
|
require_tool quartus_fit
|
|
require_tool quartus_asm
|
|
require_tool quartus_sta
|
|
|
|
echo "Running Analysis & Synthesis..."
|
|
quartus_map "${PROJECT_NAME}" --rev="${REVISION_NAME}"
|
|
|
|
echo "Running Fitter..."
|
|
quartus_fit "${PROJECT_NAME}" --rev="${REVISION_NAME}"
|
|
|
|
echo "Running Assembler..."
|
|
quartus_asm "${PROJECT_NAME}" --rev="${REVISION_NAME}"
|
|
|
|
echo "Running TimeQuest timing analysis..."
|
|
quartus_sta "${PROJECT_NAME}" --rev="${REVISION_NAME}"
|
|
|
|
echo "Quartus compile flow complete."
|
|
}
|
|
|
|
generate_rbf() {
|
|
cd "${BUILD_DIR}"
|
|
require_tool quartus_cpf
|
|
|
|
if [[ ! -f "${SOF_FILE}" ]]; then
|
|
echo "Error: SOF file not found: ${SOF_FILE}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Generating RBF from ${SOF_FILE}..."
|
|
quartus_cpf -c "${SOF_FILE}" "${RBF_FILE}"
|
|
|
|
echo "RBF generated: ${RBF_FILE}"
|
|
}
|
|
|
|
build() {
|
|
create_project
|
|
echo "Project created/updated successfully."
|
|
}
|
|
|
|
full_flow() {
|
|
create_project
|
|
compile_flow
|
|
generate_rbf
|
|
|
|
echo "Full flow completed successfully."
|
|
echo "SOF: ${SOF_FILE}"
|
|
echo "RBF: ${RBF_FILE}"
|
|
}
|
|
|
|
case "${1:-build}" in
|
|
clean)
|
|
clean
|
|
;;
|
|
rebuild)
|
|
clean
|
|
build
|
|
;;
|
|
build)
|
|
build
|
|
;;
|
|
compile)
|
|
create_project
|
|
compile_flow
|
|
;;
|
|
full)
|
|
full_flow
|
|
;;
|
|
rbf)
|
|
generate_rbf
|
|
;;
|
|
*)
|
|
echo "Usage: $0 [build|clean|rebuild|compile|full|rbf]" >&2
|
|
echo " build : create/update project only" >&2
|
|
echo " compile : create/update project + synthesis/fitter/assembler/STA" >&2
|
|
echo " full : compile + generate RBF" >&2
|
|
echo " rbf : generate RBF from existing SOF" >&2
|
|
echo "Optional: set GENERIC_IP_SRC=/path/to/original/generic_ip before build." >&2
|
|
exit 1
|
|
;;
|
|
esac
|