From: usha g. <ush...@gm...> - 2010-07-26 12:23:37
|
Hi All, I have been investigating newlib's libm and floating point support in AVR32 .Here is the information that i have got so far. I would like to discuss on implementation of libm for avr32-libc. ** *AVR32 Floating point support* Three revisions of the AVR32UC CPU currently exist: • Revision 1 implementing revision 1 of the AVR32 architecture. • Revision 2 implementing revision 2 of the AVR32 architecture, and with a faster divider. • Revision 3 implementing revision 3 of the AVR32 architecture, and with optional floating-point hardware. *Floating-Point Hardware in AVR32UC* -AVR32UC optionally supports Floating-Point Hardware implemented as coprocessor instructions.(coprocessor 0) -The CONFIG0 system register F bit indicates if floating-point hardware is present on a specific AVR32 device. -Floating-point compare updates the flags in the AVR32 Status Register, so that the regular AVR32 branch instructions can be used directly after a floatingpoint compare. -The floating-point hardware consists of a fused multiply-accumulate unit. - Hardware is also provided to convert between integer and floating-point, - to compare floating-point values - and to provide initial approximations for reciprocal and reciprocal square root -The round-to-nearest, ties to even rounding mode is used for all instructions except float-to-integer conversions. Float-to-integer conversions use the round-to-zero mode. -The hardware supports denormal numbers. -Signalling NaN are not provided, all NaN are non-signalling (quiet). NaNs are not propagated, the default quiet NaN is always returned (0x7FC00000). -No floating-point exceptions are generated *Floating point Operations* -no special floating-point data transfer instructions are required *NOTE:* Section 4.2 and 4.3 of AVR32UC Technical Reference Manual can be looked into for instruction set and compare and check operations provided by AVR32UC *AVR32AP *doest not have an fpu implemented * * *Standard Math library routines* Trigonometric functions: cos Compute cosine (function) sin Compute sine (function) tan Compute tangent (function) acos Compute arc cosine (function) asin Compute arc sine (function) atan Compute arc tangent (function) atan2 Compute arc tangent with two parameters (function) Hyperbolic functions: cosh Compute hyperbolic cosine (function) sinh Compute hyperbolic sine (function) tanh Compute hyperbolic tangent (function) Exponential and logarithmic functions: exp Compute exponential function (function) frexp Get significand and exponent (function) ldexp Generate number from significand and exponent (function) log Compute natural logarithm (function) log10 Compute common logarithm (function) modf Break into fractional and integral parts (function) Power functions pow Raise to power (function) sqrt Compute square root (function) Rounding, absolute value and remainder functions: ceil Round up value (function) fabs Compute absolute value (function) floor Round down value (function) fmod Compute remainder of division (function) * * *Newlib’s libm* * * There are four different versions of the math library routines: IEEE, POSIX, X/Open, or SVID. The version may be selected at runtime by setting the global variable {_LIB_VERSION}, defined in {math.h}. It may be set to one of the following constants defined in {math.h}: {_IEEE_}, {_POSIX_}, {_XOPEN_}, or {_SVID_}. The versions of the library differ only in how errors are handled. Default version is X/Open. *Standard Math library routines in Newlib* The list below gives the functions present in different directories. Two directories namely math/ and mathfp/ has different implementation for the same functions. The function names are listed along with the directory names. *cos() math/* *k_cos.c- _kernel_cos()* – * *The range is [-pi/4,pi/4]; function returning double *kf_cos.c- _kernel_cosf()* – * *The range is [-pi/4,pi/4] ;function returning float *s_cos.c- cos()* – * *The range is [-pi,pi] *sf_cos.c- cosf()* – * *The range is [-pi,pi] *mathfp/* *s_cos.c- cos()* –* *It calls sine(x,1) which is declared in zmath.h. *sf_cos.c- cosf()* – calls sinef(x,1) *sin()* *math/* *k_sin.c- _kernel_sin()* – * *The range is [-pi/4,pi/4]; function returning double *kf_sin.c- _kernel_sinf()* – * *The range is [-pi/4,pi/4] ;function returning float *s_sin.c- sin()* – * *The range is [-pi,pi] *sf_sin.c- sinf()* – * *The range is [-pi,pi] *mathfp/* *s_sin.c- sin()* –* *It calls sine(x,0) which is declared in zmath.h. *sf_sin.c- sinf()* – calls sinef(x,0) *tan()* *math/* *k_tan.c- _kernel_tan()* – * *takes 3 arguments. The range is [-pi/4,pi/4]; function returning double *kf_tan.c- _kernel_tanf()* – * *The range is [-pi/4,pi/4] ;function returning float *s_tan.c- tan()* – * *The range is [-pi,pi] *sf_tan.c- tanf()* – * *The range is [-pi,pi] *mathfp/* *s_tan.c- tan()* *sf_tan.c- tanf()* *acos()* *math/* *e_acos.c- __ieee754_acos()* *ef_acos.c- __ieee754_acosf()* *w_acos.c- acos()* *wf_acos.c- acosf()* *mathfp/* *s_acos.c- acos()* –* *It calls asine(x,1) which is declared in zmath.h. *sf_acos.c- acosf()* – calls asinef(x,1) * * *asin()* *math/* *e_asin.c- __ieee754_asin()* *ef_asin.c- __ieee754_asinf()* *w_asin.c- asin()* *wf_asin.c- asinf()* *mathfp/* *s_asin.c- asin()* –* *It calls asine(x,0) which is declared in zmath.h. *sf_asin.c- asinf()* – calls asinef(x,0) * * *atan()* *math/* *s_atan.c- atan()* *sf_atan.c- atanf()* *mathfp/* *s_atan.c- atan()- *calls atangent(x,0,0,0) *sf_atan.c- atanf()* - calls atangentf(x,0,0,0) *atan2()* *math/* *e_atan2.c- __ieee754_atan2()* *ef_atan2.c- __ieee754_atan2f()* *w_atan2.c- atan2()* *wf_atan2.c- atan2f()* *mathfp/* *s_atan2.c- atan2()* –* *It calls atangent (0.0, v, u, 1) which is declared in zmath.h. *sf_atan2.c- atan2f()* – calls atangentf(0.0, v, u, 1) *cosh()* *math/* *e_cosh.c- __ieee754_cosh()* *ef_cosh.c- __ieee754_coshf()* *w_cosh.c- cosh()* *wf_cosh.c- coshf()* *mathfp/* *s_cosh.c- cosh()* –* *It calls sineh ((float) x, 1) which is declared in zmath.h. *sf_cosh.c- coshf()* – calls sinehf ((float) x, 1) *sinh()* *math/* *e_sinh.c- __ieee754_sinh()* *ef_sinh.c- __ieee754_sinhf()* *w_sinh.c- sinh()* *wf_sinh.c- sinhf()* *mathfp/* *s_sinh.c- sinh()* –* *It calls sineh ((float) x) which is declared in zmath.h. *sf_sinh.c- sinhf()* – calls sinehf ((float) x) *tanh()* *math/* *s_tanh.c- tanh()* *sf_tanh.c- tanhf()* *mathfp/* *s_tanh.c- tanh()* *sf_tanh.c- tanhf()* *exp()* *math/* *e_exp.c- __ieee754_exp()* *ef_exp.c- __ieee754_expf()* *w_exp.c- exp()* *wf_exp.c- expf()* *w_exp2.c- exp2()- *return pow(2,x) *wf_exp2.c- exp2f()* *mathfp/* *s_exp.c- exp()* *sf_exp.c- expf()* *s_exp2.c- exp2()* *sf_exp2.c- exp2f()* *frexp()* *math/* *s_frexp.c- frexp()* *sf_frexp.c- frexpf()* *mathfp/* *s_frexp.c- frexp()* *sf_frexp.c- frexpf()* *ldexp()* *math/* *s_ldexp.c- ldexp()* *sf_ldexp.c- ldexpf()* *mathfp/* *s_ldexp.c- ldexp()* *sf_ldexp.c- ldexpf()* *log()* *math/* *e_log.c- __ieee754_log()* *ef_log.c- __ieee754_logf()* *w_log.c- log()* *wf_log.c- logf()* *mathfp/* *s_log.c- log()* *sf_log.c- logf()* * * *log10()* *math/* *e_log10.c- __ieee754_log10()* *ef_log10.c- __ieee754_log10f()* *w_log10.c- log10()* *wf_log10.c- log10f()* *mathfp/* *s_log10.c- log10()* *sf_log10.c- log10f()* *modf()* *commom/* *s_modf.c* *sf_modf.c* * * *pow()* *math/* *e_pow.c- __ieee754_pow()* *ef_pow.c- __ieee754_powf()* *w_pow.c- pow()* *wf_pow.c- powf()* *mathfp/* *s_pow.c- pow()* *sf_pow.c- powf()* * * *sqrt()* *math/* *e_sqrt.c- __ieee754_sqrt()* *ef_sqrt.c- __ieee754_sqrtf()* *w_sqrt.c- sqrt()* *wf_sqrt.c- sqrtf()* *mathfp/* *s_sqrt.c- sqrt()* *sf_sqrt.c- sqrtf()* * * *ceil()* *math/* *s_ceil.c- ceil()* *sf_ceil.c- ceilf()* * * *mathfp/* *s_ceil.c- ceil()* *sf_ceil.c- ceilf()* * * *floor()* *math/* *s_floor.c- floor()* *sf_floor.c- floorf()* *mathfp/* *s_floor.c- floor()* *sf_floor.c- floorf()* * * *fabs()* *math/* *s_fabs.c- fabs()* *sf_fabs.c- fabsf()* *mathfp/* *s_fabs.c- fabs()* *sf_fabs.c- fabsf()* *fmod()* *math/* *e_fmod.c- __ieee754_fmod()* *ef_fmod.c- __ieee754_fmodf()* *w_fmod.c- fmod()* *wf_fmod.c- fmodf()* *mathfp/* *s_fmod.c- fmod()* *sf_fmod.c- fmodf()* *List of non-standard functions in newlib* Other functions include 1) Bessel functions – jN, jNf, yN, yNf 2) cbrt, cbrtf 3) copysign, copysignf 4)erf, erff, erfc, erfcf – error functions 5)expm1, expm1f – exponential minus 1 6)gamma, gammaf, lgamma, lgammaf, gamma_r 7)hypot, hypotf 8)ilogb, ilogbf – get exponent of floating point number 9)infinity, infinityf- representation of infinity. 10) isnan, isnanf, isinf, isinff, finite,finitef 11)log1p, log1pf- log of 1+x 12)matherr – modifiable math error handler 13) nan, nanf 14)nextafter, naxtafterf - get next number 15)remainder, remainderf 16)scalbn, scalbnf –scale by power of 2 *Avr-libc* *List of non-standard functions in avr-libc* 1)isnan 2)isinf 3)square 4)copysign 5)fdim – returns max of (x-y,0) 6)fma – floating point multiply-add ((x*y)+z) operation 7)fmax 8)fmin 9)signbit 10)trunc 11)isfinite 12)hypot 13)round 14)lround 15)lrint -- Thanks and Regards Usha Gupta |