#!/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 (/nom_voltage /) {
s/;//;
@rail_voltage=split(":",$_);
$rail_voltage=$rall_voltage[1];
print "Rail Voltage is $rall_voltage\n";
print "95% of Rail Voltage is ".$rall_voltage*0.95."\n";
}}
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/ref erence_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);
$t=0; $rename=0; $starting_v=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 : gnuplot_ccst.txt \n";
chop $_;
$_ =~ s/^\s+|\s+$//g ; ## remove space
if ($i=="1") {$ref_time=$_;} ## reference_time
if (Si=="2") {$slew=$_;} ## slew
if (Si=="3") {$load=$_;} ## load
if (Si=="4") { ## time steps
@aryl=split(",",$_);
$max_index_3 = max @aryl;
$min_index_3 = min @aryl;
push (@accumulated_max_index_3, $max_index_3);
push (@accumulated_min_index_3, $min_index_3);
#print "The index_3 size is " ; print scalar @aryl; 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";
}
$i++;
for ($j=0; $j<$array_size; $j++) {
print TEMFILE "$aryl[$j] ";
print TEMFILE "$ary2[$j]\n";
}
for ($j=0; $j<$array_size; $j++) {
print VOLTAGE "$aryl[$j] ";
if ($j == "0") {$voltage=$starting_v;}
if ($j > 0) {
$time_step=$aryl[$j]-$ary1[$j-1];
$voltage_step=($avg_current*$time_step)/$load;
$voltage=$v_init+$voltage_step;}
print VOLTAGE "$voltage\n";
}
$i=1; $rename=1;
## To check if final voltage reached 95% of VDD
#print "Rail voltage: Srail_voltage Final voltage: $voltage 95% of Rail voltage:
if (abs($voltage) < ($rail_voltage*0.95)) {print "last voltage point $voltage doesn't reach 95% of VDD at CCST#$t\n";}
}
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 : gnuplot_ccst.txt \n";
open(VOLTAGE, ">gnuplot_voltage.txt") || die "Can not open the file : gnuplot_voltage.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 $min = min @array;
## Print out size of index_3 and value of CCST
##$array_size = $#aryl+1;
##print "$array_size \n";
##print scalar @aryl;
##print scalar @ary2;
close(TEMFILE);
close(VOLTAGE);
沒有留言:
張貼留言