#!/usr/bin/perl -w # getpaths.pl - a script for summarizing PT or MAGMA output # # By Jeff Winston http://www.kwcpa.com/tools # Rev. 1.1, 4/21/04 Copyright (C) 2004 # # --------------------------------------------------------------------- # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # #of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # #along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. or check out http://www.gnu.org/copyleft/gpl.html # --------------------------------------------------------------------- # Rev. 1.1: added -c parameter # for a thorough description, type getpaths.pl with no parameters $| = 1; # enable autoflush print "getpaths.pl. by Jeff Winston\n\n"; if (($#ARGV < 1) || ($#ARGV > 3)) { print "Usage: getpaths.pl [-c] [] \n\n"; print "getpaths.pl reads a Primetime or Magma timing report and generates two files.\n"; print "One is a list of the paths (startpoint, endpoint, slack), in slack order. The\n"; print "other is the same list in startpoint order. When the optional is\n"; print "given, the program stops processing the report file when it gets to that amount\n"; print "of slack.\n\n"; print "For a Primetime file, -c adds the display of the From and To Clock domain\n\n"; exit; } # mantle flag is used to determine file time $mantle=0; # get parameters from command line $cross=0; $tmp = shift @ARGV; if ($tmp eq "-c") { $cross=1; $tmp = shift @ARGV; } $in_file = $tmp; $out_file = shift @ARGV; $out_file2 = $out_file . "_sorted"; $downto = 0; if ($#ARGV > -1) { $downto = shift @ARGV; } # initialize counters $l=0; $l0=0; $path_cnt=0; # open files open (INFILE, "< $in_file") or die "Couldnt open $in_file"; open (OUTFILE1, "> $out_file") or die "Couldnt open $out_file"; open (OUTFILE2, "> $out_file2") or die "Couldnt open $out_file2"; print OUTFILE1 "Input: $in_file\n"; print OUTFILE2 "Input: $in_file\n"; # process file $state=0; $stop=0; while (($stop == 0) && (defined($line = ))) { chomp $line; if ($line =~ "# Mantle") { $mantle =1; $cross=0; } $l++;$l0++; if ($l0 == 50000) { $l0=0; print "Processed line $l, path $path_cnt, slack $time\n"; } @words = split (" ",$line); if ($mantle == 1) { if (($#words > 0) && ($words[0] eq "Start")) { $start = $words[1]; } elsif (($#words > 0) && ($words[0] eq "End")) { $end = $words[1]; } elsif (($#words > 1) && ($words[0] eq "Path") && ($words[1] eq "slack")) { $time = $words[2]; $t = substr($time,0,length($time)-1); if ($t > $downto) { $stop = 1; print "Stopping at $t ps, Path $path_cnt\n"; } $dataword = "$start $end $t ps"; $path_cnt++; push @data, $dataword; } } else { if (($#words > 0) && ($words[0] eq "Startpoint:")) { $state=1; $start = $words[1]; } elsif (($#words > 0) && ($words[0] eq "Endpoint:")) { $end = $words[1]; $state=0; } elsif (($cross==1) && ($#words > 0) && ($line =~ "clocked by")) { if ($state==1) { $start_clock = substr($words[$#words],0,length($words[$#words])-1); } else { $end_clock = substr($words[$#words],0,length($words[$#words])-1); } } elsif (($#words > 1) && ($words[0] eq "slack")) { $time = $words[$#words]; if ($time > $downto) { $stop = 1; print "Stopping at $time ns, Path $path_cnt\n"; } if ($cross == 1) { $dataword = "$start $end ($start_clock/$end_clock) $time "; } else { $dataword = "$start $end $time "; } $path_cnt++; push @data, $dataword; } } } # generate sorted list, write output files print "Sorting..."; @data2 = sort @data; print "Done. Printing...\n"; foreach $line (@data) { print OUTFILE1 "$line\n"; } foreach $line (@data2) { print OUTFILE2 "$line\n"; } print "$out_file, $out_file2 written, $path_cnt paths\n";