picorv32/scripts/quartus/tabtest.sh

79 lines
2.0 KiB
Bash
Raw Normal View History

2016-08-30 00:12:08 -04:00
#!/bin/bash
set -e
read _ ip dev grade _ < <( echo $* | tr '_/' ' '; )
# rm -rf tab_${ip}_${dev}_${grade}
mkdir -p tab_${ip}_${dev}_${grade}
cd tab_${ip}_${dev}_${grade}
2016-08-30 02:22:53 -04:00
max_speed=99
min_speed=01
2016-08-30 00:12:08 -04:00
best_speed=99
synth_case() {
if [ -f test_${1}.txt ]; then
echo "Reusing cached tab_${ip}_${dev}_${grade}/test_${1}."
return
fi
case "${dev}" in
2016-08-30 02:22:53 -04:00
ep4ce) al_device="ep4ce30f23${grade}" ;;
ep4cgx) al_device="ep4cgx50df27${grade}" ;;
5cgx) al_device="5cgxbc9c6f23${grade}" ;;
2016-08-30 00:12:08 -04:00
esac
2016-08-30 01:14:39 -04:00
cat > test_${1}.qsf <<- EOT
set_global_assignment -name DEVICE ${al_device}
set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files
set_global_assignment -name TOP_LEVEL_ENTITY top
set_global_assignment -name VERILOG_FILE ../tabtest.v
set_global_assignment -name VERILOG_FILE ../../../picorv32.v
set_global_assignment -name SDC_FILE test_${1}.sdc
2016-08-30 00:12:08 -04:00
EOT
2016-08-30 01:14:39 -04:00
cat > test_${1}.sdc <<- EOT
2016-08-30 00:12:08 -04:00
create_clock -period ${speed%?}.${speed#?} [get_ports clk]
EOT
echo "Running tab_${ip}_${dev}_${grade}/test_${1}.."
2016-08-30 01:14:39 -04:00
2016-08-31 01:23:50 -04:00
if ! $QUARTUS_BIN/quartus_map test_${1}; then
2016-08-30 02:22:53 -04:00
exit 1
fi
2016-08-31 01:23:50 -04:00
if ! $QUARTUS_BIN/quartus_fit --read_settings_files=off --write_settings_files=off test_${1} -c test_${1}; then
2016-08-30 02:22:53 -04:00
exit 1
fi
2016-08-31 01:23:50 -04:00
if ! $QUARTUS_BIN/quartus_sta test_${1} -c test_${1}; then
2016-08-30 02:22:53 -04:00
exit 1
fi
2016-08-30 01:14:39 -04:00
2016-08-30 02:22:53 -04:00
cp output_files/test_${1}.sta.summary test_${1}.txt
2016-08-30 00:12:08 -04:00
}
2016-08-30 11:08:10 -04:00
countdown=7
2016-08-30 00:12:08 -04:00
while [ $countdown -gt 0 ]; do
2016-08-30 02:22:53 -04:00
speed=$(((max_speed+min_speed)/2))
2016-08-30 00:12:08 -04:00
synth_case $speed
2016-08-30 02:22:53 -04:00
if grep -q '^Slack : -' test_${speed}.txt; then
2016-08-30 00:12:08 -04:00
echo " tab_${ip}_${dev}_${grade}/test_${speed} VIOLATED"
2016-08-30 02:22:53 -04:00
min_speed=$((speed))
elif grep -q '^Slack : [^-]' test_${speed}.txt; then
2016-08-30 00:12:08 -04:00
echo " tab_${ip}_${dev}_${grade}/test_${speed} MET"
[ $speed -lt $best_speed ] && best_speed=$speed
2016-08-30 02:22:53 -04:00
max_speed=$((speed))
2016-08-30 00:12:08 -04:00
else
echo "ERROR: No slack line found in $PWD/test_${speed}.txt!"
exit 1
fi
2016-08-30 02:22:53 -04:00
countdown=$((countdown-1))
2016-08-30 00:12:08 -04:00
done
echo "-----------------------"
echo "Best speed for tab_${ip}_${dev}_${grade}: $best_speed"
echo "-----------------------"
echo $best_speed > results.txt