Hi,
I'm creating application on ARM STM32F103VE. I have to multiply several
matrix in very short time. I'm thinking about using Fixed Point, to
speed up my calculations. So that I wrote union:
typedef union fxpntu{
int full;
struct fxpnts{
int_fast32_t fraction : 31;
int_fast32_t integer : 1;
} part;
} fxpnt_t;
My Fixed Point representation is Q1.31.
Than, I created multiplying function:
/* Return: c = a * b */
fxpnt_t fxmul(fxpnt_t* a, fxpnt_t* b) {
fxpnt_t c;
_fxpnt_accu64.full = a->full*b->full;
fxreg |= (_fxpnt_accu64.part.H == 0 && (a->full != 0 || b->full !=
0))<<0x05;
fxreg |= FX_UFLOW >> 3;
c.full = _fxpnt_accu64.part.H;
c.full = FX_UFLOW?0x01:_fxpnt_accu64.part.H;
FX_UFLOW_CLEAR;
return c;
}
where _fxpnt_accu64 is global object, to hold result.
I made few tests in CrossWorks and results are weird:
float a = -150.534433;
float b = 0.05323;
c = a*b; // 47 Instructions
c = a+b; // 55 Instructions
c = a-b; // 49 Instructions
c = a/b; // 139 Instructions
ans = fxmul(&fx2, &fx1); // 165 Instructions
I checked my own multiplying function, and
fxreg |= (_fxpnt_accu64.part.H == 0 && (a->full != 0 || b->full !=
0))<<0x05; <-- this line takes 43 Instructions.
Can someone explain, or send any link about creating fixed point
on ARM Cortex M-3, or example code? Maybe I'm doing something wrong,
maybe I don't get point of fixed multiplying..
Thanks for Your feedback.