dp_mul.c
2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#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
);
}