53 lines
1.6 KiB
Bash
Executable file
53 lines
1.6 KiB
Bash
Executable file
#!/bin/bash
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
# See Notices.txt for copyright information
|
|
|
|
set -e
|
|
|
|
function usage()
|
|
{
|
|
echo "usage: $0 <path-to-prjxray-db> <path-to-nextpnr-xilinx-source-code> <path-to-nextpnr-xilinx-output-directory> <device> <device> ..."
|
|
echo
|
|
echo "example: $0 /opt/fayalite-deps/prjxray-db /build/nextpnr-xilinx /opt/fayalite-deps/nextpnr-xilinx xc7a35tcsg324-1 xc7a100tcsg324-1"
|
|
}
|
|
|
|
case "$*" in
|
|
-h*|--help*)
|
|
usage
|
|
exit
|
|
;;
|
|
"")
|
|
usage >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
prjxray_db_path="$1"
|
|
nextpnr_xilinx_source_path="$2"
|
|
nextpnr_xilinx_output_path="$3"
|
|
|
|
if [[ ! ( -d "$prjxray_db_path" && -d "$nextpnr_xilinx_source_path" && ( ! -e "$nextpnr_xilinx_output_path" || -d "$nextpnr_xilinx_output_path" ) ) ]]; then
|
|
echo "invalid/nonexistent paths $prjxray_db_path $nextpnr_xilinx_source_path" >&2
|
|
usage >&2
|
|
exit 1
|
|
elif ! python3 --version > /dev/null; then
|
|
echo "can't run python3" >&2
|
|
usage >&2
|
|
exit 1
|
|
elif ! bbasm --help > /dev/null; then
|
|
echo "can't run bbasm" >&2
|
|
usage >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$nextpnr_xilinx_output_path/xilinx"
|
|
|
|
cd "$nextpnr_xilinx_source_path"
|
|
|
|
for device in "${@:4}"; do
|
|
[[ "$device" =~ ^('xc7'[aksz][0-9]+'t'?)[^t0-9/].*$ ]] || { echo "invalid device: $device" >&2; exit 1; }
|
|
xray_device="${BASH_REMATCH[1]}"
|
|
python3 "$nextpnr_xilinx_source_path/xilinx/python/bbaexport.py" --device "$device" --bba "$nextpnr_xilinx_output_path/xilinx/$xray_device.bba"
|
|
bbasm --l "$nextpnr_xilinx_output_path/xilinx/$xray_device.bba" "$nextpnr_xilinx_output_path/xilinx/$xray_device.bin"
|
|
echo "finished $device"
|
|
done
|