diff --git a/build.sh b/build.sh index 9f5b78a..1fde564 100755 --- a/build.sh +++ b/build.sh @@ -8,6 +8,7 @@ PACKAGE_FILE_NAME="sc64-extra" TOP_FILES=( "./fw/ftdi/ft232h_config.xml" + "./fw/project/lcmxo2/impl1/fpga_max_frequency.txt" "./sw/tools/primer.py" "./sw/tools/requirements.txt" "./sc64-firmware-${SC64_VERSION}.bin" @@ -90,6 +91,7 @@ build_update () { rm -f ../../sc64-firmware-*.bin fi GIT_INFO="" + GIT_INFO+=$'\n'"freq: $(cat ../../fw/project/lcmxo2/impl1/fpga_max_frequency.txt)" if [ ! -z "${SC64_VERSION}" ]; then GIT_INFO+=$'\n'"ver: $SC64_VERSION"; fi if [ ! -z "${GIT_BRANCH}" ]; then GIT_INFO+=$'\n'"branch: $GIT_BRANCH"; fi if [ ! -z "${GIT_TAG}" ]; then GIT_INFO+=$'\n'"tag: $GIT_TAG"; fi diff --git a/fw/project/lcmxo2/build.sh b/fw/project/lcmxo2/build.sh index 35a8b44..ebe6849 100755 --- a/fw/project/lcmxo2/build.sh +++ b/fw/project/lcmxo2/build.sh @@ -1,5 +1,31 @@ #!/bin/bash +set -e + source $bindir/diamond_env diamondc build.tcl + +MINIMUM_FREQ=$(cat impl1/sc64_impl1.twr \ + | grep 'Preference: FREQUENCY NET "clk"' \ + | head -1 \ + | awk -F ' ' '{print $5}' \ +) + +DESIGN_FREQ=$(cat impl1/sc64_impl1.twr \ + | sed -n '/Preference: FREQUENCY NET "clk"/,$p' \ + | grep 'is the maximum frequency for this preference' \ + | head -1 \ + | awk -F ' ' '{print $2}' \ + | sed 's/MHz//' \ +) + +echo "Minimum required frequency: $MINIMUM_FREQ MHz" +echo "Maximum design frequency: $DESIGN_FREQ MHz" + +if (( $(echo "$DESIGN_FREQ < $MINIMUM_FREQ" | bc -l) )); then + echo "Timing error detected, build failed" + exit 1 +fi + +echo -n "$DESIGN_FREQ MHz" > impl1/fpga_max_frequency.txt