二. top_core_build和get_ipname
- SoC的代码文件目录如下:
-
top_core_build子进程(subroutine)
-
其思路是先进入到top_core_dir目录下,然后编译,生成vfiles文件
-
然后再切换回到ip目录下
my $SOC_PATH = ""; my $TOP_CORE_PATH = "$SOC_PATH/top_core" my $IPS_PATH = "$SOC_PATH/ip" sub top_core_build { print("[INFO]:------------------------------------------"); print("[INFO]: begin to build top_core in $TOP_CORE_PATH"); chdir $TOP_CORE_PATH; system("make build"); # 这里假设实际的top core编译指令为make build chdir $IPS_PATH; }
-
其运行效果如下
-
-
get_ipname子程序
-
其思路是首先读取vfiles到文件句柄中。
-
然后根据文件句柄进行while循环,一行一行处理出来对应的IP_NAME和IP_VERISON。
-
然后同时把IP_NAME和IP_VERSION写入hash%IPS_LIST中。
-
sub get_ipname { my ($myFile) = @_; open(my $fh_input, "<$myFile") or die("[ERROR]: read file failed: $!"); open(my $fh_output, ">$LINT_REPORT_PATH/IPS_list.txt") or die("[ERROR]: create file failed: $!"); my %myIPS_LIST = (); print "[INFO]:------------------------------------------------------------- \n"; while(my $line = <$fh_input>){ chomp($line); if($line =~ /\S*\/ip\/(\w+)\/(\w+)\S*/){ $myIPS_LIST{"$1/$2"} = "$2"; printf "[INFO]: found new IP, name is %-25s,version is %-9s \n",$1,$2; } } my @myIPs = keys%myIPS_LIST; $IPS_NUM = @myIPs; print "[INFO]:------------------------------------------------------------ \n"; print "[INFO]: the number of IPs is $IPS_NUM \n"; foreach my $i (@myIPs){ print "[INFO]: $i, $myIPS_LIST{$i} write to IPS_list.txt \n"; printf $fh_output "%-25s,%-9s\n", $i,$myIPS_LIST{$i}; } close $fh_input; close $fh_output; return %myIPS_LIST; }
-
其运行效果如下:
-
-