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
Hi matic,
You can use PKHBT and PKHTB to format the registers, see § 3.8. Packing and unpacking instructions of Cortex-M4 Devices Generic User Guide Revision r0p1. Now, tabulate all the instructions in the two methods (PKHBT/PKHTB, SMUAD versus multiply, add), calculate and compare the total number of cycles incurred to accomplish the mathematical expression. I hope you can post the result; I'm also curious but I have to log out already.
Regards,
Goodwin
View all questions in Cortex-M / M-Profile forum