Hardware Log and EXP

As part of a signal processing design I'm working on (I was given C/Matlab code, and told "go make it hardware"), I need to calcuate log(1+B^d). So far, I've found some information on CORDIC and 2 software approximations. I need to do this in 32 bit floating point, and the requirements call for "as much accuracy as you can get" as no one has been able to figure out how much we really need yet. There's also a large possible difference betwen the biggest and smallest numbers that are used in this calcuation, so using some fixed-point system is most likly more work then it's worth.

I'm thinking that I could calcuate B^d as e^(d * LN(B)), since I'm hoping that whatever way I end up using to find log(x) can be reversed to find e^x as well.

The approximations I've found so far have all been software based, and didn't seem that accurate (about 5 or so decimal digits when tested in Matlab). It also seems like taking the iterative/software-based approach is the wrong way to go, and could easily lead to the log/exp unit needing over a hundred cycles to execute. The two approximations I've looked at are the one from glibc and the one used in the VHDL Real Math package.

CORDIC seemed more promising at first, but it looks like it's not widly used for floating point. However, I haven't been able to find any deatails on what other methods might be better.

Can anyone suggest a better way? Are there any approximations that are more hardware then software based? Or would I be better off either using one of them, or CORDIC?

Thanks, Mike

(Sorry if tihs is a re-post, I tried to post this an hour ago, but it didn't show up, I might have clicked the wrong button.)

Reply to
Mike Delaney
Loading thread data ...

This doc has some interesting ideas. They are not meant to be synthesizable, but can be made so easily.

formatting link

You should mention your clock rate and how many cycles you have. If you've got lots of time, you can use an embedded processor. The hard part is doing everything quickly. Lookup tables can be done easily with the deep Xilinx ROMs. What precision is required? Do you really need floating point? Can you normalize the radix points by successive single shifts, or do you need a barrel shifter? The Taylor approach is very good if you have an embedded multiplier and if you have several cycles you can reuse the same multiplier. Use the Horner algorithm to reduce the number of multiplications required.

-Kevin

Reply to
Kevin Neilson

Mike,

Neither CORDIC nor the software approximations are all that appropriate for hardware (FPGA) implementation. The first question is how accurate do you need the log? A quick and dirty Log will get you to about 1/4 dB using a very small LUT and barrel shift. Here's the secret:

You've got some number Y which has a big dynamic range (say it's floating point, for example). Y can be broken into Y=(2^b)*a where a is a normalized value such that 1.0

Reply to
Ray Andraka

Oh yeah, I forgot to mention this. Of course the CORDIC is fixed point. CORDIC is an inherently fixed point algorithm. It makes absolutely no sense to attempt CORDIC as floating point. If you need to use CORDIC for floats, then you should first normalize your I and Q inputs so that the larger is left justified and they share a common exponent, Then you perform the CORDIC rotation on the normalized mantissa pair as a fixed point operation, passing the common exponent around the CORDIC. At the CORDIC output, you can renormalize the I and Q and marry those individually with the common exponent. It doesn't make sense to do the insides of CORDIC in floating point because it is a shift and add operation. Each iteration requires the mantissa for either I or Q to be denormalized so that they have a common exponent so that they can be summed. Further, each elemental rotation does not alter the magnitude of the vector (other than a small fixed gain), so each stage in the CORDIC rotation has the same common exponent.

The CORDIC Log is somewhat awkward --

--Ray Andraka, P.E. President, the Andraka Consulting Group, Inc.

401/884-7930 Fax 401/884-7950 email snipped-for-privacy@andraka.com
formatting link

"They that give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin, 1759

Reply to
Ray Andraka

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.