bpmult.c
3.48 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
/************************************************************************
WHAT: RSP SCALAR UNIT BYPASS VERIFICATION MULTI-BYPASS TEST GENERATOR
This is really a hand generated code with a variable
SCCS: %W% %G%
PTLS: $Id: bpmult.c,v 1.1.1.1 2002/05/02 03:29:12 blythe Exp $
ENGR: Evan Y. Wang
PROJ: Project Reality
(CR): 1994 Silicon Graphics, Inc.
************************************************************************/
#include <stdio.h>
#include "software.h"
#include "bpgen.h"
bpmult(fcnt,tno)
int fcnt; /* File number */
int tno; /* Test number */
{
int i;
sprintf(cTFName,"bpmult.s");
if ((fhTFile = fopen(cTFName, "w")) == NULL) {
fprintf(stderr, "ERROR:\tOpening file %s failed.\n", cTFName);
fprintf(stderr, "\tExiting...\n");
exit(1);
}
Header(fhTFile, fcnt);
if (fhSFile != NULL) {
fprintf(fhSFile, "load bpmult.bin 0x%8.8lX\n",IMEM_BASE|0x04001000);
fprintf(fhSFile, "load bpmult.dat 0x%8.8lX\n",DMEM_BASE);
fprintf(fhSFile, "dep PC 0\nsilent\nrun\nreg 1\n");
}
/* Initialize SU register file */
for (i=1; i<32; i++) {
Reg[i]=Rand32();
fprintf(fhTFile,"\tlui\t$%d,\t0x%4.4X\n",i,(Reg[i]>>16));
fprintf(fhTFile,"\tori\t$%d,\t0x%4.4X\n",i,(Reg[i]&0xFFFF));
}
/* Generate tests */
for (Space=3; Space>=0; Space--) {
fprintf(fhTFile,"\n");
fprintf(fhTFile,"\t/* TEST #%2.2d ",tno++);
fprintf(fhTFile,"*********************************************/\n");
/* Initialize registers */
fprintf(fhTFile,"\t/* Initialize test registers */\n");
Reg[DestRegID] = Rand32();
Reg[Src1RegID] = Rand32();
Reg[Src2RegID] = Rand32();
Reg[Src3RegID] = Rand32();
Reg[DumpRegID] = Rand32();
fprintf(fhTFile,"\tlui\t$%d,\t0x%4.4X\n",DestRegID,(Reg[DestRegID]>>16));
fprintf(fhTFile,"\tori\t$%d,\t0x%4.4X\n",DestRegID,(Reg[DestRegID]&0xFFFF));
fprintf(fhTFile,"\tlui\t$%d,\t0x%4.4X\n",Src1RegID,(Reg[Src1RegID]>>16));
fprintf(fhTFile,"\tori\t$%d,\t0x%4.4X\n",Src1RegID,(Reg[Src1RegID]&0xFFFF));
fprintf(fhTFile,"\tlui\t$%d,\t0x%4.4X\n",Src2RegID,(Reg[Src2RegID]>>16));
fprintf(fhTFile,"\tori\t$%d,\t0x%4.4X\n",Src2RegID,(Reg[Src2RegID]&0xFFFF));
fprintf(fhTFile,"\tlui\t$%d,\t0x%4.4X\n",Src3RegID,(Reg[Src3RegID]>>16));
fprintf(fhTFile,"\tori\t$%d,\t0x%4.4X\n",Src3RegID,(Reg[Src3RegID]&0xFFFF));
fprintf(fhTFile,"\tlui\t$%d,\t0x%4.4X\n",DumpRegID,(Reg[DumpRegID]>>16));
fprintf(fhTFile,"\tori\t$%d,\t0x%4.4X\n",DumpRegID,(Reg[DumpRegID]&0xFFFF));
fprintf(fhTFile,"\n");
fprintf(fhTFile,"\t/* Test */\n");
fprintf(fhTFile,"\txor\t$%d,\t$%d,\t$%d\n",DestRegID,Src3RegID,DumpRegID);
fprintf(fhTFile,"\txor\t$%d,\t$%d,\t$%d\n",DestRegID,Src1RegID,Src2RegID);
fprintf(fhTFile,"\txor\t$%d,\t$%d,\t$%d\n",DestRegID,Src2RegID,Src3RegID);
for (i=0; i<Space; i++) fprintf(fhTFile,"\tnop\n");
fprintf(fhTFile,"\txori\t$%d,\t$%d,\t0xFFFF\n",DumpRegID,DestRegID);
fprintf(fhTFile,"\n");
fprintf(fhTFile,"\t/* Check result */\n");
fprintf(fhTFile,"\tnop\n");
fprintf(fhTFile,"\tnop\n");
fprintf(fhTFile,"\tnop\n");
Reg[Src1RegID] = Reg[Src2RegID] ^ Reg[Src3RegID] ^ 0xFFFF;
fprintf(fhTFile,"\tlui\t$%d,\t0x%4.4X\n",Src1RegID,(Reg[Src1RegID]>>16));
fprintf(fhTFile,"\tori\t$%d,\t0x%4.4X\n",Src1RegID,(Reg[Src1RegID]&0xFFFF));
fprintf(fhTFile,"\tbne\t$%d,\t$%d,\tFail\n",Src1RegID,DumpRegID);
fprintf(fhTFile,"\tnop\n");
DestRegID = ((DestRegID+1)%31)+1;
Src1RegID = ((Src1RegID+1)%31)+1;
Src2RegID = ((Src2RegID+1)%31)+1;
Src3RegID = ((Src3RegID+1)%31)+1;
DumpRegID = ((DumpRegID+1)%31)+1;
}
Tail(fhTFile);
fclose(fhTFile);
} /* bpmult */