1 |
4 |
danv |
#!/bin/bash -eu
|
2 |
|
|
###############################################################################
|
3 |
|
|
#
|
4 |
|
|
# Copyright (C) 2014
|
5 |
|
|
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
6 |
|
|
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
7 |
|
|
#
|
8 |
|
|
# This program is free software: you can redistribute it and/or modify
|
9 |
|
|
# it under the terms of the GNU General Public License as published by
|
10 |
|
|
# the Free Software Foundation, either version 3 of the License, or
|
11 |
|
|
# (at your option) any later version.
|
12 |
|
|
#
|
13 |
|
|
# This program is distributed in the hope that it will be useful,
|
14 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
# GNU General Public License for more details.
|
17 |
|
|
#
|
18 |
|
|
# You should have received a copy of the GNU General Public License
|
19 |
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20 |
|
|
#
|
21 |
|
|
###############################################################################
|
22 |
|
|
|
23 |
|
|
# Purpose:
|
24 |
|
|
# . Extract columns of interest from Quartus fitter report file
|
25 |
|
|
# Description:
|
26 |
|
|
# . Awk extracts the lines of interest: the resource utilization block
|
27 |
|
|
# . Cut is used to select the right columns (fields -f)
|
28 |
|
|
# . columns are delimited by ';'
|
29 |
|
|
# . Grep is used to extract hierarchical levels up to a certain depth:
|
30 |
|
|
# . Top level line starts with ' |'
|
31 |
|
|
# . One level down starts with ' |'
|
32 |
|
|
# . Two levels down starts with ' |'
|
33 |
|
|
# . The grep argument used to remove lines (e.g. ' |' is stored
|
34 |
|
|
# in REMOVE_LINES.
|
35 |
|
|
|
36 |
|
|
if [ ! -z $1 ]; then
|
37 |
|
|
# $1 was given
|
38 |
|
|
DEPTH=$1
|
39 |
|
|
else
|
40 |
|
|
: # $1 was not given
|
41 |
|
|
echo 'Execute this in the path of a .fit.rpt file.'
|
42 |
|
|
echo 'Usage: ./resources.sh depth columns'
|
43 |
|
|
echo '. Example: ./resources.sh 2 9,10,11,12'
|
44 |
|
|
echo '. depth = n (n=1..max depth): required'
|
45 |
|
|
echo '. columns = 2,3,4,..: optional'
|
46 |
|
|
echo ' . Columns:'
|
47 |
|
|
# echo ' . 2 - Compilation Hierarchy Node' # always selected
|
48 |
|
|
echo ' . 3 - Combinational ALUTs'
|
49 |
|
|
echo ' . 4 - Memory ALUTs'
|
50 |
|
|
echo ' . 5 - LUT_REGs'
|
51 |
|
|
echo ' . 6 - ALMs'
|
52 |
|
|
echo ' . 7 - Dedicated Logic Registers'
|
53 |
|
|
echo ' . 8 - I/O Registers'
|
54 |
|
|
echo ' . 9 - Block Memory Bits'
|
55 |
|
|
echo ' . 10 - M9Ks'
|
56 |
|
|
echo ' . 11 - M144Ks'
|
57 |
|
|
echo ' . 12 - DSP 18-bit Elements'
|
58 |
|
|
echo ' . 13 - DSP 9x9'
|
59 |
|
|
echo ' . 14 - DSP 12x12'
|
60 |
|
|
echo ' . 15 - DSP 18x18'
|
61 |
|
|
echo ' . 16 - DSP 36x36'
|
62 |
|
|
echo ' . 17 - Pins'
|
63 |
|
|
echo ' . 18 - Virtual Pins'
|
64 |
|
|
echo ' . 19 - Combinational with no register ALUT/register pair'
|
65 |
|
|
echo ' . 20 - Register-Only ALUT/register pair'
|
66 |
|
|
echo ' . 21 - Combinational with a register ALUT/register pair'
|
67 |
|
|
echo ' . 22 - Full Hierarchy Name'
|
68 |
|
|
echo ' . 23 - Library Name '
|
69 |
|
|
echo
|
70 |
|
|
echo 'Use grep to get only the info you want.'
|
71 |
|
|
exit 1
|
72 |
|
|
fi
|
73 |
|
|
|
74 |
|
|
if [ ! -z $2 ]; then
|
75 |
|
|
: # $2 was given
|
76 |
|
|
COLUMNS=$2
|
77 |
|
|
else
|
78 |
|
|
: # $2 was not given
|
79 |
|
|
COLUMNS=3,4,5,6,7,8,9,10,11,12,13,14,15,16
|
80 |
|
|
fi
|
81 |
|
|
|
82 |
|
|
RPT_FILE_COUNT=`ls -1 *.fit.rpt 2>/dev/null | wc -l`
|
83 |
|
|
if [ $RPT_FILE_COUNT = 0 ]; then
|
84 |
|
|
echo 'No .fit.rpt file found!'
|
85 |
|
|
exit 1
|
86 |
|
|
fi
|
87 |
|
|
|
88 |
|
|
RPT_FILE=*.fit.rpt
|
89 |
|
|
NOF_SPACES=$(expr 3 \* $DEPTH - 2) # nof_spaces = 3*DEPTH-2
|
90 |
|
|
REMOVE_LINES=`for i in $(eval echo {0..$NOF_SPACES}); do echo -n ' '; done`'|'
|
91 |
|
|
|
92 |
|
|
# print the rouseource utilization block only | only columns of interest | no long rows of dashes | X levels deep | remove the first long line
|
93 |
|
|
awk '/; Fitter Resource Utilization by Entity/,/Note:/' $RPT_FILE | cut -d';' -f2,$COLUMNS | grep ';' | grep -v "$REMOVE_LINES" | grep -v 'Resource Utilization'
|
94 |
|
|
|
95 |
|
|
exit 0
|