04-07-2009 10:35 AM
Hi everyone, I have a question about the FPGA functions. One can use scale by power of 2. But there is no possibility to use power of ten. I also installed the Fixed-Point Math library where one can choose the natural logarithmic but not logarithmic of 10. Has someone an idea how to do this very fast??
Regards, Irina
04-07-2009 11:38 AM
Hi Irina,
The Scale by Power of 2 just multiplies x by 2n, but I think what you are asking for here is something analogous to the Square function (x2), where you need x10?
There are a number of possible approaches, but there is a fundamental limitation with fixed-point types that they aren't good at representing large dynamic ranges (ie, it takes a lot of bits to be able to represent very large and very small numbers in the same wire). With a power of 10, any inputs that are significantly different than 1 will give you very large or small numbers, so you'll need to have a very restricted input range to make this work, or use an alternate representation such as a logarithmic number system (LNS).
That said, one idea is to take the equation y = x10 and apply a natural log and exponential to both sides, giving y = e10 ln(x). This can be accomplished with the Fixed-Point Math library functions, but there are restrictions on the range of x that you'll have to deal with.
Other approaches include using a look-up table, computing directly via multiplication, doing the operation in floating-point or LNS (via 3rd party IP), or moving that portion of the computation to the host. There are often ways of re-posing the problem for an FPGA implementation, so if you can provide more details of what your application needs to do, we might be able to come up with a more efficient way to get this part done.
Jim
04-07-2009 01:12 PM
Hi Jim, what I mean with power of 10 is 10x.And this seems to be not possible on FPGA!
Regards, Irina
04-07-2009 02:35 PM
Hi Irina,
Oops, that would make more sense, since that's what you asked for! Good news is, I think that makes the problem a bit easier. Assuming the range of x is reasonable, this is very possible. All we have to do is solve ey = 10x, where y will be the input for the Fixed-Point Math library exponential function.
The result is to simply multiply your x by ln(10) = 2.3026... and use the exponential function. That function requires an input with magnitude less than 1, so you might have to apply another similar scaling trick to bring the input into that range. I believe that procedure is described in the documentation for the exponential function.
04-07-2009 03:02 PM
Another option for small power of 10 is to use scale by power of 2 and additions. You need to be aware of overflow and your datasize.
For y=x*10
y=x*2^1+x*2^3
For y=x*100
y=x*2^6+x*2^5+x*2^2
04-09-2009 08:13 AM