trace2ver 1.82 KB
#!/usr/sbin/perl
#

$TEST = "";
$TRACE_FILE = "";

if ($#ARGV >= 0){
 $TEST = $ARGV[0];
 $TRACE_FILE = $TEST.".ctrace";
 }
if ($#ARGV == 1){
 $RANDOM = 1;
 }

open(TRACEIN,$TRACE_FILE) || die "Cant open $TRACE_FILE \n";
open(FP_SU,">$TEST.trSU") || die "Cant open file $TEST.trSU \n";
open(FP_VU,">$TEST.trVU") || die "Cant open file $TEST.trVU \n";
open(FP_DM,">$TEST.trDM") || die "Cant open file $TEST.trDM \n";

if ($RANDOM) {
  open(FP_NC,">$TEST.NC") || die "Cant open file $TEST.NC \n";
 }

$DEPTH = 256;

for ($i=0; $i<32; $i++) {
 $VU_CNT[$i] = 0;
}
$SU_CNT = 0;
$DM_CNT = 0;

while ($_ = <TRACEIN>) {

   split;
   chop;
   
   if ($_[0] eq "SU") {
	 $SU_CNT++;
         printf FP_SU "\@%03X  %s //pc=%s \n",$SU_CNT,$_[2], $_[1];
    }
   elsif ($_[0] eq "VS" || $_[0] eq "VV")  {
         ($JUNK,$VR) = split(/V/,$_[1]); 
	 $VU_CNT[$VR]++;
         if ($_[0] eq "VS") {
            printf FP_VU "\@%04X  0_%s  //bySU, pc=%s \n",$VU_CNT[$VR]+($VR*$DEPTH),$_[3], $_[2];
           }
	 else {
            printf FP_VU "\@%04X  1_%s\t\t\t//byVU, pc=%s \n",$VU_CNT[$VR]+($VR*$DEPTH),$_[3], $_[2];
           }
    }
   elsif ($_[0] eq "DM")  {
	 $DM_CNT++;
         printf FP_DM "\@%03X  %s //pc=%s \n",$DM_CNT,$_[2], $_[1];
    }
   elsif ($_[0] eq "NC")  {
         printf FP_NC "\@0 %s\n",$_[1];
    }
   else  {
     die "ERROR: unrecognised token";
    }
}

print FP_SU "/**********/\n";
printf FP_SU "\@000  %05x //Trace Count \n",$SU_CNT;

print FP_VU "/**********/\n";
for ($i=0; $i<32; $i++) {
  printf FP_VU "\@%04X  %05x //Trace Count \n",($i*$DEPTH),$VU_CNT[$i];

  if ($VU_CNT[$i]>=$DEPTH) {
      printf FP_VU "TRACE COUNT on Vector Register %d Exceeds $DEPTH\n",$i;
    }

}

print FP_DM "/**********/\n";
printf FP_DM "\@000  %05x //Trace Count \n",$DM_CNT;

close (FP_SU);
close (FP_VU);
close (FP_DM);

if ($RANDOM) { close (FP_NC); }