vlt.c
3.05 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
/****************************************************************
WHAT: RSP SCALAR UNIT TEST GENERATOR FOR VECTOR LOAD INSTRUCTIONS
SCCS: %W% %G%
FILE: vld.c
WHO: Project Reality - Evan Y. Wang
(C): 1994 Silicon Graphics, Inc.
****************************************************************/
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "software.h"
#include "gen.h"
#include "suregre.h"
PRIVATE UD32 DMem[0x1000>>2];
PRIVATE u32 Rand32()
{
return (((u32) (rand()&0x3FF)<<22)
| ((u32) (rand()&0x3FF)<<12)
| ((u32) (rand()&0xFFF)));
}
PRIVATE void GenCase(outp,tno,vT,el,vR,vD,rA,rAval,rB,rR)
FILE *outp; /* output file */
int tno; /* test number */
int vT; /* target of test */
int el; /* element */
int vR; /* result check */
int vD; /* dump */
int rA; /* SU addr reg */
u32 rAval; /* starting data addr */
int rB; /* temp */
int rR; /* VNE result */
{
int i;
fprintf(outp,"\n\t/* TEST #%2.2d ",tno);
fprintf(outp,"*********************************************/\n");
fprintf(outp,"\tori\t$1,\t$0,\t%d\n",tno);
for (i=0; i<8; i++) {
fprintf(outp,"\tlqv\t$v%d,\t0x%X($%d)\n",vT+i,(0x10*i),rA);
fprintf(outp,"\tlqv\t$v%d,\t0x%X($%d)\n",vR+i,(0x10*i),rA);
}
fprintf(outp,"\taddi\t$%d,\t$%d,\t0x80\n",rA,rA);
for (i=0; i<8; i++)
fprintf(outp,"\tlsv\t$v%d[%d],\t0x%X($%d)\n",vR+i,((8-el+i)&0x7)<<1,i*2,rA);
fprintf(outp,"\n");
fprintf(outp,"\tnop\n");
fprintf(outp,"\tnop\n");
fprintf(outp,"\tnop\n");
fprintf(outp,"\tltv\t$v%d[%d],\t0($%d)\n",vT,el,rA);
fprintf(outp,"\tnop\n");
fprintf(outp,"\tnop\n");
fprintf(outp,"\tnop\n");
fprintf(outp,"\n");
for (i=0; i<8; i++) {
fprintf(outp,"\tctc2\t$0,\t$v0\n"); /* clear VCO */
fprintf(outp,"\tnop\n");
fprintf(outp,"\tveq\t$v%d,\t$v%d,\t$v%d\n",vD,vT+i,vR+i);
fprintf(outp,"\tnop\n");
fprintf(outp,"\tcfc2\t$%d,\t$v1\n",rR); /* fetch VCC */
fprintf(outp,"\tnop\n");
fprintf(outp,"\tbne\t$%d,\t$%d,\tFail\n",rB,rR);
fprintf(outp,"\tnop\n");
}
} /* GenCase */
/************************************************************************
DmemInit(..) - initialize DMEM.
************************************************************************/
PRIVATE void DMemInit(outp)
FILE *outp;
{
int i;
u32 tdp;
tdp = 0;
for (i=0; i<(DMEM_SIZE>>2); i++, tdp+=4)
fprintf(outp,"\t.word\t0x%8.8lX\t\t/* Addr: 0x%4.4X */\n",
DMem[i].w=Rand32(), tdp);
} /* DMemInit */
int VltGen(outp, ip)
FILE *outp;
I_TABLE *ip;
{
int i, j, k;
int vT;
int vR;
int vD;
DMemInit(outp);
OpA = DMEM_BASE;
fprintf(outp,"\tlui\t$%d,\t0x%4.4X\n",rA,OpA>>16);
fprintf(outp,"\tori\t$%d,\t0x%4.4X\n",rA,OpA&0xFFFF);
OpB = 0xFF;
fprintf(outp,"\tlui\t$%d,\t0\n",rB);
fprintf(outp,"\tori\t$%d,\t$%d,\t0xFF\n",rB,rB);
for (i=0,El=0; El<8; i=(i+1)&3,El++) {
vT = i<<3;
vR = (vT+8)&0x1F;
vD = (vT-1)&0x1F;
GenCase(outp,CurTcNo,vT,El,vR,vD,rA,OpA,rB,rR);
CurTcNo++;
}
return 0;
} /* VltGen */