二. 利用perl对SoC各个ip进行lint check:top_core_build和get_ipname子程序设计

文章介绍了SoC项目中的两个关键子程序:top_core_build负责在top_core目录下编译并生成vfiles,而get_ipname则读取vfiles并提取IP_NAME和IP_VERSION信息,存储在hash中并写入文件。
摘要由CSDN通过智能技术生成

二. 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;
      }
      
    • 其运行效果如下:

    -请添加图片描述

  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值