bpmult.c 3.48 KB
/************************************************************************
  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/10/29 08:07:06 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 */