check_files.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #!/bin/bash
  2. dirs_with_no_vhdl_files="
  3. .
  4. vhdl
  5. "
  6. ipcores="
  7. audio_cntrl
  8. math
  9. nes_controller
  10. prng
  11. ram
  12. ball_game
  13. ssd_controller
  14. synchronizer
  15. lcd_graphics_controller
  16. dbg_port
  17. display_switch
  18. top
  19. "
  20. modules_with_makefiles="
  21. top
  22. ssd_controller
  23. nes_controller
  24. lcd_graphics_controller
  25. prng
  26. "
  27. modules_with_makefiles_and_sim_targets="
  28. lcd_graphics_controller
  29. prng
  30. "
  31. modules_with_makefiles_and_sim_gui_targets="
  32. top
  33. ssd_controller
  34. nes_controller
  35. "
  36. files_that_should_exist="
  37. vhdl/ssd_controller/src/ssd_controller.vhd
  38. vhdl/ssd_controller/tb/ssd_controller_tb.vhd
  39. vhdl/prng/tb/prng_tb.vhd
  40. vhdl/lcd_graphics_controller/tb/lcd_graphics_controller_tb.vhd
  41. vhdl/top/src/top.vhd
  42. vhdl/nes_controller/src/nes_controller.vhd
  43. vhdl/nes_controller/tb/nes_controller_tb.vhd
  44. "
  45. if [ "$(echo $1)" == "ex2" ]; then
  46. modules_with_makefiles="$modules_with_makefiles vbs_graphics_controller"
  47. ipcores="$ipcores vbs_graphics_controller gfx_util"
  48. fi;
  49. error_counter=0
  50. warning_counter=0
  51. if [ ! -d vhdl ]; then
  52. echo "Error: vhdl directory missing";
  53. let "error_counter++"
  54. fi;
  55. #check files that should have been created during exercise 1
  56. for f in $files_that_should_exist; do
  57. if [ ! -e "$f" ]; then
  58. echo "Warning: file $f does not exist";
  59. let "warning_counter++"
  60. fi;
  61. done;
  62. for core in $ipcores; do
  63. if [ ! -d vhdl/$core ]; then
  64. echo "Error: module [$core] missing from your source tree";
  65. let "error_counter++"
  66. fi;
  67. done;
  68. for i in $dirs_with_no_vhdl_files; do
  69. for f in $i/*.vhd; do
  70. if [ -e "$f" ]; then
  71. echo "Error: [$f] -- The folder [$i] MUST NOT contain VHDL files. VHDL files may only be put in the src or tb folder of each module";
  72. let "error_counter++"
  73. fi;
  74. break;
  75. done;
  76. done;
  77. for core in $ipcores; do
  78. if [ -e "vhdl/$core" ] && [ $(ls vhdl/$core | grep -i "\.vhd" | wc -l) -ne 0 ]; then
  79. echo "Error: The folder [vhdl/$core] MUST NOT contain VHDL files. VHDL files may only be put in the src or tb folder of each module";
  80. fi;
  81. for d in vhdl/$core/*; do
  82. if [ -d "${d}" ] && [ "$(basename $d)" != "src" ] && [ "$(basename $d)" != "tb" ] ; then
  83. if [ $(ls $d | grep -i ".vhd" | wc -l) -ne 0 ]; then
  84. echo "Error: The folder [$d] MUST NOT contain VHDL files. VHDL files may only be put in the src or tb folder of each module";
  85. fi;
  86. fi
  87. done;
  88. done;
  89. #check makefiles
  90. for i in $modules_with_makefiles; do
  91. if [ ! -e vhdl/$i/Makefile ]; then
  92. echo "Warning: The makefile for module $i is missing!";
  93. let "warning_counter++"
  94. else
  95. for target in compile clean; do
  96. if ! [[ $(cat vhdl/$i/Makefile | grep "^$target:") ]]; then
  97. echo "Warning: The makefile for $i module is missing the $target target!";
  98. let "warning_counter++"
  99. fi;
  100. done;
  101. fi;
  102. done;
  103. for i in $modules_with_makefiles_and_sim_gui_targets; do
  104. if [ -e vhdl/$i/Makefile ]; then
  105. if ! [[ $(cat vhdl/$i/Makefile | grep "^sim_gui:") ]]; then
  106. echo "Warning: The makefile for $i module is missing the sim_gui target!";
  107. let "warning_counter++"
  108. fi;
  109. fi;
  110. done;
  111. for i in $modules_with_makefiles_and_sim_targets; do
  112. if [ -e vhdl/$i/Makefile ]; then
  113. if ! [[ $(cat vhdl/$i/Makefile | grep "^sim:") ]]; then
  114. echo "Warning: The makefile for $i module is missing the sim target!";
  115. let "warning_counter++"
  116. fi;
  117. fi;
  118. done;
  119. #check for quartus projects
  120. for f in vhdl/top/quartus/*.qpf; do
  121. if [ ! -e "$f" ]; then
  122. echo "Error: Quartus project missing!";
  123. let "error_counter++"
  124. fi;
  125. if [ ! -e "vhdl/top/quartus/top.qpf" ]; then
  126. echo "Error: The name of the top-level Quartus project is wrong! The name MUST BE top!";
  127. let "error_counter++"
  128. fi;
  129. break;
  130. done;
  131. #check for SDC file in quartus project directory
  132. for f in vhdl/top/quartus/*.sdc; do
  133. if [ ! -e "$f" ]; then
  134. echo "Warning: SDC file missing in top-level quartus project directory vhdl/top/quartus!";
  135. let "warning_counter++"
  136. fi;
  137. break;
  138. done;
  139. #check for PLL file in top source directory
  140. if [ $(ls vhdl/top/src/ | grep -i PLL | wc -l) -eq 0 ]; then
  141. echo "Error: PLL file missing from /top/src directory!";
  142. let "error_counter++"
  143. fi;
  144. #check for the all keyword
  145. for f in vhdl/ssd_controller/src/*.vhd; do
  146. if [ -e "$f" ]; then
  147. if [ $(cat vhdl/ssd_controller/src/*.vhd | grep process | grep all | wc -l) -ne 0 ]; then
  148. echo "Warning: Your ssd_controller seems to use the all keyword for sensitivity lists";
  149. fi;
  150. fi;
  151. break;
  152. done;
  153. exit $error_counter