DSPRelated.com
Forums

Number of Cycles taken by Fixed Point program

Started by bsdap November 24, 2005
Hi All,

I wrote a code in floating point and then converted it to fixed point(32
bit). The final answers given by both the codes are found to be same. Then
I tried executing both these codes on Visual DSP++ 4.0 simulator to check
the reduction in cycles by Fixed point code. But to my surprise the fixed
point code took more cycles than the floating point code. I found that the
elementry opeations like multiplication, division etc took more cycles than
the corresponding floating point operations. 

I wonder why this should happen??

Can anyone please help me with this...

Thank you very much in Anticipation.

b.s.d.




bsdap wrote:
> Hi All, > > I wrote a code in floating point and then converted it to fixed point(32 > bit). The final answers given by both the codes are found to be same. Then > I tried executing both these codes on Visual DSP++ 4.0 simulator to check > the reduction in cycles by Fixed point code. But to my surprise the fixed > point code took more cycles than the floating point code. I found that the > elementry opeations like multiplication, division etc took more cycles than > the corresponding floating point operations. > > I wonder why this should happen?? > > Can anyone please help me with this... > > Thank you very much in Anticipation. > > b.s.d.
Ask the designer of the hardware. I can't explain the behavior because you give no indication of the processor type. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
A floating point DSP sometimes has floating point multipliers but not
fixed point.

Then, a compiler will sometimes convert fixed point to floating point,
use the floating point multiplier, and convert back to fixed point.
This takes longer.

As Jerry says, it is probably a question of what hardware there is, and
what the compiler tries to do with it.

Chris
======================
Chris Bore
BORES Signal Processing
www.bores.com

chris_bore@yahoo.co.uk wrote:
> A floating point DSP sometimes has floating point multipliers but not > fixed point. > > Then, a compiler will sometimes convert fixed point to floating point, > use the floating point multiplier, and convert back to fixed point. > This takes longer. > > As Jerry says, it is probably a question of what hardware there is, and > what the compiler tries to do with it. > > Chris > ====================== > Chris Bore > BORES Signal Processing > www.bores.com
Does any one know any other way to evaluate the performance of the Fixed point code other than the DSP simulator. bs.
>A floating point DSP sometimes has floating point multipliers but not >fixed point. > >Then, a compiler will sometimes convert fixed point to floating point, >use the floating point multiplier, and convert back to fixed point. >This takes longer. > >As Jerry says, it is probably a question of what hardware there is, and >what the compiler tries to do with it. > >Chris >====================== >Chris Bore >BORES Signal Processing >www.bores.com > >
Hi, Thank you very much for the replies. I am extremely sorry I forgot to give the details. Actually I am not using any hardware but simulating the code for Blackfin processor (BF535) which is supposed to be a fixed point processor in Visual DSP++ and that is why I am more concerned about the above query. The fixed point functions that I have used are all from the standard fixed point library (dsp_fx). Now can you please help me out. B.S.D.
bsdap wrote:
>>A floating point DSP sometimes has floating point multipliers but not >>fixed point. >> >>Then, a compiler will sometimes convert fixed point to floating point, >>use the floating point multiplier, and convert back to fixed point. >>This takes longer. >> >>As Jerry says, it is probably a question of what hardware there is, and >>what the compiler tries to do with it. >> >>Chris >>====================== >>Chris Bore >>BORES Signal Processing >>www.bores.com >> >> > > > Hi, > Thank you very much for the replies. > I am extremely sorry I forgot to give the details. > Actually I am not using any hardware but simulating the code for Blackfin > processor (BF535) which is supposed to be a fixed point processor in > Visual DSP++ and that is why I am more concerned about the above query. > The fixed point functions that I have used are all from the standard fixed > point library (dsp_fx). > Now can you please help me out. > B.S.D.
On a Blackfin, fixed-point math will be much faster that floating point. Software floating point is very slow compared to single-cycle fixed point, and addition takes longer than multiplication. Is your simulator timing related to real hardware? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Any DSP can do a multiply and accumulate within a single cycle. A
floating point DSP can multiply and accumulate 2 floating point values
within one cycle. A fixed point 16 bit DSP does the same thing but with
two 16 bit values. To perform a multiply and accumulate of two floating
point values with a 16 bit DSP logically takes more time than with a
floating point DSP. Even a 32 bit DSP will take more time to do the
same operation.

jmoes@chello.nl wrote:
> ... A > floating point DSP can multiply and accumulate 2 floating point values > within one cycle. A fixed point 16 bit DSP does the same thing but with > two 16 bit values.
I assume you have particular processors in mind. Certainly not all have the data-bus and memory arrangements to fetch four operands in the same cycle. > To perform a multiply and accumulate of two floating
> point values with a 16 bit DSP logically takes more time than with a > floating point DSP. Even a 32 bit DSP will take more time to do the > same operation.
Logically but not in fact? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
I don't understand how you are comparing with floating point
operations, since floating point ops won't be supported by your
processor.

For most DSPs multiplication, addition etc. should take only 1 cycle if
you are working within the supported precision for data. So you need to
take care of the precision that is supported for the operations. e.g.
if 16-bit multiplication instruction is supported you can't do
32-multiplication in single cycle. Division would usually take many
more since most fixed point processors don't have a division circuit
and division is supported by algorithms using subtraction.

> >On a Blackfin, fixed-point math will be much faster that floating point.
>Software floating point is very slow compared to single-cycle fixed >point, and addition takes longer than multiplication. Is your simulator
>timing related to real hardware? > >Jerry >-- >Engineering is the art of making what you want from things you can get. >����������������������������������������������������������������������� >
Hi Jerry, First of all, a million thanks for replying my query and the guidance. The simulator timing is definitely related to real Hardware because the simulator is selected for the BF535 DSP so it has to load all the settings for the said DSP. I am still confused why this would happen. I was just thinking whether the issue is related to optimization of the code, but I am not sure.If it is the issue related to optimization then what steps need to be followed?? Or if I have to use some Blackfin specific libraries (?) then from where I can get it?? Thanks again, B.S.D.