vlt.c 3.05 KB
/****************************************************************
  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 */