Advertisement
Guest User

Untitled

a guest
May 27th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # ========================================
  3. #
  4. # Author : William Liao
  5. # Date : 2017.05.21
  6. #
  7. # Find GTECH in final netlist
  8. #
  9. # Put this file in this path:
  10. # PROJECT/trunk/asic/SYN/net
  11. #
  12. # It will generate the output file:
  13. # search_GTECH_result
  14. #
  15. # There is no need to check "*.elab.vg"
  16. # since the 'elab' files are temp files!
  17. #
  18. # This script will search GTECH in
  19. # every 'final' netlist.
  20. #
  21. # ========================================
  22.  
  23.  
  24. Search() {
  25. # Detect the command 'rg' exist or not
  26. if hash rg 2> /dev/null; then
  27. printf "$ rg '%s' ${RED}%s${NC} :\n" "$1" "$2"
  28. printf "%s\n" -----------------------------------------
  29. rg --color=always -n "$@"
  30. printf "%s\n\n" -----------------------------------------
  31. else
  32. printf "$ grep --color=always -n '%s' ${RED}%s${NC} :\n" "$1" "$2"
  33. printf "%s\n" -----------------------------------------
  34. grep --color=always -n "$@"
  35. printf "%s\n\n" -----------------------------------------
  36. fi
  37. }
  38.  
  39.  
  40. # Files
  41. TEMP='temp_file'
  42. RESULT='search_GTECH_result'
  43.  
  44.  
  45. # Find all netlist but remove the temp files and shell netlists
  46. # in the current directory
  47. ALL_NETLIST='*.vg'
  48. TMP_NETLIST='elab'
  49. SHELL_NETLIST='shell'
  50. # Store all output from command 'find' to an array
  51. NETLIST=( $(find . -maxdepth 1 -name "${ALL_NETLIST}" | sed "/${TMP_NETLIST}/d;/${SHELL_NETLIST}/d") )
  52.  
  53. # Check whether array is empty or not
  54. if [ ${#NETLIST[@]} -eq 0 ]; then
  55. echo 'There are no files to be checked!'
  56. exit
  57. else
  58. echo -e 'Start checking...\n'
  59. fi
  60.  
  61.  
  62. # Create a new temporary file
  63. true > ${TEMP}
  64.  
  65.  
  66. # Search 'GTECH' in those report
  67. for ((index=0; index<${#NETLIST[@]}; index++)); do
  68. # Print this line for debugging
  69. # --------------------------------------------
  70. # echo "NETLIST[$index] => ${NETLIST[$index]}"
  71. # --------------------------------------------
  72.  
  73. # Search 'GTECH' in every 'final' netlist
  74. {
  75. Search 'GTECH' "${NETLIST[$index]}"
  76. } >> ${TEMP}
  77.  
  78. done
  79.  
  80.  
  81. # Show info. in terminal
  82. cat ${TEMP}
  83.  
  84.  
  85. # Remove color
  86. sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" ${TEMP} > ${RESULT}
  87. # Change mode to add readbility
  88. chmod +x ${RESULT}
  89. # Remove temporary file
  90. rm ${TEMP}
  91.  
  92.  
  93. : << Comment
  94. The script will not search the temporary file and shell netlist.
  95.  
  96. ex:
  97. miu_XXX.elab.vg (temporary file)
  98. miu_XXX_shell.vg (shell netlist)
  99. Comment
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement