$FILE_NAME = $ARGV[0];
$i=1;
$write_out = 0; $curly_brackets=0; $write_next=0; $start=0;
open(TEMCCST, ">temp_ccst.txt") || die "Can not open the file : temp.txt \n";
open(SearchFile, "<$FILE_NAME");
while(<SearchFile>){
chop $_;
if (/cell \(/) {$start = 1;}
if($start == "1") {
if (/output_current/) {$write_out =1;}
if($write_next == "1") {
s/"//g;
s/\\//g;
print TEMCCST "$_\n"; $write_next=0;}
if ($write_out == "1") {
if (/\{/) {$curly_brackets++;}
if (/\}/) {$curly_brackets--;}
if (/index_3/) {
s/index_3 \("//g;
s/"\);//g;
print TEMCCST "$_\n";}
if (/values/) {$write_next = 1;}
if ($curly_brackets== "0") {$write_out = 0;}
}
}
}
close(SearchFile);
close(TEMCCST);
$t=0; $rename=0;
open(CCST, "<temp_ccst.txt") || die "Can not open the file : temp_ccst.txt \n";
open(TEMFILE, ">gnuplot_ccst.txt") || die "Can not open the file : temp.txt \n";
while(<CCST>){
chop $_;
if ($i=="1") {
@ary1=split(",",$_);}
if ($i=="2") {
@ary2=split(",",$_);}
$i++;
if($i > 2) {
$array_size = $#ary1+1;
for ($j=0; $j<$array_size; $j++) {
print TEMFILE "$ary1[$j] ";
print TEMFILE "$ary2[$j]\n ";
}
$i=1; $rename=1;
}
if ($rename=="1") {
close(TEMFILE);
rename("gnuplot_ccst.txt",CCST.".$t");
print "CCST file number is $t \n";
$t++;
open(TEMFILE, ">gnuplot_ccst.txt") || die "Can not open the file : temp.txt \n";
$rename=0;
}}
close(CCST);
close(TEMFILE);
Version-II:
#!/usr/bin/perl
$FILE_NAME = $ARGV[0];
$i=1;
$write_out = 0; $curly_brackets=0; $write_next=0; $start=0;
open(TEMCCST, ">temp_ccst.txt") || die "Can not open the file : temp.txt \n";
open(SearchFile, "<$FILE_NAME");
while(<SearchFile>){
chop $_;
if (/cell \(/) {$start = 1;}
if($start == "1") {
if (/output_current/) {$write_out =1;}
if($write_next == "1") {
s/"//g;
s/\\//g;
print TEMCCST "$_\n"; $write_next=0;}
if ($write_out == "1") {
if (/\{/) {$curly_brackets++;}
if (/\}/) {$curly_brackets--;}
if (/index_3/) {
s/index_3 \("//g;
s/"\);//g;
print TEMCCST "$_\n";}
if (/values/) {$write_next = 1;}
if ($curly_brackets== "0") {$write_out = 0;}
}
}
}
close(SearchFile);
close(TEMCCST);
use List::Util qw/max min/;
$t=0; $rename=0;
open(CCST, "<temp_ccst.txt") || die "Can not open the file : temp_ccst.txt \n";
open(TEMFILE, ">gnuplot_ccst.txt") || die "Can not open the file : temp.txt \n";
while(<CCST>){
chop $_;
if ($i=="1") {
@ary1=split(",",$_);
$max_index_3 = max @ary1;
$min_index_3 = min @ary1;
push (@accumulated_max_index_3, $max_index_3);
push (@accumulated_min_index_3, $min_index_3);
print "The index_3 size is " ; print scalar @ary1; print "\n";
print "The max number of index_3 is $max_index_3 , The min is $min_index_3 \n";}
$max_index_3 = max @ary1;
$min_index_3 = min @ary1;
push (@accumulated_max_index_3, $max_index_3);
push (@accumulated_min_index_3, $min_index_3);
print "The index_3 size is " ; print scalar @ary1; print "\n";
print "The max number of index_3 is $max_index_3 , The min is $min_index_3 \n";}
if ($i=="2") {
@ary2=split(",",$_);
$max_value = max @ary2;
$min_value = min @ary2;
push (@accumulated_max_value, $max_value);
push (@accumulated_min_value, $min_value);
print "The value size is " ; print scalar @ary2; print "\n";
print "The max number of value is $max_value , The min is $min_value \n";}
$max_value = max @ary2;
$min_value = min @ary2;
push (@accumulated_max_value, $max_value);
push (@accumulated_min_value, $min_value);
print "The value size is " ; print scalar @ary2; print "\n";
print "The max number of value is $max_value , The min is $min_value \n";}
$i++;
if($i > 2) {
$array_size = $#ary1+1;
for ($j=0; $j<$array_size; $j++) {
print TEMFILE "$ary1[$j] ";
print TEMFILE "$ary2[$j]\n ";
}
$i=1; $rename=1;
}
if ($rename=="1") {
close(TEMFILE);
rename("gnuplot_ccst.txt",CCST.".$t");
print "CCST file number is $t \n";
$t++;
open(TEMFILE, ">gnuplot_ccst.txt") || die "Can not open the file : temp.txt \n";
$rename=0;
}}
$accumulated_max_index_3 = max @accumulated_max_index_3;
$accumulated_min_index_3 = min @accumulated_min_index_3;
$accumulated_max_value = max @accumulated_max_value;
$accumulated_min_value = min @accumulated_min_value;
print "\n";
print "#######################\n";
print "print out max/min index_3/value \n";
print "#######################\n";
print "The whole max/min index_3 are $accumulated_max_index_3/$accumulated_min_index_3 \n";
print "The whole max/min value are $accumulated_max_value/$accumulated_min_value \n";
my $max = max @array;
my $min = min @array;
## Print out size of index_3 and value of CCST
#$array_size = $#ary1+1;
#print "$array_size \n";
#print scalar @ary1;
#print scalar @ary2;
close(CCST);
close(TEMFILE);
Version-III:
#!/usr/bin/perl
$FILE_NAME = $ARGV[0];
$i=1;
$write_out = 0; $curly_brackets=0; $write_next=0; $start=0;
open(TEMCCST, ">temp_ccst.txt") || die "Can not open the file : temp.txt \n";
open(SearchFile, "<$FILE_NAME");
while(<SearchFile>){
chop $_;
if (/voltage/) {
if (/VDD/) {
s/\);//g;
@rail_voltage=split(",",$_);
$rail_voltage=$rail_voltage[1];
}}
if (/cell \(/) {$start = 1;}
if($start == "1") {
if (/output_current/) {$write_out =1;}
if($write_next == "1") {
s/"//g;
s/\\//g;
print TEMCCST "$_\n"; $write_next=0;}
if ($write_out == "1") {
if (/\{/) {$curly_brackets++;}
if (/\}/) {$curly_brackets--;}
if (/index_3/) {
s/index_3 \("//g;
s/"\);//g;
print TEMCCST "$_\n";}
if (/reference_time/) {
s/reference_time//g;
s/://g;
s/;//g;
print TEMCCST "$_\n";}
if (/index_1/) {
s/index_1 \("//g;
s/"\);//g;
print TEMCCST "$_\n";}
if (/index_2/) {
s/index_2 \("//g;
s/"\);//g;
print TEMCCST "$_\n";}
if (/values/) {$write_next = 1;}
if ($curly_brackets== "0") {$write_out = 0;}
}
}
}
close(SearchFile);
close(TEMCCST);
use List::Util qw/max min/;
$t=0; $rename=0;
open(CCST, "<temp_ccst.txt") || die "Can not open the file : temp_ccst.txt \n";
open(TEMFILE, ">gnuplot_ccst.txt") || die "Can not open the file : temp.txt \n";
$accumulated_max_index_3 = max @accumulated_max_index_3;
$accumulated_min_index_3 = min @accumulated_min_index_3;
$accumulated_max_value = max @accumulated_max_value;
$accumulated_min_value = min @accumulated_min_value;
print "\n";
print "#######################\n";
print "print out max/min index_3/value \n";
print "#######################\n";
print "The whole max/min index_3 are $accumulated_max_index_3/$accumulated_min_index_3 \n";
print "The whole max/min value are $accumulated_max_value/$accumulated_min_value \n";
my $max = max @array;
my $min = min @array;
## Print out size of index_3 and value of CCST
#$array_size = $#ary1+1;
#print "$array_size \n";
#print scalar @ary1;
#print scalar @ary2;
Version-III:
#!/usr/bin/perl
$FILE_NAME = $ARGV[0];
$i=1;
$write_out = 0; $curly_brackets=0; $write_next=0; $start=0;
open(TEMCCST, ">temp_ccst.txt") || die "Can not open the file : temp.txt \n";
open(SearchFile, "<$FILE_NAME");
while(<SearchFile>){
chop $_;
if (/voltage/) {
if (/VDD/) {
s/\);//g;
@rail_voltage=split(",",$_);
$rail_voltage=$rail_voltage[1];
}}
if (/cell \(/) {$start = 1;}
if($start == "1") {
if (/output_current/) {$write_out =1;}
if($write_next == "1") {
s/"//g;
s/\\//g;
print TEMCCST "$_\n"; $write_next=0;}
if ($write_out == "1") {
if (/\{/) {$curly_brackets++;}
if (/\}/) {$curly_brackets--;}
if (/index_3/) {
s/index_3 \("//g;
s/"\);//g;
print TEMCCST "$_\n";}
if (/reference_time/) {
s/reference_time//g;
s/://g;
s/;//g;
print TEMCCST "$_\n";}
if (/index_1/) {
s/index_1 \("//g;
s/"\);//g;
print TEMCCST "$_\n";}
if (/index_2/) {
s/index_2 \("//g;
s/"\);//g;
print TEMCCST "$_\n";}
if (/values/) {$write_next = 1;}
if ($curly_brackets== "0") {$write_out = 0;}
}
}
}
close(SearchFile);
close(TEMCCST);
use List::Util qw/max min/;
$t=0; $rename=0;
open(CCST, "<temp_ccst.txt") || die "Can not open the file : temp_ccst.txt \n";
open(TEMFILE, ">gnuplot_ccst.txt") || die "Can not open the file : temp.txt \n";
open(VOLTAGE, ">gnuplot_voltage.txt") || die "Can not open the file : temp.txt \n";
while(<CCST>){
chop $_;
if ($i=="1") {$ref_time = $_;} ## reference_time
if ($i=="2") {$slew= $_;} ## slew
if ($i=="3") {$load = $_;} ## load
if ($i=="1") {$ref_time = $_;} ## reference_time
if ($i=="2") {$slew= $_;} ## slew
if ($i=="3") {$load = $_;} ## load
if ($i=="4") { ## time steps
@ary1=split(",",$_);
$max_index_3 = max @ary1;
$min_index_3 = min @ary1;
push (@accumulated_max_index_3, $max_index_3);
push (@accumulated_min_index_3, $min_index_3);
print "The index_3 size is " ; print scalar @ary1; print "\n";
print "The max number of index_3 is $max_index_3 , The min is $min_index_3 \n";}
$max_index_3 = max @ary1;
$min_index_3 = min @ary1;
push (@accumulated_max_index_3, $max_index_3);
push (@accumulated_min_index_3, $min_index_3);
print "The index_3 size is " ; print scalar @ary1; print "\n";
print "The max number of index_3 is $max_index_3 , The min is $min_index_3 \n";}
if ($i=="5") { ## current steps
@ary2=split(",",$_);
$max_value = max @ary2;
$min_value = min @ary2;
push (@accumulated_max_value, $max_value);
push (@accumulated_min_value, $min_value);
print "The value size is " ; print scalar @ary2; print "\n";
print "The max number of value is $max_value , The min is $min_value \n";}
$max_value = max @ary2;
$min_value = min @ary2;
push (@accumulated_max_value, $max_value);
push (@accumulated_min_value, $min_value);
print "The value size is " ; print scalar @ary2; print "\n";
print "The max number of value is $max_value , The min is $min_value \n";}
$i++;
if($i > 5) {
$array_size = $#ary1+1;
for ($j=0; $j<$array_size; $j++) {
print TEMFILE "$ary1[$j] ";
print TEMFILE "$ary2[$j]\n ";
}
for ($j=0; $j<$array_size; $j++) {
print VOLTAGE "$ary1[$j] ";
if ($j == "0") {$voltage=$rail_voltage;}
if ($j > 0) {
$avg_current=($ary2[$j]+$ary2[$j-1])/2;
$time_step=$ary1[$j]-$ary1[$j-1];
$voltage_step=($avg_current*$time_step)/$load;
$voltage=$v_init+$voltage_step;}
$v_init=$voltage;
if ($j == "0") {$voltage=$rail_voltage;}
if ($j > 0) {
$avg_current=($ary2[$j]+$ary2[$j-1])/2;
$time_step=$ary1[$j]-$ary1[$j-1];
$voltage_step=($avg_current*$time_step)/$load;
$voltage=$v_init+$voltage_step;}
$v_init=$voltage;
print VOLTAGE "$voltage\n ";
}
$i=1; $rename=1;
}
if ($rename=="1") {
close(TEMFILE); close(VOLTAGE);
rename("gnuplot_ccst.txt",CCST.".$t"); rename("gnuplot_voltage.txt",VOLTAGE.".$t");
print "CCST/VOLTAGE file number is $t \n";
$t++;
open(TEMFILE, ">gnuplot_ccst.txt") || die "Can not open the file : temp.txt \n";
open(VOLTAGE, ">gnuplot_voltage.txt") || die "Can not open the file : temp.txt \n";
$rename=0;
}}
$accumulated_max_index_3 = max @accumulated_max_index_3;
$accumulated_min_index_3 = min @accumulated_min_index_3;
$accumulated_max_value = max @accumulated_max_value;
$accumulated_min_value = min @accumulated_min_value;
print "\n";
print "#######################\n";
print "print out max/min index_3/value \n";
print "#######################\n";
print "The whole max/min index_3 are $accumulated_max_index_3/$accumulated_min_index_3 \n";
print "The whole max/min value are $accumulated_max_value/$accumulated_min_value \n";
my $max = max @array;
my $min = min @array;
## Print out size of index_3 and value of CCST
#$array_size = $#ary1+1;
#print "$array_size \n";
#print scalar @ary1;
#print scalar @ary2;
close(CCST);
close(TEMFILE);
close(VOLTAGE);
close(VOLTAGE);