Technical discussions related to Analog Devices DSPs (including Blackfin, TigerSHARC, SHARC and ADSP-21xx DSPs).
I need to multiply two fixed-point numbers (32b in length, signed Q1.30), and when I get 64b number I need its upper part, in order to create signed Q1.30 again out of it. Problem is that when you multiply two 4B number you get 4B number again, so I casted one of multiplicator to 8B, and then shifted the result left and right to get the proper form: int a, b, int_res; long long int result = (long long int) a * b; result <<= 2; intres = result >> 16; /*sizeof(long long int) = 8; sizeof(int) = 4*/ This works great, with only problem the slowness. So, my question is: Is there a way on BF561 to multiply ints, and to get only upper (meaning where MSBs are, 32b out of 64b) part of the result, without casting and adjusting it? I looked up for the solution in the "BF Instruction Set Reference" pdf I've found on the net, but multiply functions work only with 32b result, nowhere is 64b result mentioned. ------------------------------------
Hi, See EE-186 at Analog Devices website. It should answer your questions. Cheers, George Kadziolka Kaztek Systems <http://www.kaztek.com/> www.kaztek.com _____ From: a...@yahoogroups.com [mailto:a...@yahoogroups.com] On Behalf Of Nemanja Djuric Sent: Friday, April 18, 2008 6:35 AM To: ADSP Subject: [adsp] BF561 Multiplication : 32bx32b (VDSP++) I need to multiply two fixed-point numbers (32b in length, signed Q1.30), and when I get 64b number I need its upper part, in order to create signed Q1.30 again out of it. Problem is that when you multiply two 4B number you get 4B number again, so I casted one of multiplicator to 8B, and then shifted the result left and right to get the proper form: int a, b, int_res; long long int result = (long long int) a * b; result <<= 2; intres = result >> 16; /*sizeof(long long int) = 8; sizeof(int) = 4*/ This works great, with only problem the slowness. So, my question is: Is there a way on BF561 to multiply ints, and to get only upper (meaning where MSBs are, 32b out of 64b) part of the result, without casting and adjusting it? I looked up for the solution in the "BF Instruction Set Reference" pdf I've found on the net, but multiply functions work only with 32b result, nowhere is 64b result mentioned.
I've found even better way of multiplying them, if someone's interested. Include fract.h, and there you have function mult_fr32x32, something like that, it's really great, does all the work for you, and it's optimized even. Problem is that fract32 type is 1 signed bit, and 31 fractional, but a little bit of scaling can do the job. ------------------------------------