alu_wwi.c 5.25 KB
/****************************************************************
  WHAT:	RSP TEST GENERATOR for ALU_WWI MACRO TYPE INSTRUCTIONS
  SCCS: @(#)alu_wwi.c	1.1 03 Aug 1994
  FILE:	alu_wwi.c
   WHO:	Project Reality - Evan Y. Wang
   (C):	1994 Silicon Graphics, Inc.
 ****************************************************************/
#include <stdio.h>
#include "software.h"
#include "gen.h"
#include "suregre.h"

#define MAX_TCS	MAX_ALU_WWI_TCS

#define GenCase()						\
    fprintf(outp, Templ, CurTcNo, ip->name, rR,			\
	    HHW(Reg[rR]), LHW(Reg[rR]), rA, LHW(Imm),		\
	    HHW(Res), LHW(Res), HHW(OpA), LHW(OpA), rT)

PRIVATE	char *Templ =
    /* ChkAluWWI(  n,Op,   rR,  RValH,  RValL,   rA,    Imm,   ResH,   ResL,   OpAH,   OpAL,   rT); */
    "\tChkAluWWI(%2d,%s,r%-2d,0x%4.4X,0x%4.4X,r%-2d,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,r%-2d)\n";

PRIVATE int AddWWI(outp, ip)
    FILE *outp;
    I_TABLE *ip;
{
    int i;

    /************************************************************
      Generate input patterns:  (0...010...0 Op 0...011...1)
     ************************************************************/
    for (i = 0; i < 16; i++, CurTcNo++) {
	OpA = 0x00010001 << i;
	Imm = 0xFFFF >> (15-i);
	FILE_SPLIT {
	    Res = ip->proc(OpA,Imm);
	    GenCase();
	    UpdRegTAR();
	}
	UpdRegID();
    }

    for (i = 0; i < 16; i++, CurTcNo++) {	/* reverse direc*/
	OpA = 0x00000001 << i;
	Imm = 0xFFFF >> (15-i);
	FILE_SPLIT {
	    Res = ip->proc(OpA,Imm);
	    GenCase();
	    UpdRegTAR();
	}
	UpdRegID();
    }

    for (i = 0; i < 16; i++, CurTcNo++) {
	/* Update all variables for next test case */
	OpA = 0x10001000 << i;
	Imm = (0xFFFF >> (15-i)) | 0x8000;
	FILE_SPLIT {
	    Res = ip->proc(OpA,Imm);
	    GenCase();
	    UpdRegTAR();
	}
	UpdRegID();
    }

    /************************************************************
      Generate input patterns:  (1110...0111 Op 0011...1100)
     ************************************************************/
    OpA = 0x80000001;
    Imm = 0xFFFF;
    FILE_SPLIT {
	Res = ip->proc(OpA,Imm);
	GenCase();
	UpdRegTAR();
    }
    UpdRegID();
    CurTcNo++;

    for (i = 1; i < 16; i++, CurTcNo++) {
	/* Update all variables for test case */
	OpA |= (1<<i) | (0x80000000>>i);
	Imm = ((u16) 0xFFFF << i >> i) | 1;
	FILE_SPLIT {
	    Res = ip->proc(OpA,Imm);
	    GenCase();
	    UpdRegTAR();
	}
	UpdRegID();
    }

    /************************************************************
      Generate input patterns:  (1110...0111 Op 0010...0100)
     ************************************************************/
    for (i = 15; i >= 0; i--, CurTcNo++) {
	OpA = (0xFFFF >> (15-i)) | (0xFFFF0000 << (15-i));
	Imm = (1<<i) | (0x8000>>i) | 1;
	FILE_SPLIT {
	    Res = ip->proc(OpA,Imm);
	    GenCase();
	    UpdRegTAR();
	}
	UpdRegID();
    }

    /************************************************************
      Generate some special patterns.
     ************************************************************/
    {
	PRIVATE u32 Aarray[] = { 0, 0x15555555, 0xAAAAAAAA, 0xFFFFFFFF };
	PRIVATE s16 Barray[] = { 0, 0x5555, 0x2AAA, 0xFFFF };

	Imm = 0x5555;
	for (i=0; i<4; i++, CurTcNo++) {
	    OpA = Aarray[i];
	    FILE_SPLIT {
		Res = ip->proc(OpA,Imm);
		GenCase();
		UpdRegTAR();
	    }
	    UpdRegID();
	}
    
	OpA = 0xAAAAAAAA;
	for (i=0; i<4; i++, CurTcNo++) {
	    Imm = Barray[i];
	    FILE_SPLIT {
		Res = ip->proc(OpA,Imm);
		GenCase();
		UpdRegTAR();
	    }
	    UpdRegID();
	}
    }
    return 0;

}   /* AddWWI */

PRIVATE int LogWWI(outp, ip)
    FILE *outp;
    I_TABLE *ip;
{
    /************************************************************
      Generate input patterns:  (0..010..010 Op 0xZZZZZZZZ)
      where Z = { 0, 1, ... 15 }
     ************************************************************/
    OpA = 0;
    for (CntA = 0; CntA < 4; CntA++) {
	for (CntI=0; CntI<6; CntI++, CurTcNo++) {
	    Imm = 0x1041 << CntI;
	    FILE_SPLIT {
		Res = ip->proc(OpA,LHW(Imm));
		GenCase();
		UpdRegTAR();
	    }
	    UpdRegID();
	}
	OpA |= 0x11111111 << CntA;
    }

    for (CntA = 0; CntA < 4; CntA++) {
	for (CntI=0; CntI<6; CntI++, CurTcNo++) {
	    Imm = 0x1041 << CntI;
	    FILE_SPLIT {
		Res = ip->proc(OpA,LHW(Imm));
		GenCase();
		UpdRegTAR();
	    }
	    UpdRegID();
	}
	OpA &= ~(0x11111111 << CntA);
    }

    return 0;

}   /* LogWWI */

PRIVATE int ShfWWI(outp, ip)
    FILE *outp;
    I_TABLE *ip;
{
    PRIVATE u32 patterns[] = {
	0x01800180, 0x02400240, 0x04200420, 0x08100810,
	0x10081008, 0x20042004, 0x40024002, 0x80018001	};

    Imm = 0;
    for (CntA=0; CntA<50; CntA++, CurTcNo++) {
	OpA = patterns[CntA&7];
	FILE_SPLIT {
	    Res = ip->proc(OpA,Imm);
	    GenCase();
	    UpdRegTAR();
	}
	UpdRegID();
	Imm = (Imm+1)&0x1F;
    }

    return 0;

}   /* ShfWWI */

PRIVATE	int SetWWI(outp, ip)
    FILE *outp;
    I_TABLE *ip;
{
    return AddWWI(outp, ip);
}   /* SetWWI */

int AluWWIGen(outp, ip)
    FILE *outp;
    I_TABLE *ip;
{
    /* Generate default case - both operands zero */
    FILE_SPLIT {
	Res = ip->proc(OpA,Imm);
	GenCase();
	UpdRegTAR();
    }
    CurTcNo++;
    UpdRegID();

    switch (ip->vec) {
      case ADD_VEC:	return AddWWI(outp, ip);	break;
      case LOG_VEC:	return LogWWI(outp, ip);	break;
      case SHF_VEC:	return ShfWWI(outp, ip);	break;
      case SET_VEC:	return SetWWI(outp, ip);	break;
      default:		return 0;			break;
    }

}   /* AluWWIGen */