print " #!/usr/local/bin/perl ################################################ # Author : Sayandeep Nag # Date : 04 May 2004 # Description : Utility to Compare DRC Files ################################################ my $drcFile1 ; my $drcFile2 ; my $init1; my $init2; BEGIN { require Exporter ; use Carp ; # Initialize Global Variables ; $drc::error = " " ; $drc::warn = " " ; $drc::verbose = 0 ; $drc::DEBUG_ = 0 ; $drc::tmpFile = " " ; } $drc::flag = 0 ; use strict; # if( $#ARGV-1 <= 1 ) { # If File Name is Not Specified as Input Argument # print "Enter The First DRC File : " ; # $drcFile1 = ; chop $drcFile1 ; # length $drcFile1 ; # print "Enter The Second DRC File : " ; # $drcFile2 = ; chop $drcFile2 ; # length $drcFile2 ; # } # else { # %{$ARGV[0]} = "" ; # %{$ARGV[1]} = "" ; $drcFile1 = $ARGV[0] ; # Else Take file Name from Input Argument $drcFile2 = $ARGV[1] ; # Else Take file Name from Input Argument # } $init1 = drcInit( $drcFile1 ) ; # Initialising the Input Files $init2 = drcInit( $drcFile2 ) ; if ( ($init1 == -1 ) or ($init2 == -1) ) { print "$drc::error\n" ; } # DRC Files Initialised # Processing of DRC files to Eliminate Comments Log ( " Processing DRC File $drcFile1\n " ) if ( $drc::verbose ) ; # If $drc::verbose is set my $retValue1 ; $retValue1 = processDRC ( $drcFile1 ) ; Log ( " Processing DRC File $drcFile2\n " ) if ( $drc::verbose ) ; # If $drc::verbose is set my $retValue2 ; $retValue2 = processDRC ( $drcFile2 ) ; return -1 if ( ($retValue1 == -1) or ( $retValue2 == -1) ) ; my $retValue2 ; Log ( " Reading DRC File $drcFile2\n " ) if ( $drc::verbose ) ; # If $drc::verbose is set $retValue2 = readDRC($drcFile1 , $drc::flag ) ; return -1 if ($retValue1 == -1) ; # Log ( " Reading DRC File $drcFile2\n " ) # if ( $drc::verbose ) ; # If $drc::verbose is set # $retValue2 = readDRC($drcFile2 , $drc::flag ) ; # return -1 if ( $retValue2 == -1) ; exit 0; ###################################################################### # Name : drcInit # Description : Subroutine to Initialise Input Files # Date : 4 May 2004 ###################################################################### sub drcInit { my ( $file ) = @_ ; $drc::error = "" ; $drc::warn = "" ; do { carp " No DRC File Given ." ; $drc::error = " No DRC File Given ." ; return -1 ; } unless ( defined $file ) ; # If No DRC File Specified do { carp " DRC File $file is Not a Plain Text File ."; $drc::error = " DRC File $file is Not a Plain Text File ."; return -1; } unless ( -f $file && -T $file ) ; # If File is not a valid Text File return 0 ; # Initialization Successful. } ###################################################################### # Name : processDRC # Description : Subroutine to Process Input Files and Eliminate # Comments # Date : 4 May 2004 ###################################################################### sub processDRC { my ( $file ) = @_ ; $drc::tmpFile = "${file}.tmp" if ($file) ; open ( TMPDRC, ">$drc::tmpFile" ); # Opening Temporary File In Write Mode open (DRC , "<$file" ) ; # Opening DRC File in Read Mode Log ( " Reading DRC File $file..... ") if ($drc::verbose ); my $line ; my $prevLine ; my $lineNo = 0 ; while ( $line = ) { $lineNo++ ; Log ( "." ) if ( $lineNo/1000==int($lineNo/1000) && $drc::verbose) ; $line =~ s/\n//g ; next unless ( length $line ) ; # ignore blank lines. next if ( $line =~ m/^\s*\*/ ); # weed out comments. next if ( $line =~ m/^\s*\|/ ); # weed out comments. next if ( $line =~ m/^\s*\+/ ); # weed out comments. print TMPDRC "$prevLine\n" if ( $prevLine ) ; $prevLine = $line ; } print TMPDRC "$prevLine\n" if ( $prevLine ) ; Log ( "... done.\n" ) if ( $drc::verbose ) ; close DRC ; close TMPDRC ; return 0; # Phase 1 successful. } ###################################################################### # Name : readDRC # Description : Subroutine to read Input Files and find differences # Date : 4 May 2004 ###################################################################### sub readDRC ( ) { my ( $file , $flag ) = @_ ; $drc::tmpFile1 = "${file}.tmp" if ($file) ; my $moduleName = "" ; my $netName ; my @gateInst ; my $gate ; my $netCap ; my $violation ; my @maxTrans ; my $worstTrans ; open ( TMPDRC, "<$drc::tmpFile1" ) ; my $line ; my $i; my $j = 0 ; @drc::file1 = ; for ( $i = 0 ; $i <= $#drc::file1 - 1 ; $i++ ){ if ( $drc::file1[$i] =~ m/^\s*\Module:/i ) { $moduleName = getModuleName ( $drc::file1[$i] ) ; } # End of IF Statement if ( $drc::file1[$i] =~ /Net:/ ) { $netName = getNetName ( $drc::file1[$i] ) ; } # End of IF Statement if ( $drc::file1[$i] =~ /Max Capacitance/ ) { @gateInst = getMaxCapacitance ( $drc::file1[$i] ) ; $gate = $gateInst[5].$gateInst[6] ; } # End of IF Statement if ( $drc::file1[$i] =~ /Net Capacitance/ ) { $netCap = getNetCapacitance ( $drc::file1[$i] ) ; } # End of IF Statement if ( $drc::file1[$i] =~ /VIOLATION/ ) { $violation = getViolation ( $drc::file1[$i] ) ; if ( $drc::flag ) { $drc::rpt1{$moduleName}{$netName}{$gate}{"Capacitance"} = $violation; } else { $drc::rpt2{$moduleName}{$netName}{$gate}{"Capacitance"} = $violation; } } # End of IF Statement if ( $drc::file1[$i] =~ /Max Transition/ ) { @maxTrans = getMaxTransition ( $drc::file1[$i] ) ; $gate = $maxTrans[5].$maxTrans[6] ; } # End of IF Statement if ( $drc::file1[$i] =~ /Pin Worst Transition/ ) { $worstTrans = getWorstTransition ( $drc::file1[$i] ) ; } # End of IF Statement if ( $drc::file1[$i] =~ /VIOLATION/ ) { $violation = getViolation ( $drc::file1[$i] ) ; if ( $drc::flag ) { $drc::rpt1{$moduleName}{$netName}{$gate}{"Transition"} = $violation } else { $drc::rpt2{$moduleName}{$netName}{$gate}{"Transition"} = $violation } } # End of IF Statement # } # End of FOR Loop # if ($flag) {compareFiles(\@drc::rpt1 , \@drc::rpt2 , \$drc::tmpFile1 ) } # Calling The Function to Compare Values # only if both Hashes are assigned printValues(\@drc::rpt1) ; # my $caps = "Capacitance" ; # my $tran = "Transition"; # if ( $drc::rpt1{$moduleName}{$netName}{$gate}{$tran} != $drc::rpt2{$moduleName}{$netName}{$gate}{$tran}) { # print " Module = $moduleName \n" ; # print " Net = $netName \n" ; # print " Gate = $gate \n" ; # print " Transition Violation Value = $drc::rpt1{$moduleName}{$netName}{$gate}{$tran} \n" ; # print " Capacitance Violation Value = $drc::rpt1{$moduleName}{$netName}{$gate}{$caps} \n" ; # print " Transition Violation NEW Value = $drc::rpt2{$moduleName}{$netName}{$gate}{$tran} \n" ; # } # End of IF } # End of FOR Loop close TMPDRC ; $drc::flag = 1 ; # unlink ( $drc::tmpFile1 ) if ( -f $drc::tmpFile1 ) ; return 0 ; # mission successful :=) } ###################################################################### # Name : getModuleName # Description : Subroutine to read Input Files and find Module Names # Date : 4 May 2004 ###################################################################### sub getModuleName { my ($stmt) = @_ ; $drc::error = "" ; $drc::warn = "" ; my @parts ; $stmt =~ s/^\s*\Module:\s+//i; @parts = split /\s+/, $stmt ; if ( $drc::DEBUG_ ) { print "\t\tModule Name : $parts[0]\n" ; } if( $parts[0] ) { return $parts[0]; } else {return -1 ;} } ###################################################################### # Name : getNetName # Description : Subroutine to read Input Files and find Net Names in a # Particular Module # Date : 7 May 2004 ###################################################################### sub getNetName { my ($stmt) = @_ ; $drc::error = "" ; $drc::warn = "" ; my @parts ; @parts = split /\s+/, $stmt ; if ( $drc::DEBUG_ ) { print "\t\t\tNet Name : $parts[2] \n" ; } if( $parts[2] ) { return $parts[2]; } else {return -1 ;} } ###################################################################### # Name : getMaxCapacitance # Description : Subroutine to read Input Files and find Net Names in a # Particular Module # Date : 7 May 2004 ###################################################################### sub getMaxCapacitance { my ($stmt) = @_ ; $drc::error = "" ; $drc::warn = "" ; my @parts ; @parts = split /\s+/, $stmt ; if ( $drc::DEBUG_ ) { print "\t\t\t\t\t : $parts[5] $parts[6] \n" ; } if( $parts[2] ) { return $parts[2]; } else {return -1 ;} } ###################################################################### # Name : getNetCapacitance # Description : Subroutine to read Input Files and find Net Names in a # Particular Module # Date : 7 May 2004 ###################################################################### sub getNetCapacitance { my ($stmt) = @_ ; $drc::error = "" ; $drc::warn = "" ; my @parts ; @parts = split /\s+/, $stmt ; if ( $drc::DEBUG_ ) { print "\t\t\t\t\t : $parts[4] \n" ; } if( $parts[2] ) { return $parts[4]; } else {return -1 ;} } ###################################################################### # Name : getViolation # Description : Subroutine to read Input Files and find Net Names in a # Particular Module # Date : 7 May 2004 ###################################################################### sub getViolation { my ($stmt) = @_ ; $drc::error = "" ; $drc::warn = "" ; my @parts ; @parts = split /\s+/, $stmt ; if ( $drc::DEBUG_ ) { print "\t\t\t\t\t : $parts[3] \n" ; } if( $parts[2] ) { return $parts[3]; } else {return -1 ;} } ###################################################################### # Name : getMaxTransition # Description : Subroutine to read Input Files and find Net Names in a # Particular Module # Date : 7 May 2004 ###################################################################### sub getMaxTransition { my ($stmt) = @_ ; $drc::error = "" ; $drc::warn = "" ; my @parts ; @parts = split /\s+/, $stmt ; if ( $drc::DEBUG_ ) { print "\t\t\t\t\t : $parts[5] $parts[6]\n" ; } if( $parts[2] ) { return @parts; } else {return -1 ;} } ###################################################################### # Name : getWorstTransition # Description : Subroutine to read Input Files and find Net Names in a # Particular Module # Date : 7 May 2004 ###################################################################### sub getWorstTransition { my ($stmt) = @_ ; $drc::error = "" ; $drc::warn = "" ; my @parts ; @parts = split /\s+/, $stmt ; if ( $drc::DEBUG_ ) { print "\t\t\t\t\t : $parts[5] \n" ; } if( $parts[2] ) { return $parts[5]; } else {return -1 ;} } ###################################################################### # Name : compareFiles # Description : Subroutine to Compare Contents of two files stored in # two different hashes # Date : 7 May 2004 ###################################################################### sub compareFiles { my ($rpt1 , $rpt2 , $file) = @_ ; $drc::tmpFile2 = "${file}.tmp" if ($file) ; open ( TMPDRC, "<$drc::tmpFile2" ) ; @drc::file2 = ; print "$file \n" ; print " Main Hoon Naa \n" ; my $moduleName = "" ; my $netName ; my @gateInst ; my $gate ; my $netCap ; my $violation ; my @maxTrans ; my $worstTrans ; my $i ; my $caps = "Capacitance" ; my $tran = "Transition"; for ( $i = 0 ; $i <= $#drc::file2 - 1 ; $i++ ){ if ( $drc::file2[$i] =~ m/^\s*\Module:/i ) { $moduleName = getModuleName ( $drc::file2[$i] ) ; } # End of IF Statement if ( $drc::file2[$i] =~ /Net:/ ) { $netName = getNetName ( $drc::file2[$i] ) ; } # End of IF Statement if ( $drc::file2[$i] =~ /Max Capacitance/ ) { @gateInst = getMaxCapacitance ( $drc::file[$i] ) ; $gate = $gateInst[5].$gateInst[6] ; } # End of IF Statement if ( $drc::file2[$i] =~ /Net Capacitance/ ) { $netCap = getNetCapacitance ( $drc::file2[$i] ) ; } # End of IF Statement if ( $drc::file[$i] =~ /VIOLATION/ ) { $violation = getViolation ( $drc::file2[$i] ) ; # if ( $drc::flag ) { $rpt1{$moduleName}{$netName}{$gate}{"Capacitance"} = $violation; } # else { $rpt2{$moduleName}{$netName}{$gate}{"Capacitance"} = $violation; } } # End of IF Statement if ( $drc::file2[$i] =~ /Max Transition/ ) { @maxTrans = getMaxTransition ( $drc::file2[$i] ) ; $gate = $maxTrans[5].$maxTrans[6] ; } # End of IF Statement if ( $drc::file2[$i] =~ /Pin Worst Transition/ ) { $worstTrans = getWorstTransition ( $drc::file2[$i] ) ; } # End of IF Statement if ( $drc::file2[$i] =~ /VIOLATION/ ) { $violation = getViolation ( $drc::file2[$i] ) ; # if ( $drc::rpt1{$moduleName}{$netName}{$gate}{$tran} != $drc::rpt2{$moduleName}{$netName}{$gate}{$tran}) { # print " Module = $moduleName \n" ; # print " \t\t Net = $netName \n" ; # print " \t\t\t Gate = $gate \n" ; # print " \t\t\t\t Transition Violation OLD Value = $drc::rpt1{$moduleName}{$netName}{$gate}{$tran} " ; # print " \t\t\t\t Transition Violation NEW Value = $drc::rpt2{$moduleName}{$netName}{$gate}{$tran} " ; # } # End of IF } # End of IF Statement } # End of FOR Loop } # End of SUBROUTINE ###################################################################### # Name : searchModuleName # Description : Subroutine to read Input Files and find Module Names in # second file # Date : 6 May 2004 ###################################################################### sub printValues { my ($rpt1) = @_ ; my $module ; my $net ; my $gate ; my $vlte ; foreach $module ( keys %rpt1 ) { print "$module"; foreach $net ( keys %{ $rpt1{$module} } ) { print "{$net}" ; foreach ( keys %{ $rpt1{$module}{$net} } ) { print "{$gate}" ; foreach $vlte ( keys %{ $rpt1{$module}{$net}{$gate} } ) { print "{$vlte}" ; } } } } # if ( $drc::rpt1{$moduleName}{$netName}{$gate}{$tran} != $drc::rpt2{$moduleName}{$netName}{$gate}{$tran}) { # print " Module = $moduleName \n" ; # print " \t\t Net = $netName \n" ; # print " \t\t\t Gate = $gate \n" ; # print " \t\t\t\t Transition Violation OLD Value = $drc::rpt1{$moduleName}{$netName}{$gate}{$tran} " ; # print " \t\t\t\t Transition Violation NEW Value = $drc::rpt2{$moduleName}{$netName}{$gate}{$tran} " ; # } # End of IF } ###################################################################### # Name : searchModuleName # Description : Subroutine to read Input Files and find Module Names in # second file # Date : 6 May 2004 ###################################################################### sub searchModuleName { # Subroutind to Search Module in Second Temporary File my ($ModuleName , $file1 , $file2) = @_ ; open ( TMPDRC2, "<$file2" ) ; my $searchModule; my $line; my $i; @drc::file2 = ; # Storing Contents of File in an Array for ( $i = 0 ; $i <= $#drc::file2 - 1 ; $i++ ){ if ( $drc::file2[$i] =~ m/^\s*\Module:/i ) { $searchModule = getModuleName ( $drc::file2[$i] ) ; } if ( $ModuleName eq $searchModule ) { print " $ModuleName Found in both files $i \n" ; } else { print " $ModuleName Not Found in second file $i\n" ; } } # End of While Loop close TMPDRC2; return 0; } # End of Subroutine searchModuleName ###################################################################### # Name : Log # Description : Subroutine Print Log Output # Date : 6 May 2004 ###################################################################### sub Log { my ( $msg ) = @_ ; print $msg ; } ";