DSPRelated.com
Forums

pow/log functions in fixed point

Started by dsp.study July 20, 2010
Hi,

I have successfully converted add, sub, mul and div operations to fixed pt
and see ~10 times improvement.

I'm not sure how to go about doing pow and log functions...can some one
please suggest an algo or pt me to an open source code for reference.

thanks,
Marty


dsp.study <learner.study@n_o_s_p_a_m.gmail.com> wrote:
 
> I have successfully converted add, sub, mul and div operations to fixed pt > and see ~10 times improvement.
> I'm not sure how to go about doing pow and log functions...can some one > please suggest an algo or pt me to an open source code for reference.
Fixed point exp() and log() are in Knuth's "Metafont: The Program." (In Pascal, if that isn't too bad.) -- glen
On Tue, 20 Jul 2010 06:15:44 -0500, "dsp.study"
<learner.study@n_o_s_p_a_m.gmail.com> wrote:

>I'm not sure how to go about doing pow and log functions...can some one >please suggest an algo or pt me to an open source code for reference.
http://groups.google.com/group/comp.dsp/browse_thread/thread/ce4f56d93425ee17
On Jul 20, 7:15 am, "dsp.study" <learner.study@n_o_s_p_a_m.gmail.com>
wrote:
> > I have successfully converted add, sub, mul and div operations to fixed pt > and see ~10 times improvement.
on what platform did you do this? the only kind of platform i can think of that would have this kind of speed improvement is a chip without native floating-point capability. and what did you convert the add and sub operations from? i'm curious.
> I'm not sure how to go about doing pow and log functions...can some one > please suggest an algo or pt me to an open source code for reference.
do you need bit-wise accuracy? or can you trade off some error performance for speed performance? for DSP chips, i've always been a proponent of simple polynomials with optimized coefficients for a single octave and then to use shift operations to get the other octaves. r b-j
On 07/20/2010 04:15 AM, dsp.study wrote:
> Hi, > > I have successfully converted add, sub, mul and div operations to fixed pt > and see ~10 times improvement.
In what? Speed? Code size? Weight? Beauty? Management approval? Wages?
> I'm not sure how to go about doing pow and log functions...can some one > please suggest an algo or pt me to an open source code for reference.
-- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
This is on a mips processor which doesn't have native floating pt support.
I have converted from floating pt to fixed pt (8.24) i.e. 8 bits for int
part and 24 for fraction.

I'd looking at log10 - any pointers would be highly appreciated.

thanks,
Marty

>On Jul 20, 7:15 am, "dsp.study" <learner.study@n_o_s_p_a_m.gmail.com> >wrote: >> >> I have successfully converted add, sub, mul and div operations to fixed
pt
>> and see ~10 times improvement. > >on what platform did you do this? the only kind of platform i can >think of that would have this kind of speed improvement is a chip >without native floating-point capability. > >and what did you convert the add and sub operations from? > >i'm curious. > >> I'm not sure how to go about doing pow and log functions...can some one >> please suggest an algo or pt me to an open source code for reference. > >do you need bit-wise accuracy? or can you trade off some error >performance for speed performance? for DSP chips, i've always been a >proponent of simple polynomials with optimized coefficients for a >single octave and then to use shift operations to get the other >octaves. > >r b-j >
I tried to use the sample code for BinLog() and notice that its taking 1.5x
more cycles as compared to std libc log2(). 

I'm using MIPS cpu.

thanks!

>On Tue, 20 Jul 2010 06:15:44 -0500, "dsp.study" ><learner.study@n_o_s_p_a_m.gmail.com> wrote: > >>I'm not sure how to go about doing pow and log functions...can some one >>please suggest an algo or pt me to an open source code for reference. > >http://groups.google.com/group/comp.dsp/browse_thread/thread/ce4f56d93425ee17 >
On Wed, 21 Jul 2010 02:39:27 -0500, dsp.study wrote:

> I'd looking at log10 - any pointers would be highly appreciated.
log10 is only a constant factor different from log2, and the latter is where you want to be starting from. You can get the integer part from whatever the processor-native version of count-leading-zeros is. That leaves you with a value between 0.5 and 1.0 (in whatever fixed point form you're using). How you proceed from there depends on the accuracy you require. You can do iterations of the taylor series, polynomial approximations, or table-lookup and further refinements. Depends a lot on what you want to do with your logs afterwards... Cheers, -- Andrew
dsp.study <learner.study@n_o_s_p_a_m.gmail.com> wrote:

>This is on a mips processor which doesn't have native floating pt support. >I have converted from floating pt to fixed pt (8.24) i.e. 8 bits for int >part and 24 for fraction. > >I'd looking at log10 - any pointers would be highly appreciated.
I'd recommend implementing log2 in fixed point, and recoding anything to use it instead of log10. Since you asked.... S.
On Jul 20, 4:15=A0am, "dsp.study" <learner.study@n_o_s_p_a_m.gmail.com>
wrote:
> Hi, > > I have successfully converted add, sub, mul and div operations to fixed p=
t
> and see ~10 times improvement. > > I'm not sure how to go about doing pow and log functions...can some one > please suggest an algo or pt me to an open source code for reference. > > thanks, > Marty
Did you try the obvious and search? I always go to TI's website. http://focus.ti.com/lit/an/spra619/spra619.pdf http://www.dattalo.com/technical/theory/logs.html#2.%20Borchardt's%20Algori= thm You still need to find sqrt() though. http://math.fullerton.edu/mathews/n2003/pade/PadeApproximationMod/Links/Pad= eApproximationMod_lnk_8.html Peter Nachtwey