#! /usr/local/bin/perl
### input all simulation waveforms then export values which have spike current
### generate a shell script (check_waveform.sh) to plot waveforms in gnuplot for examination
open (AA, "ls analyze_ccs/*/*/*/waveforms/waveform simulation.txt |") or die;
while (<AA>){
chomp;
push @libs, $_;
}
close AA;
$out = "check_waveform.sh";
open (BB,">$out") or die;
foreach $lib (@libs){
open (AA, $lib) or die;
#print "file: $lib ";
$i=0; $previous_current=le-8; $present_current=le-8;
#$dir=`basename $lib`;
$dir=`dirname $lib`;
chomp($dir);
#print "dir path is $dir \n";
while (<AA>){
chomp;
if ($i>"1"){
@current=split(" ",$_);
$present_current=$current[1];}
if ($i=="2"){
$previous_current=$current[1]; $present_current=$current[1];}
$rel_diff=abs($previous_current/$present_current) ;
#print "Rel diff is $rel_diff , previous is $previous_current , present is $present_current \n";
#export waveform values which have large differences (X10000)
if ($rel_diff > 10000 || $rel_diff < 0.0001){
print "file: $lib has spike at line $i, Rel diff is $rel_diff, previous is $previous_current, present is $present_current\n";
$time_axis=$current[0]+le-10;
print BB "sed -i '/set datafile missing/i";
print BB "set xrange [0:$time_axis]";
print BB "gnuplot $dir/gnuplot.cmd\n";
print BB "gnuplot $dir/gnuplot.cmd\n";
}
$previous_current=$present_current ;
$i++;
}
close AA;
}
close BB;
沒有留言:
張貼留言