Hello all!
I am new to ARM community and this is my first question here. I work on embedded systems where we use Cortex-M4 based MCUs (concretely STM32F3 series). I would like to ask, if there is a DSP instruction which would calculate x*x + y*y.
x and y represent sine and cosine values (signed integers, 16-bit variables are sufficient). I would like to calculate a square of amplitude (x*x + y*y).
Thanks in advance.
Hi.
I would have another question regarding these DSP instructions.
What is their real advantage? I mean, if I calculate x*x + y*y using SMUAD instruction, I first had to format the 32-bit register with (x << 16) | y. Now, I have three instructions (<<, | and SMUAD). If I do a simple calculation with two multiplication and one addition (x*x + y*y), I also have three instructions. I know that I will not gain a huge amount of time with these few instructions, but I am curious when they become preferred over normal calculation. In my case there is no advantage of using it at all.
Thanks
Hello Matic,
These instructions are kind of SIMD extensions possible with existing ARM register files.
Consider the scenario where you have a lot of x and y co-ordinates in memory where it is already in the packed form. In that case you just need to load them as 32 bit values and perform these computations.
Even in scenarios where x and y values are calculated and then performed (x*x + y*y), other SIMD instructions can be used to get the x and y results in packed format.
Or if you localize the problem, then yes we do have the packing overhead and it can be huge such that there is no advantage in using those special instructions.
Regards, Prasad
View all questions in Cortex-M / M-Profile forum