cancel
Showing results for
Show  only  | Search instead for
Did you mean:
Highlighted
Observer
8,498 Views
Registered: ‎09-30-2015

Hello all,

I want to write a variable in decibels. So I need to do variable = 10*log10(x).

How to implement log10 on Verilog for Vivado?

Thanks,

Shruthi Sampathkumar.

Tags (3)
1 Solution

Accepted Solutions
Highlighted
Visitor
13,999 Views
Registered: ‎06-03-2016

Sorry I don't have FPGA code handy, but I have implemented a fixed point integer logarithm on small microprocessors.  I used a successive approximation algorithm similar to CORDIC.  http://www.quinapalus.com/efunc.html <= is where I found the basic algorithm.  In my case, I built a Log2() function covering an input range of 1 to 2 with a prescaling loop to find the integer portion of the answer.  Then I used the change of base formula to convert any logarithm to Log2(). example: 10*log10(x) = 10/log2(10)*log2(x).  Gave about 1-bit per loop and I would expect a state machine implementing it to be pretty simple.

Also found this quick discussion that links to a few other algorithms in current use for calculating logarithms. What algorithm is used by computers to calculate logarithms?

Marty

3 Replies
Highlighted
Xilinx Employee
8,481 Views
Registered: ‎08-02-2011

A lookup table is common for this, depending on your requirements.

www.xilinx.com
Highlighted
Visitor
14,000 Views
Registered: ‎06-03-2016

Sorry I don't have FPGA code handy, but I have implemented a fixed point integer logarithm on small microprocessors.  I used a successive approximation algorithm similar to CORDIC.  http://www.quinapalus.com/efunc.html <= is where I found the basic algorithm.  In my case, I built a Log2() function covering an input range of 1 to 2 with a prescaling loop to find the integer portion of the answer.  Then I used the change of base formula to convert any logarithm to Log2(). example: 10*log10(x) = 10/log2(10)*log2(x).  Gave about 1-bit per loop and I would expect a state machine implementing it to be pretty simple.

Also found this quick discussion that links to a few other algorithms in current use for calculating logarithms. What algorithm is used by computers to calculate logarithms?

Marty

Highlighted
Newbie
3,158 Views
Registered: ‎06-11-2018

How the lookup table method is used to implement log10 (x) in verilog. Please give me some example?