picorv32/scripts/quartus/tabtest.sh

79 lines
2.0 KiB
Bash
Raw Normal View History

2016-08-30 12:12:08 +08: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 14:22:53 +08:00
max_speed=99
min_speed=01
2016-08-30 12:12:08 +08: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 14:22:53 +08:00
ep4ce) al_device="ep4ce30f23${grade}" ;;
ep4cgx) al_device="ep4cgx50df27${grade}" ;;
5cgx) al_device="5cgxbc9c6f23${grade}" ;;
2016-08-30 12:12:08 +08:00
esac
2016-08-30 13:14:39 +08: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 12:12:08 +08:00
EOT
2016-08-30 13:14:39 +08:00
cat > test_${1}.sdc <<- EOT
2016-08-30 12:12:08 +08:00
create_clock -period ${speed%?}.${speed#?} [get_ports clk]
EOT
echo "Running tab_${ip}_${dev}_${grade}/test_${1}.."
2017-06-07 23:05:19 +08:00
2016-08-31 13:23:50 +08:00
if ! $QUARTUS_BIN/quartus_map test_${1}; then
2016-08-30 14:22:53 +08:00
exit 1
fi
2016-08-31 13:23:50 +08:00
if ! $QUARTUS_BIN/quartus_fit --read_settings_files=off --write_settings_files=off test_${1} -c test_${1}; then
2016-08-30 14:22:53 +08:00
exit 1
fi
2016-08-31 13:23:50 +08:00
if ! $QUARTUS_BIN/quartus_sta test_${1} -c test_${1}; then
2016-08-30 14:22:53 +08:00
exit 1
fi
2017-06-07 23:05:19 +08:00
2016-08-30 14:22:53 +08:00
cp output_files/test_${1}.sta.summary test_${1}.txt
2016-08-30 12:12:08 +08:00
}
2016-08-30 23:08:10 +08:00
countdown=7
2016-08-30 12:12:08 +08:00
while [ $countdown -gt 0 ]; do
2016-08-30 14:22:53 +08:00
speed=$(((max_speed+min_speed)/2))
2016-08-30 12:12:08 +08:00
synth_case $speed
2016-08-30 14:22:53 +08:00
if grep -q '^Slack : -' test_${speed}.txt; then
2016-08-30 12:12:08 +08:00
echo " tab_${ip}_${dev}_${grade}/test_${speed} VIOLATED"
2016-08-30 14:22:53 +08:00
min_speed=$((speed))
elif grep -q '^Slack : [^-]' test_${speed}.txt; then
2016-08-30 12:12:08 +08:00
echo " tab_${ip}_${dev}_${grade}/test_${speed} MET"
[ $speed -lt $best_speed ] && best_speed=$speed
2016-08-30 14:22:53 +08:00
max_speed=$((speed))
2016-08-30 12:12:08 +08:00
else
echo "ERROR: No slack line found in $PWD/test_${speed}.txt!"
exit 1
fi
2016-08-30 14:22:53 +08:00
countdown=$((countdown-1))
2016-08-30 12:12:08 +08:00
done
echo "-----------------------"
echo "Best speed for tab_${ip}_${dev}_${grade}: $best_speed"
echo "-----------------------"
echo $best_speed > results.txt