2021年6月6日 星期日

chk_rtl_file.sh

 #!/bin/sh

# Updated date : 2020/02/20

# Set default golden_path and reverse_path

Impl_path="../../Implementation"

impl_level=6

#Impl_path="../../../../../AM-12M/FPGA/Implementation"

#impl_level=11

# Choose implementation directory manually.

echo "==========================================="

echo "Please choose FPGA implementation : "

echo "==========================================="

ls -F ../../ | grep "Impl" | sed 's/\///' | \

awk 'BEGIN { num = 0 } 

   { print num "-" $1 ;

print num "-" $1 > "list.data" ; 

num +=1 }'

read project_num

Impl_dir=`cat list.data | grep -w "^$project_num" | cut -d '-' -f 2`

echo "Check implementation directory is $Impl_dir"  

Impl_path="../../$Impl_dir"

# Choose FPGA design.

echo "==========================================="

echo "Please choose FPGA version : "

echo "==========================================="

ls -F $Impl_path | grep "/" | sed 's/\///' | \

awk 'BEGIN { num = 0 } 

   { print num "-" $1 ;

print num "-" $1 > "list.data" ; 

num +=1 }'


read project_num

project_file=`cat list.data | grep -w "^$project_num" | cut -d '-' -f 2`

echo "Check project file is $project_file"  

golden_path="."

reverse_path="$Impl_path/$project_file/source"

# Back up old file

echo ""

if [ -f diff_rtl.log ]; then

echo "Move diff_rtl.log to x_diff_rtl.log"

cp diff_rtl.log x_diff_rtl.log

rm diff_rtl.log

fi

# Print basic infomation

echo ""

echo "Check RTL Files" | tee -a diff_rtl.log

echo "" | tee -a diff_rtl.log

echo "golden_path  = $golden_path"  | tee -a diff_rtl.log

echo "reverse_path = $reverse_path " | tee -a diff_rtl.log

echo "" | tee -a diff_rtl.log

# Generate file list

#

find ../ -name "*.v" | sort > golden_file.log

#find $reverse_path -name "*.v" | sort | grep -v '/IP/\|/Testbench/' > reverse_file.log

find $reverse_path -name "*.v" | grep -v "_tmpl\." | sort | grep -v '/Testbench/' > reverse_file.log

# cat golden_file.log | rev | cut -d "/" -f 1 | rev

# Execute Diff

#for i in `cat golden_file.log | rev | cut -d "/" -f 1-2 | rev | sed 's/^/\//'`

#for i in `cat golden_file.log | sed 's/^.//'`

start=`date +%s`

for i in `cat reverse_file.log | cut -d "/" -f $impl_level- | sed 's/^/\//'`

do

echo "===== START `cat reverse_file.log | grep $i` =====" >> diff_rtl.log

#echo "===== grep $i =====" >> diff_rtl.log

diff -w `cat reverse_file.log | grep $i` `cat golden_file.log | grep $i` >> diff_rtl.log

done

end=`date +%s`

runtime=$((end-start))

echo "----"

echo "runtime is $runtime."

echo "----"

echo "-------------------------------------" >> diff_rtl.log

echo " DIFF golden_file & reverse_file     " >> diff_rtl.log

echo "-------------------------------------" >> diff_rtl.log

#cat reverse_file.log |\

#    cut -d "/" -f 6- |\

#    sed 's/^Design\//.\//' |\

sed 's/^Design_definition\//..\/&/' > reverse_file2.log

cat reverse_file.log | cut -d "/" -f 6- | sed 's/^/\//' > reverse_file2.log

#cat golden_file.log | grep -v '/IP/\|/Testbench/' | sort | sed 's/^\.\.//' > golden_file2.log

cat golden_file.log | grep -v '/Testbench/' | sort | sed 's/^\.\.//' > golden_file2.log

diff golden_file2.log reverse_file2.log >> diff_rtl.log

echo -- >> diff_rtl.log

date >> diff_rtl.log

echo -- >> diff_rtl.log


echo ""

echo "Different files are -->"

echo ""

cat diff_rtl.log | grep -B 1 -v '=====\|-----' | grep "====="

echo ""


echo DONE


rm golden_file.log

rm golden_file2.log

rm reverse_file.log

rm reverse_file2.log

rm list.data


沒有留言:

張貼留言

SystemVerilog DPI 介紹 (1)

什麼是 DPI? 自 SystemVerilog3.1a之後,SystemVerilog 推出了一個與第三方語言介接的功能,稱之為DPI(Direct Programming Interface),可以方便在SystemVerilog中引入其它的語言來使用。在本文中將介紹其中最常...