dp_mul.c 2.58 KB
#include <stdio.h>
#include <vudefs.h>

char *Templ_dpmul_frmt = "( %2d, $26, $v%-d, $v%-d, $v%-d, $v%-d, $v%-d, $v%-d, $v%-d, $v%-d, $v%-d, $v%-d, $v%-d, $v%-d,$v%-d, $v%-d, $v%-d,0x%0x)\n";

dp_mul(fp)
FILE *fp;
  {
    int         i,j;
    i64         result,clamp_mask;
    i32 	vs,vt;
    u8 		low_mask;

    clamp_mask = 0xffffffff80000000;

    low_mask = 0xff;
    for (i=0; i<8; i++)
      {
      vsh[i] = (dp_vs[i]>>16) & 0xffff;
      vsl[i] = (dp_vs[i]    ) & 0xffff;
      vth[i] = (dp_vt[i]>>16) & 0xffff;
      vtl[i] = (dp_vt[i]    ) & 0xffff;

      vs = (i32) dp_vs[i];
      vt = (i32) dp_vt[i];

      result = (i64) ((i64)vs * (i64)vt);
      result = (i64) (result>>16);

      vdl[i] = (u16) (result)&0xffff;
      vdh[i] = (u16) (result>>16)&0xffff;
     
      if (result>0 && (result & clamp_mask)) {
	  vdh[i] = 0x7fff;
	  low_mask &= ~(0x1<<i);
	 }
      else
      if (result<0 && (~result & clamp_mask)) {
	  vdh[i] = 0x8000;
	  low_mask &= ~(0x1<<i);
	 }

      vacc[i] = result & 0xffffffffffff;
      dp_res[i] = result;

      }

       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++] = vsh[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vsl[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vth[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vtl[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vdh[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vdl[i];}
           for (i=0;i<8;i++) data[data_pntr++] = (u16)(vacc[i]    )&0xffff;
           for (i=0;i<8;i++) data[data_pntr++] = (u16)(vacc[i]>>16)&0xffff;
           for (i=0;i<8;i++) data[data_pntr++] = (u16)(vacc[i]>>32)&0xffff;
         }

         fprintf(fp,optab[opindex].op_tmplt);
         fprintf(fp,Templ_dpmul_frmt,
                        test_num,
                        regtab[VSH].rnum,
                        regtab[VSL].rnum,
                        regtab[VTH].rnum,
                        regtab[VTL].rnum,
                        regtab[VDH].rnum,
                        regtab[VDL].rnum,
                        regtab[VDH_Exp].rnum,
                        regtab[VDL_Exp].rnum,
                        regtab[TEMP].rnum,
                        regtab[ACCL].rnum,
                        regtab[ACCM].rnum,
                        regtab[ACCH].rnum,
                        regtab[ACCL_EXP].rnum,
                        regtab[ACCM_EXP].rnum,
                        regtab[ACCH_EXP].rnum,
			low_mask
                );

  }