Perl 脚本记录1

Summary_Timing_Report.pl (适用于Innovus Timing report 处理)

#!/usr/bin/perl
#use strict;
#use warnings;

$top = $ARGV[0] =~ /(\S+)_\S+\.(\S+)$/ ;
$top = $1 ;
$type = $2 ;

my $func_sum_rpt = "./$top.func.$type.sum.rpt";
my $scan_sum_rpt = "./$top.scan.$type.sum.rpt";
my $func_rpt = "./$top.func.$type.rpt";
my $scan_rpt = "./$top.scan.$type.rpt";
my @VIO = ();

## main ##
open(OUTFUNC, ">$func_rpt");
open(OUTSCAN, ">$scan_rpt");
open my $report,"<",$ARGV[0] or die "error:file can't open";
open my $rpt,"<",$ARGV[0] or die "error:file can't open";
## split report with view type ##
while (<$report>) {
        if(/^Path \d+:/) {
                $line1 = "$_";
        }
        if(/^Endpoint/) {
                $line2 = "$_";
        }
        if(/^Beginpoint/) {
                $line3 = "$_";
        }
        if(/^Path Groups/) {
                $line4 = "$_";
        }
        if(/^Analysis View:/) {
                $timeview = /^Analysis View:\s(\S+)/ ;
                $timeview = $1 ;
                if($timeview =~ /func/) {
                    print OUTFUNC "$line1";
                        print OUTFUNC "$line2";
                        print OUTFUNC "$line3";
                        print OUTFUNC "$line4";
                } elsif($timeview =~ /testscan/) {
                    print OUTSCAN "$line1";
                    print OUTSCAN "$line2";
                    print OUTSCAN "$line3";
                    print OUTSCAN "$line4";
                }
        }
        ## print all lines except Path line ##
        if(/^Analysis View: func/../^Path \d+/) {
                @funclines = "$_";
                foreach my $funcline (@funclines) {
                        if($funcline !~ /^Path \d+/) {
                                print OUTFUNC "$_";
                        }
                }
        } elsif(/^Analysis View: testscan/../^Path \d+/) {
                @scanlines = "$_";
                foreach my $scanline (@scanlines) {
                        if($scanline !~ /^Path \d+/) {
                                print OUTSCAN "$_";
                        }
                }
        }
}
close(OUTFUNC);
close(OUTSCAN);

## get violation summary with view type ##
while (<$rpt>) {
        ## get header ##
        if( /^Endpoint/ ) {
                $end = /^Endpoint:\s+(\S+)/ ;
                $end = $1;
        }
        if( /^Beginpoint/ ) {
                $begin = /^Beginpoint:\s(\S+)/ ;
                $begin = $1 ;
        }
        if( /^Path\sGroups/ ) {
                $path_group = /^Path\sGroups:\s\{(\S+)\}/ ;
                $path_group = $1 ;
        }
        if( /^Analysis\sView:/ ) {
                $view = /^Analysis\sView:\s(\S+)/ ;
                $view = $1;
        }
        if( /Slack\sTime/ ) {
                $slack = /^=\sSlack\sTime\s+(-\d+\.\d+)/ ;
                $slack = $1 ;
                $slack = $slack / 1000.000 ;
                push @VIOLATION,"$view,$path_group,$begin,$end,$slack \n";
        }
}

## output summary by view ##
open(FUNC, ">$func_sum_rpt");
open(SCAN, ">$scan_sum_rpt");
printf FUNC ("%-15s %-10s %-60s %-60s %-10s\n","Analysic View","Path Group","Beginpoint","Endpoint","Slack");
printf FUNC ("%-15s %-10s %-60s %-60s %-10s\n","--------------","--------","----------------------------------------------------------","-----------------------------------------------------------","------");
printf SCAN ("%-15s %-10s %-60s %-60s %-10s\n","Analysic View","Path Group","Beginpoint","Endpoint","Slack");
printf SCAN ("%-15s %-10s %-60s %-60s %-10s\n","--------------","--------","----------------------------------------------------------","-----------------------------------------------------------","------");
foreach my $vio (@VIOLATION) {
        chomp($vio);
        ($view_type,$path_group,$beginpoint,$endpoint,$violation) = split(/,/,$vio);
        chomp($view_type,$path_group,$beginpoint,$endpoint,$violation);
        if($view_type =~ /func_slle_cmax/) {
                printf FUNC ("%-15s %-10s %-60s %-60s %.3f\n","$view_type","$path_group","$beginpoint","$endpoint","$violation");
        }
        if($view_type =~ /testscan/) {
                printf SCAN ("%-15s %-10s %-60s %-60s %.3f\n","$view_type","$path_group","$beginpoint","$endpoint","$violation");
        }
}
close(FUNC);
close(SCAN);

你可能感兴趣的:(Perl 脚本记录1)