UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer shruthi_07
Observer
7,681 Views
Registered: ‎09-30-2015

How to implement log10 (x) in verilog in Vivado?

Jump to solution
 

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? 

Please help.

 

Thanks,

Shruthi Sampathkumar.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Visitor LawsonSSEC
Visitor
13,182 Views
Registered: ‎06-03-2016

Re: How to implement log10 (x) in verilog in Vivado?

Jump to solution

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

View solution in original post

3 Replies
Xilinx Employee
Xilinx Employee
7,664 Views
Registered: ‎08-02-2011

Re: How to implement log10 (x) in verilog in Vivado?

Jump to solution

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

www.xilinx.com
0 Kudos
Visitor LawsonSSEC
Visitor
13,183 Views
Registered: ‎06-03-2016

Re: How to implement log10 (x) in verilog in Vivado?

Jump to solution

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

View solution in original post

Newbie ctpoomagal
Newbie
2,341 Views
Registered: ‎06-11-2018

Re: How to implement log10 (x) in verilog in Vivado?

Jump to solution

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

0 Kudos