MeasDataFifo.sh 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. #!/bin/bash -f
  2. #*********************************************************************************************************
  3. # Vivado (TM) v2020.2 (64-bit)
  4. #
  5. # Filename : MeasDataFifo.sh
  6. # Simulator : Xilinx Vivado Simulator
  7. # Description : Simulation script for compiling, elaborating and verifying the project source files.
  8. # The script will automatically create the design libraries sub-directories in the run
  9. # directory, add the library logical mappings in the simulator setup file, create default
  10. # 'do/prj' file, execute compilation, elaboration and simulation steps.
  11. #
  12. # Generated by Vivado on Wed May 03 12:02:59 +0700 2023
  13. # SW Build 3064766 on Wed Nov 18 09:12:45 MST 2020
  14. #
  15. # Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.
  16. #
  17. # usage: MeasDataFifo.sh [-help]
  18. # usage: MeasDataFifo.sh [-lib_map_path]
  19. # usage: MeasDataFifo.sh [-noclean_files]
  20. # usage: MeasDataFifo.sh [-reset_run]
  21. #
  22. #*********************************************************************************************************
  23. # Command line options
  24. xv_boost_lib_path=C:/Xilinx/Vivado/2020.2/tps/boost_1_64_0
  25. xvlog_opts="--relax"
  26. # Script info
  27. echo -e "MeasDataFifo.sh - Script generated by export_simulation (Vivado v2020.2 (64-bit)-id)\n"
  28. # Main steps
  29. run()
  30. {
  31. check_args $# $1
  32. setup $1 $2
  33. compile
  34. elaborate
  35. simulate
  36. }
  37. # RUN_STEP: <compile>
  38. compile()
  39. {
  40. # Compile design files
  41. xvlog $xvlog_opts -prj vlog.prj 2>&1 | tee compile.log
  42. }
  43. # RUN_STEP: <elaborate>
  44. elaborate()
  45. {
  46. xelab --relax --debug typical --mt auto -L xil_defaultlib -L unisims_ver -L unimacro_ver -L secureip -L xpm --snapshot MeasDataFifo xil_defaultlib.MeasDataFifo xil_defaultlib.glbl -log elaborate.log
  47. }
  48. # RUN_STEP: <simulate>
  49. simulate()
  50. {
  51. xsim MeasDataFifo -key {Behavioral:sim_1:Functional:MeasDataFifo} -tclbatch cmd.tcl -log simulate.log
  52. }
  53. # STEP: setup
  54. setup()
  55. {
  56. case $1 in
  57. "-lib_map_path" )
  58. if [[ ($2 == "") ]]; then
  59. echo -e "ERROR: Simulation library directory path not specified (type \"./MeasDataFifo.sh -help\" for more information)\n"
  60. exit 1
  61. fi
  62. copy_setup_file $2
  63. ;;
  64. "-reset_run" )
  65. reset_run
  66. echo -e "INFO: Simulation run files deleted.\n"
  67. exit 0
  68. ;;
  69. "-noclean_files" )
  70. # do not remove previous data
  71. ;;
  72. * )
  73. copy_setup_file $2
  74. esac
  75. # Add any setup/initialization commands here:-
  76. # <user specific commands>
  77. }
  78. # Copy xsim.ini file
  79. copy_setup_file()
  80. {
  81. file="xsim.ini"
  82. lib_map_path="C:/Xilinx/Vivado/2020.2/data/xsim"
  83. if [[ ($1 != "") ]]; then
  84. lib_map_path="$1"
  85. fi
  86. if [[ ($lib_map_path != "") ]]; then
  87. src_file="$lib_map_path/$file"
  88. if [[ -e $src_file ]]; then
  89. cp $src_file .
  90. fi
  91. # Map local design libraries to xsim.ini
  92. map_local_libs
  93. fi
  94. }
  95. # Map local design libraries
  96. map_local_libs()
  97. {
  98. updated_mappings=()
  99. local_mappings=()
  100. # Local design libraries
  101. local_libs=()
  102. if [[ 0 == ${#local_libs[@]} ]]; then
  103. return
  104. fi
  105. file="xsim.ini"
  106. file_backup="xsim.ini.bak"
  107. if [[ -e $file ]]; then
  108. rm -f $file_backup
  109. # Create a backup copy of the xsim.ini file
  110. cp $file $file_backup
  111. # Read libraries from backup file and search in local library collection
  112. while read -r line
  113. do
  114. IN=$line
  115. # Split mapping entry with '=' delimiter to fetch library name and mapping
  116. read lib_name mapping <<<$(IFS="="; echo $IN)
  117. # If local library found, then construct the local mapping and add to local mapping collection
  118. if `echo ${local_libs[@]} | grep -wq $lib_name` ; then
  119. line="$lib_name=xsim.dir/$lib_name"
  120. local_mappings+=("$lib_name")
  121. fi
  122. # Add to updated library mapping collection
  123. updated_mappings+=("$line")
  124. done < "$file_backup"
  125. # Append local libraries not found originally from xsim.ini
  126. for (( i=0; i<${#local_libs[*]}; i++ )); do
  127. lib_name="${local_libs[i]}"
  128. if `echo ${local_mappings[@]} | grep -wvq $lib_name` ; then
  129. line="$lib_name=xsim.dir/$lib_name"
  130. updated_mappings+=("$line")
  131. fi
  132. done
  133. # Write updated mappings in xsim.ini
  134. rm -f $file
  135. for (( i=0; i<${#updated_mappings[*]}; i++ )); do
  136. lib_name="${updated_mappings[i]}"
  137. echo $lib_name >> $file
  138. done
  139. else
  140. for (( i=0; i<${#local_libs[*]}; i++ )); do
  141. lib_name="${local_libs[i]}"
  142. mapping="$lib_name=xsim.dir/$lib_name"
  143. echo $mapping >> $file
  144. done
  145. fi
  146. }
  147. # Delete generated data from the previous run
  148. reset_run()
  149. {
  150. files_to_remove=(xelab.pb xsim.jou xvhdl.log xvlog.log compile.log elaborate.log simulate.log xelab.log xsim.log run.log xvhdl.pb xvlog.pb MeasDataFifo.wdb xsim.dir)
  151. for (( i=0; i<${#files_to_remove[*]}; i++ )); do
  152. file="${files_to_remove[i]}"
  153. if [[ -e $file ]]; then
  154. rm -rf $file
  155. fi
  156. done
  157. }
  158. # Check command line arguments
  159. check_args()
  160. {
  161. if [[ ($1 == 1 ) && ($2 != "-lib_map_path" && $2 != "-noclean_files" && $2 != "-reset_run" && $2 != "-help" && $2 != "-h") ]]; then
  162. echo -e "ERROR: Unknown option specified '$2' (type \"./MeasDataFifo.sh -help\" for more information)\n"
  163. exit 1
  164. fi
  165. if [[ ($2 == "-help" || $2 == "-h") ]]; then
  166. usage
  167. fi
  168. }
  169. # Script usage
  170. usage()
  171. {
  172. msg="Usage: MeasDataFifo.sh [-help]\n\
  173. Usage: MeasDataFifo.sh [-lib_map_path]\n\
  174. Usage: MeasDataFifo.sh [-reset_run]\n\
  175. Usage: MeasDataFifo.sh [-noclean_files]\n\n\
  176. [-help] -- Print help information for this script\n\n\
  177. [-lib_map_path <path>] -- Compiled simulation library directory path. The simulation library is compiled\n\
  178. using the compile_simlib tcl command. Please see 'compile_simlib -help' for more information.\n\n\
  179. [-reset_run] -- Recreate simulator setup files and library mappings for a clean run. The generated files\n\
  180. from the previous run will be removed. If you don't want to remove the simulator generated files, use the\n\
  181. -noclean_files switch.\n\n\
  182. [-noclean_files] -- Reset previous run, but do not remove simulator generated files from the previous run.\n\n"
  183. echo -e $msg
  184. exit 1
  185. }
  186. # Launch script
  187. run $1 $2