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.
danrok wrote: > Thanks for Your feedback. Could you provide an example of what you are actually compiling? The fragments above do not make sense. For instance there is no structure with member H, fxreg is not defined, FX_UFLOW and FX_UFLOW_CLEAR are unknown macros. Please test the example before posting otherwise you are wasting all of our times including your own. -- Marcus http://www.doulos.com/arm/
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.