From: abhijitk on
Hello everyone..

How to calculate Logarithm of a signal in FPGA? Is there any hardware
efficient method for it? Can CORDIC core be used to calculate log
function?

Regards
Abhijit
From: Kenn Heinrich on
"abhijitk" <mailabhi.k(a)gmail.com> writes:

> Hello everyone..
>
> How to calculate Logarithm of a signal in FPGA? Is there any hardware
> efficient method for it? Can CORDIC core be used to calculate log
> function?
>
> Regards
> Abhijit

The most hardware efficient method is a diode and an op amp! It's
somewhat ironic that you could spend $50 worth of FPGA gates (and
possibly nontrivial amounts of engineering effort) simulating this :-)

But seriously, it's all about the input and output data formats, and the
required precision. Is it fixed-point? How many bits? Could you use
somthing as simple as a leading ones detector, a lookup table and
interpolation?

- Kenn


From: emeb on
On Feb 1, 9:34 am, Kenn Heinrich <kwhei...(a)uwaterloo.ca> wrote:
> "abhijitk" <mailabh...(a)gmail.com> writes:
> > How to calculate Logarithm of a signal in FPGA?
>
> Could you use
> something as simple as a leading ones detector, a lookup table and
> interpolation?

I've done that - worked reasonably well (a few % error), didn't use up
a whole slew of gates.

Eric
From: Vladimir Vassilevsky on


abhijitk wrote:

> Hello everyone..
>
> How to calculate Logarithm of a signal in FPGA? Is there any hardware
> efficient method for it? Can CORDIC core be used to calculate log
> function?

Here is very efficient method:

ln(x) ~ x - 1

How about that?

VLV
From: Clay on
On Feb 1, 10:23 am, "abhijitk" <mailabh...(a)gmail.com> wrote:
> Hello everyone..
>
> How to calculate Logarithm of a signal in FPGA? Is there any hardware
> efficient method for it? Can CORDIC core be used to calculate log
> function?
>
> Regards
> Abhijit

A way that is pretty simple in binary (gives the log to base 2):

1) start with number x so that 2 > x >= 1 and init mantissa 0.

2) let x = x*x (square x)

3) if x>=2, then augment "1" and let x=x/2 else augment "0". The
augmenting of the "1" or "0" is done to the right side of the
manitssa.

4) go back to step 2.

This will let you compute the radix 2 logarithm to an precise number
of bits.

IHTH,

Clay

p.s. if your original number is outside of the range [1,2) simply
multiply/divide by two keeping count of the number of times and
subtracting/adding the count from/to the resulting manitissa. Final
result may be multiplied by a scaling factor to change radix of log.