vlog_sel.c 7.06 KB
#include <stdio.h>
#include "vudefs.h"
/**************************************************************************
 * used by vand, vnand, vor, vnor, vxor, vxnor
 *         ===================================
 *
 * Check_Vlog  (tno, Op, rMp, vS, vT, vT_El, vD, vDexp, vTemp)
 **************************************************************************/

char *Templ_vlog_frmt = "( %2d, %s, $26, $v%-d, $v%-d, $v%-d%-s, $v%-d, $v%-d, $v%-d)\n";

vlog(fp)
FILE *fp;
  {
    int         i,j;
    u16         si, ti, di;
    

    for (i=0; i<8; i++) {

        si = (i16) vs[i];
	ti = get_ti(i);

	     if (optab[opindex].enu_name==VAND ) di =  (si & ti);
	else if (optab[opindex].enu_name==VNAND) di = ~(si & ti);
	else if (optab[opindex].enu_name==VOR  ) di =  (si | ti);
	else if (optab[opindex].enu_name==VNOR ) di = ~(si | ti);
	else if (optab[opindex].enu_name==VXOR ) di =  (si ^ ti);
	else if (optab[opindex].enu_name==VXNOR) di = ~(si ^ ti);

        vd[i] = (u16) di;

       }/*for loop*/

       if (data_pntr < (2048 - 100)) 
         {
           /* initidLize data segment starting at data_pntr */
           /* SRC, TRGT, RES, RES_ACCH, RES_ACCM, RES_ACCL */
           for (i=0;i<8;i++) {data[data_pntr++] = vs[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vt[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vd[i];}
	 }
       
	 fprintf(fp,optab[opindex].op_tmplt); 
         fprintf(fp,Templ_vlog_frmt,
		      	test_num, 
		        optab[opindex].name,
		      	regtab[SRC].rnum,
		      	regtab[TRG].rnum,
		      	regtab[TRG].rnum,el_sf,
		      	regtab[DST].rnum,
		      	regtab[DST_EXP].rnum,
		      	regtab[TEMP].rnum
		);  
}/*vlog*/

/**************************************************************************
 * used by vlt, veq, vneq, vge, vmrg
 *         ===========================
 *
 * Check_Vcmp(tno,Op,rMp,vS,vT,vT_El,vD,vDexp,vTemp,inVCO,initVCC,expVCC)
 **************************************************************************/

char *Templ_vcmp_frmt = "( %2d, %s, $26, $v%-d, $v%-d, $v%-d%-s, $v%-d, $v%-d, $v%-d, 0x%4.4X, 0x%4.4X, 0x%4.4X)\n";


vcmp(fp)
FILE *fp;
{
    int         i,j;
    i16         si, ti, di;
    u8		vco_equal[8], vco_carry[8], cond_true;
    u8		init_vcc;


    out_vcc = 0;
    out_vco = 0;

    for (i=0; i<8; i++) {
	vco_carry[i] = (in_vco >> i) & 0x01; 
	vco_equal[i] = (~in_vco >> (i+8)) & 0x01; 
	}

    for (i=0; i<8; i++) {

	cond_true = 0;
        si = (i16) vs[i];
        ti = get_ti(i);


        if (optab[opindex].enu_name==VLT) 
	   cond_true =  (si<ti) || (si==ti && vco_carry[i]);
	else
        if (optab[opindex].enu_name==VEQ) 
	   cond_true =  (si==ti && vco_equal[i]);
	else
        if (optab[opindex].enu_name==VNE) 
	   cond_true =  (si!=ti) || (si==ti && !vco_equal[i]);
	else
        if (optab[opindex].enu_name==VGE) 
	   cond_true =  (si>ti) || (si==ti && (vco_equal[i] || !vco_carry[i]));
	else
        if (optab[opindex].enu_name==VMRG) 
	   cond_true =  (in_vcc >> i) & 0x01;


	vd[i] = (cond_true) ? si : ti;
	out_vcc = out_vcc | (cond_true << i);

       }/*for loop*/

       init_vcc = (optab[opindex].enu_name==VMRG) ? in_vcc : ~out_vcc;

       if (data_pntr < (2048 - 100)) 
         {
           /* initidLize data segment starting at data_pntr */
           /* SRC, TRGT, RES, RES_ACCH, RES_ACCM, RES_ACCL */
           for (i=0;i<8;i++) {data[data_pntr++] = vs[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vt[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vd[i];}
	 }
       
	 fprintf(fp,optab[opindex].op_tmplt); 
         fprintf(fp,Templ_vcmp_frmt,
		      	test_num, 
		        optab[opindex].name,
		      	regtab[SRC].rnum,
		      	regtab[TRG].rnum,
		      	regtab[TRG].rnum,el_sf,
		      	regtab[DST].rnum,
		      	regtab[DST_EXP].rnum,
		      	regtab[TEMP].rnum,
			in_vco,
			init_vcc,
			out_vcc
		);  
}/*vcmp*/

/**************************************************************************
 * used by vch, vcl and vcr
 *         ================
 *
 * Check_Vcl(tno,Op,rMp,vS,vT,vT_El,vD,vDexp,vTemp,inVCO,inVCC,inVCE,expVCO,expVCC,expVCE)
 **************************************************************************/

char *Templ_vcl_frmt = "( %2d, %s, $26, $v%-d, $v%-d, $v%-d%-s, $v%-d, $v%-d, $v%-d, 0x%4.4X, 0x%4.4X, 0x%4.4X,0x%4.4X, 0x%4.4X, 0x%4.4X)\n";

vcl(fp)
FILE *fp;
{
    int         i,j,carry,borrow;
    i16         si, ti;
    i32		di;
    u16	        su, tu;
    u8		ge, le, vce,sn,eq,neq;

    out_vcc = 0;
    out_vco = 0;
    out_vce = 0;

    for (i=0; i<8; i++) {

	le = (in_vcc >>  i   ) & 0x01; 
	ge = (in_vcc >> (i+8)) & 0x01; 
	sn = (in_vco >> i) & 0x01; 
	eq = (~in_vco >> (i+8)) & 0x01; 
	vce = (in_vce >> i) & 0x01;

        if (optab[opindex].enu_name==VCH) { 
          si = (i16) vs[i];
          ti = get_ti(i);

	  sn = ((si^ti) < 0);

	  if (sn) {
	      ge = (ti<0);
	      le = ((si+ti)<=0);
	     vce = ((si+ti)==-1); 
	      eq = ((si+ti)==0) | vce; 

	     vd[i] = (le) ? -ti  : si;
	  }
	  else {
	      le = (ti<0);
	      ge = ((si-ti)>=0);
	      eq = ((si-ti)==0);
	     vce = 0;

	      vd[i] = (ge) ? ti  : si;
	  }
	}/*if (VCH) */

        if (optab[opindex].enu_name==VCL) { 

	  su = (u16) vs[i]; 
	  tu = (u16) get_ti(i);
	 
	  if (sn) {
	     di = su + tu;
	     carry = (di > 65535);

	     if (eq) 
	        le = (!vce & (((di&0xffff)==0) & !carry)) |
	             ( vce & (((di&0xffff)==0) | !carry));

	     vd[i] = (le) ? -tu  : su;
	  }
	  else {
	     di = su - tu;
	     if (eq) 
	        ge = (di>=0);
	     vd[i] = (ge) ? tu  : su;
	  }
	}/*if (VCL) */

	/* VCR always assumes ti >0 */
        if (optab[opindex].enu_name==VCR) {
          si = (i16) vs[i];
          ti = get_ti(i);

	  sn = ((si^ti) < 0);

	  if (sn) {
	      ge = (ti<0);
	      le = ((si+ti+1)<=0);
	     vce = ((si+ti+1)==-1); 
	      eq = ((si+ti+1)==0) | vce; 

	     vd[i] = (le) ? ~ti  : si;
	  }
	  else {
	      le = (ti<0);
	      ge = ((si-ti)>=0);
	      eq = ((si-ti)==0);
	     vce = 0;

	     vd[i] = (ge) ? ti  : si;
	  }
	}/*if (VCR) */

       neq = ~eq & 0x1;
	
       out_vcc = out_vcc | ( ge<<(i+8)) | (le<<i); 
       out_vco = out_vco | (neq<<(i+8)) | (sn<<i); 
       out_vce = out_vce | ( vce<<i); 

       }/*for loop*/

       if (optab[opindex].enu_name==VCR ||  optab[opindex].enu_name==VCL) {
   	out_vco = 0;
   	out_vce = 0;
	} 

       if (optab[opindex].enu_name==VCR || optab[opindex].enu_name==VCH) {
	in_vcc = ~out_vcc;
	in_vco = ~out_vco;
	in_vce = ~out_vce;
	}

       if (data_pntr < (2048 - 100)) 
         {
           /* initidLize data segment starting at data_pntr */
           /* SRC, TRGT, RES, RES_ACCH, RES_ACCM, RES_ACCL */
           for (i=0;i<8;i++) {data[data_pntr++] = vs[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vt[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vd[i];}
	 }
       
	 fprintf(fp,optab[opindex].op_tmplt); 
         fprintf(fp,Templ_vcl_frmt,
		      	test_num, 
		        optab[opindex].name,
		      	regtab[SRC].rnum,
		      	regtab[TRG].rnum,
		      	regtab[TRG].rnum,el_sf,
		      	regtab[DST].rnum,
		      	regtab[DST_EXP].rnum,
		      	regtab[TEMP].rnum,
			in_vco,
			in_vcc,
			in_vce,
			out_vco,
			out_vcc,
			out_vce
		);  
}/*vcl*/