From 09b3d51015186a3a9f1dbc9e25eae1bdc948f999 Mon Sep 17 00:00:00 2001 From: "(Tim) Efthimis Kritikos" Date: Thu, 9 Nov 2023 23:09:50 +0000 Subject: [PATCH] Added statistics to place&route --- system/Makefile | 5 ++-- tools/parse_nextpnr_stats.sh | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100755 tools/parse_nextpnr_stats.sh diff --git a/system/Makefile b/system/Makefile index b426cba..e8ca364 100644 --- a/system/Makefile +++ b/system/Makefile @@ -66,7 +66,7 @@ else $(error invalid ECP5 device ${ECP5_DEVICE}) endif -ECP5_TARGETS=synth_ecp5.json synth_ecp5_out.config synth_ecp5.bit synth_ecp5.dfu +ECP5_TARGETS=synth_ecp5.json synth_ecp5_out.config synth_ecp5.bit synth_ecp5.dfu synth_pnr_report.json ECP5_TARGETS+=abc.history # created from yosys EXTRA_SYNTHESIS_SOURCES=peripherals/I2C_driver.v peripherals/ascii_to_HD44780_driver.v peripherals/pcf8574_for_HD44780.v @@ -78,7 +78,8 @@ synth_ecp5.json: ${SOURCES} ${TOP_LEVEL_SOURCE} fpga_config/${FPGA_BOARD}/fpga_t synth_ecp5_out.config:synth_ecp5.json ${QUIET_NEXTPNR} - ${Q} nextpnr-ecp5 --Werror -q --json $< --textcfg $@ ${NEXTPNR_ECP5_DEV} --package ${ECP5_PACKAGE} --lpf fpga_config/${FPGA_BOARD}/pin_constraint.pcf + ${Q} nextpnr-ecp5 --Werror -q --json $< --textcfg $@ ${NEXTPNR_ECP5_DEV} --package ${ECP5_PACKAGE} --lpf fpga_config/${FPGA_BOARD}/pin_constraint.pcf --report=synth_pnr_report.json + ${Q}../tools/parse_nextpnr_stats.sh --brief synth_pnr_report.json synth_ecp5.bit:synth_ecp5_out.config ${QUIET_ECPPACK} diff --git a/tools/parse_nextpnr_stats.sh b/tools/parse_nextpnr_stats.sh new file mode 100755 index 0000000..99532f7 --- /dev/null +++ b/tools/parse_nextpnr_stats.sh @@ -0,0 +1,49 @@ +#!/bin/sh +set -eu + +if ! which jq &> /dev/null +then + echo to get stastics, please install jq + exit 0 +fi + +REPORT_TYPE=brief + +if [ $# == 0 ] +then + echo $0' [report type] ' + exit 1 +elif [ $# == 2 ] +then + case "$1" in + "--brief") + REPORT_TYPE=brief + ;; + *) + echo unkown parameter "\"$1\"" + exit 1 + ;; + esac + REPORT=$2 +else + REPORT=$1 +fi + +if ! [ -e "$REPORT" ] +then + echo file "\"${REPORT}\"" doesn\'t exist! + exit 1 +fi + +LUT_AVAIL=$(jq '.utilization.TRELLIS_COMB.available' "$REPORT" ) +LUT_USED=$(jq '.utilization.TRELLIS_COMB.used' "$REPORT" ) +FF_AVAIL=$(jq '.utilization.TRELLIS_FF.available' "$REPORT" ) +FF_USED=$(jq '.utilization.TRELLIS_FF.used' "$REPORT" ) + +if [ "$REPORT_TYPE" == "brief" ] +then + printf '\e[1;30m' + echo Luts $LUT_USED/$LUT_AVAIL \($(echo "($LUT_USED*100)/$LUT_AVAIL"|bc -l|grep -o '^.*\..')%\) + echo Flip Flops $FF_USED/$FF_AVAIL \($(echo "($FF_USED*100)/$FF_AVAIL"|bc -l|grep -o '^.*\..')%\) + printf '\e[0m' +fi