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.
BF561 Multiplication : 32bx32b (VDSP++)
Started by ●April 18, 2008
Reply by ●April 20, 20082008-04-20
Hi,
See EE-186 at Analog Devices website. It should answer your questions.
Cheers,
George Kadziolka
Kaztek Systems
www.kaztek.com
_____
From: a... [mailto:a...] 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.
See EE-186 at Analog Devices website. It should answer your questions.
Cheers,
George Kadziolka
Kaztek Systems
www.kaztek.com
_____
From: a... [mailto:a...] 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.
Reply by ●April 22, 20082008-04-22
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.
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.