【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";
}
相关推荐
FPGA技术实战35 分钟前
《探索Zynq MPSoC》学习笔记(二)
fpga开发·mpsoc
bigbig猩猩11 小时前
FPGA(现场可编程门阵列)的时序分析
fpga开发
Terasic友晶科技16 小时前
第2篇 使用Intel FPGA Monitor Program创建基于ARM处理器的汇编或C语言工程<二>
fpga开发·汇编语言和c语言
码农阿豪17 小时前
基于Zynq FPGA对雷龙SD NAND的测试
fpga开发·sd nand·spi nand·spi nand flash·工业级tf卡·嵌入式tf卡
江山如画,佳人北望18 小时前
EDA技术简介
fpga开发
淘晶驰AK18 小时前
电子设计竞赛准备经历分享
嵌入式硬件·fpga开发
最好有梦想~18 小时前
FPGA时序分析和约束学习笔记(4、IO传输模型)
笔记·学习·fpga开发
檀越剑指大厂19 小时前
【基于Zynq FPGA对雷龙SD NAND的测试】
fpga开发
9527华安2 天前
FPGA视频GTH 8b/10b编解码转PCIE3.0传输,基于XDMA中断架构,提供工程源码和技术支持
fpga开发·音视频·pcie·gth·xdma·pcie3.0
爱奔跑的虎子2 天前
FPGA实现以太网(一)、以太网基础知识
fpga开发·以太网·fpga·vivado