Part Number: TMS320F28377D
Tool/software: Code Composer Studio
Hi,
I want to make a time-analysis for math operation between CPU and CLA. I want to use exponential function for this analysis.
I can successfully run exponantial function on CLA, it takes around 67 SYSCLK cycles. However when I try to use exp function in standard maht libray on CPU (not CLA) it throws ILLEGAL_ISR.
The line where this exception occurs in file e_expf.c on line 101. I copy whole function below.
My code is simple:
float NumDen; double temp; NumDen = -1.56f; temp = exp(NumDen); // Exception occurs
float expf(float x) function in e_expf.c
float
expf(float x)
{
float y,hi=0.0,lo=0.0,c,t,twopk;
int32_t k=0,xsb;
uint32_t hx;
GET_FLOAT_WORD(hx,x);
xsb = (hx>>31)&1; /* sign bit of x */
hx &= 0x7fffffff; /* high word of |x| */
/* filter out non-finite argument */
if(hx >= 0x42b17218) { /* if |x|>=88.721... */
if(hx>0x7f800000)
return x+x; /* NaN */
if(hx==0x7f800000)
return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */
if(x > o_threshold)
{
__raise_overflow();
return INFINITY;
}
if(x < u_threshold)
{
__raise_underflow();
return 0;
}
}
/* argument reduction */
if(hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */
if(hx < 0x3F851592) { /* and |x| < 1.5 ln2 */
hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
} else {
k = invln2*x+halF[xsb];
t = k;
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
STRICT_ASSIGN(float, x, hi - lo);
}
else if(hx < 0x39000000) { /* when |x|<2**-14 */
if(huge+x>one) return one+x;/* trigger inexact */
}
else k = 0;
/* x is now in primary range */
t = x*x;
if(k >= -125)
SET_FLOAT_WORD(twopk,0x3f800000+(k<<23));
else
SET_FLOAT_WORD(twopk,0x3f800000+((k+100)<<23));
c = x - t*(P1+t*P2);
if(k==0) return one-((x*c)/(c-(float)2.0)-x);
else y = one-((lo-(x*c)/((float)2.0-c))-hi);
if(k >= -125) {
if(k==128) return y*2.0F*0x1p127F; // LINE 101: ERROR OCCURS HERE
return y*twopk;
} else {
return y*twopk*twom100;
}
}
I suspect some overflow? How can I run it succesfully?
Thanks and merry christmas.