logarithm look-up table

Hi all,

I'm about to convert the amplitude output from a Cordic to dB,

20*log(amp) that is. The output from the Cordic is 24 bits wide, the maximum value would thus be approximately 144.5 dB. It is sufficient with 12 bits resolution on the logarithm, 8 integer bits and 4 fractional bits.

My idea is to create a look-up table out of BRAM in the FPGA, and since I want 12 bits resolution the size should not be larger than 2312 words (the largest value is 10010000.0111 which is equal to 2311 if the binary point is removed) each 12 bits wide. The problem has proved to be to create a clever address function though.

Any thoughts or ideas I have forseen? I'm sure this has been done before, but some Googling didn't really help me in the right direction.

Regards

--
-----------------------------------------------
Johan Bernspång, xjohbex@xfoix.se
 Click to see the full signature
Reply to
Johan Bernspång
Loading thread data ...

Isn't the largest (scaled) value 1.111111111111?

Logs are typically performed first with a shift until the MSbit of the scaled value is 1. The amount of shift is the log2 integer portion. The remaining bits are then used for the lookup to produce the fractional portion of the log2. If you need log10 or ln, you can multiply the complete log2 result (integer plus fractional) by 1/log2(10) or 1/log2(e), respectively.

- John_H

Reply to
John_H

Left shift the CORDIC output to get the first '1' bit into the left most position, keeping track of how many bit positions you shift. Each shift is 6dB. The residue that is left has the MSB always '1' so it can be discarded (it is implied), and then use as many MSBs of the remaining residue to address a smaller table. Add the number of bit shifts * 6dB to the table output to get your complete log. A 4 bit look-up will get you to about 1/4dB, which is often sufficient. In that case, no BRAMs are used or harmed for testing the product :-)

Reply to
Ray Andraka

Ray and John_H,

Thanks a lot for your inputs. I kind of knew I would get some valuable comments from the group, and I'm not really surprised it came from you guys... I will take it to my heart and implement it as soon as I get back to my office.

Regards

Johan

Ray Andraka skrev:

Reply to
j.bernspang

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.