2020年7月8日 星期三

untar all files

#!/bin/csh
    foreach filename (`ls *.tgz | sed -r "s/\x1B\[[0-9;]*[mK]//g"`)
    tar -zxvf $filename
end

2020年3月31日 星期二

Check LIB-817 in Liberate

#!/usr/bin/perl
# set targeted files
$FILE1 = "sim.sp" ; $FILE2 = "sim.measure" ;
open (SP, "$FILE1"); open (MEAS, "$FILE2");

### Section 1
## glean initial-conditions (pulse results) from sim.measure
my %meas_hash;
while (<MEAS>) {
            chop $_;
            if (/altosinitialcondition/) {
                  @init = split("=",$_);
                  $init[0] =~ s/\s+//;  #remove space
                  $init[1] =~ s/\s+//;
                  #print "$init[0] $init[1]\n"; #print out for checking
                  $meas_hash { $init[0] } = $init[1];  #create hash table for measurement data
                  # another type
                  # %meas_hash = @init;
              }}
## uncomment following 3 lines to out measurement result we got from sim.measure
#foreach $key (keys %meas_hash){
#          print "pulse measured initial value of $key : $meas_hash{$key}\n";
#}
### Section 2
### glean node information from sim.sp
my %node_hash ;
while (<SP>) {
           chop $_;
           if(/AltosInitialCondition/) {
                   @node = split(" ",$_);
                   $node[2] =~ s/\s+//; $node[2] = lc($node[2]);
                   $node[4] =~ s/\s+//; $node[4] =~ s/v\(//; $node[4] =~ s/\)//;
                   #print "$node[2] $node[4]\n"; #print out for checking
                   $node_hash { $node[2] } = $node[4];
} }
close SP;

### Section 3 
### glean inside-view values from sim.sp 
open (SP, "$FILE1"); 
my %inside_view_hash; 
while (<SP>) { 
           chop $_; 
           if (/^.nodeset/ || /^.ic/) { 
                     s/=//; # remove '=' in .ic to align with format of .nodeset 
                     @inside_view = split(" ",$_); 
                     $inside_view[1] =~ s/\s+//; $inside_view[1] =~ s/v\(//; $inside_view[1] =~ s/\)//; 
                     $inside_view[2] =~ s/\s+//; 
                     foreach $key (keys %node_hash){ 
                           if ($inside_view[1] =~ $node_hash{$key}) { 
                                  $inside_view_hash { $inside_view[1] } = $inside_view[2]; 
                                  #print "$key : nodel= $node_hash{$key} of inside-view value is $inside_view[3]\n"; 
                     }} 
}}
## uncomment following 3 lines to print out inside view result we got from sim.sp 
#foreach $key (keys %inside_view_hash){ 
#             print "inside view initial value of $key : $inside_view_hash{$key}\n"; 
#} 
### Section 4 
### print out result 
#print "List inside-view vs pulse results\n"; 
#print " node inside-view pulse\n"; 
#print "***********************************************************************\n"; #foreach $key (keys %node_hash){ 
#              if (!$inside_view_hash{$node_hash{$key}}) { 
#                       if (defined $inside_view_hash{$node_hash{$key}}) { 
#                              print "";} 
#                       else { 
#                              $inside_view_hash{$node_hash{$key}}="9.99999";}} 
#               print "$key $node_hash{$key} "; print "$inside_view_hash{$node_hash{$key}} "; print "$meas_hash{$key}\n"; 
#}
print "List inside-view vs pulse results\n"; 
print " node inside-view pulse\n"; 
print "***********************************************************************\n"; foreach $key (keys %node_hash){ 
               if (!$inside_view_hash{$node_hash{$key}}) { 
                     if (defined $inside_view_hash{$node_hash{$key}}) { 
                                  print "";} 
                     else { 
                                  $inside_view_hash{$node_hashf$keyl}="9.99999";}}
               printf ("%30s %15s ",$key, $node_hash{$key}); printf ("%.5f  ",$inside_view_hash{$node_hash{$key}}); printf ("%.10f \n",$meas_hash{$key}); 
}

Results:

2020年2月16日 星期日

C Shell -- Calculation

This script was written for plot all 8x8 ccst tables.

#!/bin/csh

set i = 1
while ($i < 65)
            cp CCST.$i CCST.print
            cp VOLTAGE.$i VOLTAGE.print
            echo $i
            gunplot print_all_ccst.gp
            @ i = $i + 1
               ^
end


#### print_all_ccst.gp ####
#!/usr/bin/gnuplot

plot "CCST.print" using 1:2 with linespoints title "CCST"
pause mouse "click any mouse button on selected data point"
plot "VOLTAGE.print" using 1:2 with linespoints title "VOLTAGE"
pause mouse "click any mouse button on selected data point"

2019年10月27日 星期日

plot dc_current

#!/usr/bin/perl

$FILE_NAME = $ARGV[0];
open(h2,">dc.txt");
$i=0; $j=1;

open(SearchFile, "$FILE_NAME");

while(<SearchFile>){
               chop $_;
                             if ($i=="0") {
                                       @x=split(",",$_);
                                       print "first";
                                                  }

                              if($i!="0") {
                                        @y=split(",",$_);
                                         for($j=0; $j<29; $j++) {
                                                       print h2 "@x[$j] @y[$j] \n";
                                                                               }
                                         close (h2);
                                         rename("dc.txt","dc_current_$i");
                                         open(h2,">dc.txt");
                                                   }
$i++;
}
close (h2);

##############  gnuplot ####################
#!/usr/bin/gnuplot
plot [0.4:0.6] "orig25" using 1:2 with linespoints title "TSMC", "aps" using 1:2 with linespoints title "wo APS", "conservative" using 1:2 with linespoints title "conservative"

pause mouse "click any mouse button on selected data point"

2019年10月23日 星期三

Plot 3d dc_current

#!/usr/bin/perl


$FILE_NAME = $ARGV[0];
open(h2,">dc.txt");
$i=0; $j=1; $x_count=0;

open(SearchFile, "$FILE_NAME");
while(<SearchFile>) {
               chop $_;
s/"//g;
s/\(//g;
s/\)//g;
s/index_1//g;
s/index_2//g;
s/;//g;
s/, \\//g;
s/\\//g;
                             if($i=="0"){
                                         @x=split(",",$_);
                                          print "x axis";
                                                }
                             if($i=="1"){
                                         @y=split(",",$_);
                                          print "y axis";
                                                }
                             if($i>"1"){
                                         @z=split(",",$_);
                                          for($j=0; $j<29; $j++){
                                                           print h2 "@x[$x_count] @y[$j] @z[$j] \n";
                                                                               }
                                                           $x_count++;
                                                }
$i++;
}
close (h2);
rename("dc.txt","3d_dc_current");
system "gnuplot plot3d.gp 3d_dc_current"


####### plot3d.gp #######
set xlabel "index_1"; set ylabel "index_2"; set zlabel "current"
set dgrid3d 29,29
#set hidden3d
set pm3d; set palette
splot '3d_dc_current' u 1:2:3 with line
pause mouse keypress "type"









2019年8月11日 星期日

rerun Spectre in Liberate

Create a C shell script:

cp sim.sp 1.sp
sed -i 's/save=nooutput/save=all/g' 1.sp
grep 'Command line:' -A 5 sim.lis > r
sed -i '/Command line/d' r
sed -i '/sim.sp/d' r
sed -i 's/sim.lis/1.lis 1.sp/' r
sed -i 's/\\//g' r
sed -i ":a;N;s/\n//g;ta" r
source r

2019年5月28日 星期二

標籤