trace_print.c 3.34 KB

/**************************************************************************
 *                                                                        *
 *               Copyright (C) 1994, Silicon Graphics, Inc.               *
 *                                                                        *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
 *  are protected by Federal copyright  law.  They  may not be disclosed  *
 *  to  third  parties  or copied or duplicated in any form, in whole or  *
 *  in part, without the prior written consent of Silicon Graphics, Inc.  *
 *                                                                        *
 *************************************************************************/

/*
 * File:	vu.c
 * Creator:	hsa@sgi.com
 * Create Date:	Tue Feb  8 11:51:11 PST 1994
 *
 * This file is the top of the vector unit for the RSP simulator.
 *
 */

#include <stdio.h>
#include "rsp.h"
#include "i128.h"
#include "trace_print.h"

void
traceVUbyVU(int vr, int elem, i128 *y, int pc)
{
  int i;

  u16 tmp[8];
  for (i=0; i<8; i++) 
    tmp[i] = (y->b[i*2]<<8)&0xff00 | y->b[i*2+1]&0x00ff;

 if (trout_en==TRUE) {
  fprintf(trout,"VV  $V%-2d %03x %028x_%02x_%02x_%04x_%04x_%04x_%04x_%04x_%04x_%04x_%04x\n", 
         vr, pc&0xfff, 0x0, vr, elem,tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5],tmp[6],tmp[7]);
  }
}

void
traceVUbyLTV(int vr, int format, i128 *y,int pc)
{
  int i;
  int rn[8];
  int bm[8];
  u16 tmp[8];
  int elm;
  for (i=0; i<8; i++) {
    tmp[i] = (y->b[i*2]<<8)&0xff00 | y->b[i*2+1]&0x00ff;
    elm = ((format>>1) + i) & 0x7;
    rn[i] = (vr&0x18) + elm;
    bm[i] = 3;
    }
 if (trout_en==TRUE) {
  fprintf(trout,"VS $V%-2d %03x ",rn[0],pc&0xfff);
  fprintf(trout,"%02x_%02x_%04x",rn[0],bm[0],tmp[0]);
  for (i=1; i<8; i++)
   fprintf(trout,"__%02x_%02x_%04x",rn[i],bm[i],tmp[i]);
  fprintf(trout,"\n");
 }
}

void
traceVUbySU(int vr, int bytemask, i128 *y,int pc)
{
  int i;
  int bm[8];
  u16 tmp[8];
  for (i=0; i<8; i++)
    {
    tmp[i] = (y->b[i*2]<<8)&0xff00 | y->b[i*2+1]&0x00ff;
    bm[i] = (bytemask >> ((7 - i)*2)) & 0x3;
    }

 if (trout_en==TRUE) {
  fprintf(trout,"VS $V%-2d %03x ",vr,pc&0xfff);
  fprintf(trout,"%02x_%02x_%04x",vr,bm[0],tmp[0]);
  for (i=1; i<8; i++)
   fprintf(trout,"__%02x_%02x_%04x",vr,bm[i],tmp[i]);
  fprintf(trout,"\n");
 }
}

void
traceSU(int reg_num, u32 data,int pc)
{
 if (trout_en==TRUE) {
   if (reg_num!=0)
     fprintf(trout,"SU  %03x %02x_%08x\n", pc&0xfff, reg_num, data);
  }
}


void
traceDM(u32 addr, i128 *Data,i128 *Mask, int pc,int bytes)
{

 int  maskH,maskL;
 int  addrH, addrL;
 int  i;
 u64  dataH,dataL;

 if (trout_en==TRUE) {
   maskH = maskL = 0;
   dataH = dataL = 0;
   addrH = addrL = (addr>>4) & 0xfff;

   for (i=0; i<8; i++) {
     maskH = maskH | (Mask->b[i]<<(7-i));
     maskL = maskL | (Mask->b[8+i]<<(7-i));

     dataH = dataH | ((u64) Data->b[i]<<((7-i)*8));
     dataL = dataL | ((u64) Data->b[8+i]<<((7-i)*8));
    }

   if (((addr&0xf)>14 && bytes>=2) ||
       ((addr&0xf)>12 && bytes>=4) ||
       ((addr&0xf)>8  && bytes>=8) ||    
       ((addr&0xf)==8  && bytes==16) /* stv case */    
      )
      addrH = addrL + 1;
	
   fprintf(trout, "DM  %03x %02x_%02x_%016llx__%02x_%02x_%016llx \n",
			pc&0xfff, addrH&0xff, maskH, dataH, addrL&0xff, maskL, dataL); 

  }
}