trace_print.c
3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**************************************************************************
* *
* 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);
}
}