【IC验证】perl脚本——分析前/后仿用例回归情况

目录

[1 脚本名称](#1 脚本名称)

[2 脚本使用说明](#2 脚本使用说明)

[3 nocare_list文件示例](#3 nocare_list文件示例)

[4 脚本执行方法](#4 脚本执行方法)

[5 postsim_result.log文件示例](#5 postsim_result.log文件示例)

[6 脚本代码](#6 脚本代码)


1 脚本名称

post_analysis

2 脚本使用说明

help:打印脚本说明信息

命令:post_analysis help

前/后仿结束后,首先填写好nocare_list(要过滤的log信息),然后在有log文件的上一层次路径下运行post_analysis脚本,执行脚本时若不带-all参数,则过滤掉nocare_list中的信息后只对后仿log进行分析,若带-all参数,则会过滤nocare_list中的信息后,对前/后仿的log信息进行分析,给出pass、timeout、bombed、violation等结果:

(1)不带-all参数:

脚本会只分析名称带max或者min的后仿文件夹如(rfdig_m33_tc029_max、rfdig_m33_tc001_max_20230911),除去runsim.log文件中和nocare_list中的内容相关的violation,之后在各个用例文件夹下产生runsim_temp.log文件,随后分析runsim_temp.log文件out of reset之后的内容,若case PASS但存在violation,则输出结果 VOILATION以及setuphold/setup/hold/width违例的数量,并产生结果文件: postsim_result.log;若不仍存在violation,则输出结果PASS到postsim_result.log文件中;否则输出结果FAIL、TIMEOUT、RUNNING、BOMB到postsim_result.log文件中。

(2)带-all参数:

对前仿也进行上述分析。

3 nocare_list文件示例

在runsim.log中找到包含以下关键字的行,并将其删除:

4 脚本执行方法

cpp 复制代码
post_analysis //只对文件夹名称中有max或者min的后仿文件夹进行分析
post_analysis -all //对前后仿的文件夹都进行分析

5 postsim_result.log文件示例

(1)PASS说明reset后无任何violation;

(2)VOILATION说明reset后仍存在violation,需查看对应的runsim_temp.log确认每一个violation;

(3)FAIL说明用例fail,需查看对应的runsim_temp.log,确认fail原因;

(4)TIMEOUT说明用例超时,需查看对应的runsim_temp.log,确认超时原因;

(5)RUNNING说明用例还在跑,确认相关原因;

(6)BOMB说明用例编译失败,需查看对应的vcs_compile.log确认编译失败原因;

6 脚本代码

perl 复制代码
#! /usr/bin/perl -w

#==========================================================
# PERL MODULE 
#==========================================================

use Cwd;
use Getopt::Long;
    $Getopt::Long::ignorecase = 0;

#==========================================================
# PERL FUNCTION GetOptions (get command parameters)
#==========================================================
GetOptions("all" => \$g_dir) or die ("Invalid arguments. \n");

our $g_help = 0;
if (!GetOptions (
     "help" => \$g_help,
                )
   ) {
  &print_message();
  exit 0;
}


#==========================================================
# GENERATE postsim_result.log FILE
#==========================================================


our $sim_log = "runsim.log";
our $new_sim_log = "runsim_temp.log";
our @dirs = <*>;

our $reset_line_num;
our $tail_lines; 
our $casename;

($sec,$min,$hour,$mday,$mon,$year) = localtime();

if (open(NOCARE_ID,"nocare_list") or die "cannot open nocare_list, no such file!!!") {
    @nocarecontent = <NOCARE_ID>;

    my $cur_dir = getcwd; 
    chdir($cur_dir) or die "cannot cd $cur_dir"; #cd simdir 

    open(PS_ID,">postsim_result.log");
    print  PS_ID "====================================================";
    printf PS_ID "%02d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon+1,$mday,"$hour","$min","$sec";
    print  PS_ID "====================================================\n";
    
    foreach $dir (@dirs) { 
        chdir($cur_dir) or die "cannot cd $cur_dir"; #cd simdir 
        if ($g_dir) {
            if ($dir =~ /(.+)tc(\d+)(.*)/) {
                $casename = $dir;
                print "dir_name = $casename \n" ;
            }
            else {
                next;
            }
        }
        else {
            if (($dir =~ /(.+)(\d+)(.*)max(.*)/) or ($dir =~ /(.+)(\d+)(.*)min(.*)/)) {
                $casename = $dir;
                print "dir_name = $casename \n" ;
            }
            else {
                next;
            }
        }
        chdir($dir) or die "cannot cd $dir"; #cd simdir/xxx_tc00X(every case dir)
        unlink $new_sim_log;
        open(NEW_ID,">runsim_temp.log");
        $nocarename=$sim_log; #simdir/xxx_tcXXX/runsim.log
        if (open(LOG_ID,"$nocarename")) {
            @logcontent = <LOG_ID>; #ever line in runsim.log
            $match=0;
            $write_en=0;
            foreach $log (@logcontent) {
                if ($match eq 1) {
                    $match = 0;
                } else {
                    foreach $nocare (@nocarecontent) {
                        if ($log =~ /$nocare/) {
                            $match = 1;
                            $write_en = 0;
                            last;
                        } else {
                            $write_en = 1;
                        }
                    }
                    if ($write_en eq 1) {
                        print NEW_ID $log;
                        $write_en = 0;
                    }
                }
            }
            close NEW_ID; #finish write run_sim_temp.log
            close LOG_ID; #finish read run_sim.log
        } 
        else {
            print "Can not find $nocarename file!!! \n";
        }

        ####report###
        if(-e "runsim.log") {
            if (open NEW_ID,$new_sim_log) {
                @linecontent = <NEW_ID>;
                $reset_bgn = 0;
                $setuphold = 0;
                $width     = 0;
                $print_over= 0;
                foreach $line (@linecontent) {
                    if ($reset_bgn eq 1) {
                        if ($line =~ /.*\$setuphold.*/ or $line =~ /.*\$setup.*/ or $line =~ /.*\$hold.*/) {
                            $setuphold = $setuphold+1;
                        } elsif ($line =~ /.*\$width.*/) {
                            $width = $width+1;
                        } elsif ($line =~ /.*the test case finished with (\w+).*/) {
                            if($1 eq "FAIL") {
                                $print_over = 1;
                                printf PS_ID "%-50s%-10s%-30s","$casename",">>>>","FAIL";
                                print  PS_ID "\n"; 
                            } elsif ($1 eq "TIMEOUT") {
                                $print_over = 1;
                                printf PS_ID "%-50s%-10s%-30s","$casename",">>>>","TIMEOUT";
                                print  PS_ID "\n";  
                            } elsif ($1 eq "PASS") {
                                $print_over = 1;
                                if ($setuphold > 0 or $width > 0) {
                                    printf PS_ID "%-50s%-10s%-30s","$casename",">>>>","VOILATION";
                                    printf PS_ID "\$setuphold:%-5d \$width:%-5d",$setuphold,$width;
                                    print  PS_ID "\n";    
                                } else {
                                    printf PS_ID "%-50s%-10s%-30s","$casename",">>>>","PASS";
                                    print  PS_ID "\n";   
                                }
                            } else {
                               next;
                            }
                        } else {
                            next;

                        }
                    } else {
                        if ($line =~ /.*Out of reset!.*/) {
                            $reset_bgn = 1;
                        } else {
                            next;
                        }
                    }
                }
                if ($print_over eq 0) {
                    printf PS_ID "%-50s%-10s%-30s","$casename",">>>>","RUNNING";
                    print  PS_ID "\n"; 
                } else {
                    next;
                }
            } else {
                next;
            }
        } else {
             printf PS_ID "%-50s%-10s%-30s","$casename",">>>>","BOMBED";
             print  PS_ID "\n";    
        }
    }
    printf PS_ID "%-58s","========================================================";
    printf PS_ID "%-7s",$ENV{'USER'};
    printf PS_ID "%58s","========================================================";
    close PS_ID;
}


#==========================================================
# HELP INFORMATION PRINT
#==========================================================

if ($g_help) {
  &print_message();
  exit 0;
}

#==========================================================
# SUB PROGRAM (print help ingormation) 
#==========================================================

sub print_message ()
{
  print "
NAME
      post_analysis - Maxscend check case post sim result script

MAXSCEND
      post_analysis [-h]

Options
      -h : help information

You should run this script in the directory containing all the cases' working directories
        \n";
}
相关推荐
szxinmai主板定制专家2 小时前
【国产NI替代】基于FPGA的32通道(24bits)高精度终端采集核心板卡
大数据·人工智能·fpga开发
HIZYUAN7 小时前
AGM FPGA如何配置上拉或者下拉电阻
fpga开发
∑狸猫不是猫7 小时前
(13)CT137A- 简易音乐盒设计
fpga开发
ThreeYear_s13 小时前
基于FPGA 的4位密码锁 矩阵键盘 数码管显示 报警仿真
fpga开发·矩阵·计算机外设
Anin蓝天(北京太速科技-陈)19 小时前
252-8路SATAII 6U VPX高速存储模块
fpga开发
如何学会学习?21 小时前
2. FPGA基础了解--全局网络
fpga开发
Anin蓝天(北京太速科技-陈)1 天前
271-基于XC7V690T的12路光纤PCIe接口卡
嵌入式硬件·fpga开发
碎碎思1 天前
FPGA新闻速览-WiMi开发基于FPGA的数字量子计算机验证技术
fpga开发·量子计算
hi942 天前
Vivado - 远程调试 + 远程综合实现 + vmWare网络配置 + NFS 文件共享 + 使用 VIO 核
嵌入式硬件·fpga开发·vivado 远程开发·vmware网络配置