ASIC/FPGA Design and Verification Out Source Services
A simple script to search in all files, which were loaded into the simulation.
- It is very frequent to search only on some files, listed by file list. In my case all e, specman, files, which were loaded. It can also be used for all HDL files used. While this page talks about specman files, one can easily apply it to other suitable cases. For instance see:
ncls
-
Once you prepared the list, you can start using the smart search script. For example:
e_search n "my regular .*expression" [optional list file]
- The script gets three parameters: one is going to linux command grep (i ignore case, n show line numbers, etc ...). The second parameter is a regular expression pattern, which is also given to grep command as an input. I recommend that usually you use n. Later you can explore and try other options. The last parameter is optional. If you don't give it, the script uses a default file name, e_list_mod.txt.
- A message will be issued, when the script starts and a progress display will be shown as well. Sometimes there are many files involved resulting in long processing time and therefor progress info is valuable.
- For each file on which the pattern was found, the results will be summarized to a nice report and be available for user visual inspection, using less command. less will be used with the -p option to nicely mark the given pattern.
- The next option uses less -p separately, to view each file, for farther user inspection. Since many files are involved, the user is asked per each file, if he wishes to continue. The script uses xmessage to communicate with the user. Note that instead of less one can use gvim/vim and give it a search pattern from the command line:gvim +"/^spec.*"
-
Similar topics are discussed also in:
e_search original
-
The script is available on this site at:
e_search_1 script
-
A version of the script that simply scans e tests, without a file list is
shown in this
link.
-
A short explanation to main command used in the script follows:
The third parameter is optional and the way to detect its presence is simple:
if [ $# -eq "3" ]
then
cmd="cp "${3}" tmp_3"
else
cmd="cp e_list_mod.txt tmp_3"
fi
eval $cmd
Progress report is done by displaying the number of files processed, divided by the number of all files multiplied by 100.
#progress
pc_tot=`wc -l tmp_3 | sed 's/ tmp_3//'`
pc_cnt="0"
pc_mod="10"
pc_n_char="100"
echo "start search in "$pc_tot" e files, which were loaded"
for f in $(cat tmp_3); do
#progrss counter
pc_cnt=$[$pc_cnt+1]
loop=$(($pc_n_char * $pc_cnt))
loop=$(($loop / $pc_tot))
mod=$(($loop % $pc_mod))
if [ "$mod" -eq 0 ]; then
#\r brings the cursor to the head of line
echo -ne "${loop} %\r"
fi
|