Tuesday, July 3, 2018

perl scripts2

1. lib post processing:

#######################################################
## liberty file postprocessing
##
######################################################
#!/usr/bin/perl -w

use strict;
use File::Basename;

if (($ARGV[0] eq "-h")  or ($ARGV[0] eq "-help"))
{
  print "USAGE      :: lib_postprocess.pl <.lib file> \n";
  print "DESCRIPTION:: All instances of will be replaced by in (including file name)\n";
  exit 0;
}

my $file    = $ARGV[0];
my $tempfile = "$ARGV[0]"."_new";

open INFILE, "<$file" or die "Cannot open $file: $!\n";

open OUTFILE,">$tempfile" or die "Cannot open $tempfile: $!\n";
my $line;
my $instance_a0 = 0;
my $instance_a1 = 0;
my $instance_a2 = 0;
my $instance_a3 = 0;
my $instance_a4 = 0;
my $instance_a5 = 0;
my $instance_a6 = 0;

#my $a0 = "adacond_(\w+) == (.*)\"";
#my $b0 = "adacond_$1\"";

my $a1 = "\"adacond_TE\"";
my $b1 = "\"TE\"";

my $a2 = "\"adacond_TI\"";
my $b2 = "\"TI\"";

my $a3 = "\"adacond_CD\"";
my $b3 = "\"CD\"";

my $a4 = "\"adacond_E\"";
my $b4 = "\"E\"";

my $a5 = "\"adacond_D\"";
my $b5 = "\"D\"";

my $a6 = "\"adacond_SD\"";
my $b6 = "\"SD\"";

while($line=)
{
  chomp($line);
#input_threshold_pct_fall : 60;
if ($line =~ m/input_threshold_pct_fall/)  {
print OUTFILE  "  define (decoupling_capacitance, cell, float);\n";
#print OUTFILE  "$line \n";
}
#my $a0 = "adacond_(\w+) == (.*)\"";
#my $b0 = "adacond_$1\"";

if ($line =~ m/adacond_(\w+) == (.*)\"/)  {
    $line =~ s/adacond_(\w+) == (.*)\"/adacond_$1\"/g;
    $instance_a0++;   
  }
if ($line =~ m/$a1/)  {
    $line =~ s/$a1/$b1/g;
    $instance_a1++;   
  }
if ($line =~ m/$a2/)  {
    $line =~ s/$a2/$b2/g;
    $instance_a2++;   
  }
if ($line =~ m/$a3/)  {
    $line =~ s/$a3/$b3/g;
    $instance_a3++;   
  }
if ($line =~ m/$a4/)  {
    $line =~ s/$a4/$b4/g;
    $instance_a4++;   
  }
if ($line =~ m/$a5/)  {
    $line =~ s/$a5/$b5/g;
    $instance_a5++;   
  }
if ($line =~ m/$a6/)  {
    $line =~ s/$a6/$b6/g;
    $instance_a6++;   
  }

  print OUTFILE "$line \n";
}
close INFILE;
close OUTFILE;

#print "$instance_a0 line(s) containing $a0 replaced by $b0 \n";
print "$instance_a0 line(s) containing /adacond_(\w+) == (.*)\" with /adacond_$1\" \n";
print "$instance_a1 line(s) containing $a1 replaced by $b1 \n";
print "$instance_a2 line(s) containing $a2 replaced by $b2 \n";
print "$instance_a3 line(s) containing $a3 replaced by $b3 \n";
print "$instance_a4 line(s) containing $a4 replaced by $b4 \n";
print "$instance_a5 line(s) containing $a5 replaced by $b5 \n";
print "$instance_a6 line(s) containing $a6 replaced by $b6 \n";

print " post processing of .lib is completed... \n";


2.  lib_normal.pl

#!/usr/bin/perl -w

use strict;
use File::Basename;

if (($ARGV[0] eq "-h")  or ($ARGV[0] eq "-help"))
{
  print "USAGE      :: perl

No comments:

Post a Comment