[85] | 1 | #!/bin/bash |
---|
| 2 | |
---|
[82] | 3 | #----------------------------------------------------------- |
---|
| 4 | # $Id: xilinx_extract_info.sh 145 2010-10-13 18:15:51Z rosiere $ |
---|
| 5 | #----------------------------------------------------------- |
---|
[71] | 6 | |
---|
[100] | 7 | ##-----[ usage ]--------------------------------------------- |
---|
| 8 | #function usage () |
---|
| 9 | #{ |
---|
| 10 | # echo "Usage : ${0} [files]"; |
---|
| 11 | # echo "Arguments : "; |
---|
| 12 | # echo ' * files : lists of files. If empty, take *.fpga.log'; |
---|
| 13 | ## echo "Notes :"; |
---|
| 14 | ## echo " * Morpheo's environnement must be positionned."; |
---|
| 15 | # |
---|
| 16 | # exit; |
---|
| 17 | #} |
---|
| 18 | |
---|
[138] | 19 | #-----[ xilinx_extract_info_usage ]------------------------- |
---|
| 20 | function xilinx_extract_info_usage() |
---|
[100] | 21 | { |
---|
[138] | 22 | echo "${0} option [files]"; |
---|
| 23 | echo "Arguments : "; |
---|
| 24 | echo ' * files : lists of files. If empty, take *.fpga.log'; |
---|
| 25 | echo " * -s : print summary section"; |
---|
| 26 | echo " * -t : print timing section"; |
---|
| 27 | exit 1; |
---|
[100] | 28 | } |
---|
| 29 | |
---|
[138] | 30 | #-----[ xilinx_extract_info_summary ]----------------------- |
---|
| 31 | function xilinx_extract_info_summary () |
---|
| 32 | { |
---|
| 33 | summary_line_begin=$(grep -n "Device utilization summary:" ${1} | cut -d : -f 1); |
---|
| 34 | summary_line_end=$(grep -n "Partition Resource Summary:" ${1} | cut -d : -f 1); |
---|
| 35 | |
---|
[145] | 36 | if test "${summary_line_begin}" != "" -a "${summary_line_end}" != ""; then |
---|
| 37 | head -n $(($summary_line_end-1)) ${1} | tail -n $(($summary_line_end-$summary_line_begin)); |
---|
| 38 | fi; |
---|
[138] | 39 | } |
---|
| 40 | |
---|
| 41 | #-----[ xilinx_extract_info_timing ]------------------------ |
---|
| 42 | function xilinx_extract_info_timing () |
---|
| 43 | { |
---|
| 44 | timing_line_begin=$(grep -n "Timing Summary:" ${1} | cut -d : -f 1); |
---|
| 45 | timing_line_end=$(grep -n "Timing Detail:" ${1} | cut -d : -f 1); |
---|
| 46 | |
---|
[145] | 47 | if test "${timing_line_begin}" != "" -a "${timing_line_end}" != ""; then |
---|
| 48 | head -n $(($timing_line_end-1)) ${1} | tail -n $(($timing_line_end-$timing_line_begin)); |
---|
| 49 | fi; |
---|
[138] | 50 | } |
---|
| 51 | |
---|
[100] | 52 | #-----[ main ]---------------------------------------------- |
---|
[138] | 53 | function xilinx_extract_info() |
---|
[100] | 54 | { |
---|
[138] | 55 | local summary=0; |
---|
| 56 | local timing=0; |
---|
| 57 | local nb_params=$#; |
---|
| 58 | set -- $(getopt :tsh "$@") |
---|
| 59 | for arg |
---|
| 60 | do case "$arg" in |
---|
| 61 | -t) timing=1; nb_params=$((nb_params-1));; |
---|
| 62 | -s) summary=1; nb_params=$((nb_params-1));; |
---|
| 63 | -h) xilinx_extract_info_usage ${*}; break;; |
---|
| 64 | --) if test ${summary} -eq 0 -a ${timing} -eq 0; then |
---|
| 65 | summary=1; |
---|
| 66 | timing=1; |
---|
| 67 | fi; |
---|
| 68 | |
---|
| 69 | esac |
---|
| 70 | done |
---|
| 71 | |
---|
| 72 | if test $nb_params -eq 0; then |
---|
[100] | 73 | files="*.fpga.log"; |
---|
| 74 | else |
---|
| 75 | files="$*"; |
---|
| 76 | fi; |
---|
| 77 | |
---|
| 78 | for i in $files; do |
---|
[138] | 79 | if test -f ${i}; then |
---|
| 80 | echo "===================| ${i}"; |
---|
| 81 | |
---|
| 82 | if test ${summary} -ne 0; then |
---|
| 83 | xilinx_extract_info_summary $i; |
---|
| 84 | fi; |
---|
| 85 | if test ${timing} -ne 0; then |
---|
| 86 | xilinx_extract_info_timing $i; |
---|
| 87 | fi; |
---|
| 88 | fi; |
---|
[100] | 89 | done |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | #-----[ Corps ]--------------------------------------------- |
---|
[138] | 93 | xilinx_extract_info ${*} |
---|
[100] | 94 | |
---|