Hello Dear
Does any one implement an exponential function in VHDL? and how did it? For instance, I want to calculate the EXP(a) that 'a' is a constant (negative or Positive), and floating point. what can I do for it?
" I found that one way is using Taylor series to approximate it, but it contains plenty amount of Multiplication and division, so it seems that the hardware implementation consume a lot of sources"
Regards
Mostafa
Well, I've got some exponential function HDL for you in base 2.
- - - Updated - - -
Using Taylor polynomials can be quite useful, a bit depending on your input range. If you have a small input range, you can get away with lower order polynomials. And thus not that many multiplications.
OK. Thanks . Using four terms of the Taylor polynomials gives enough accuracy for negative inputs, but It is not enough for positive one. Consider Exp(-2) and Exp(2) for instance. IS there any way except Taylor series?
Using Taylor polynomials can be quite useful, a bit depending on your input range. If you have a small input range, you can get away with lower order polynomials. And thus not that many multiplications.
Thanks Dear FvM and Dear mrflibble
Another question: how do you determine the accuracy of constant numbers when you want to use them in your design? For instance :
Pi -> 3.14 or 3.1415 ( may it is not a good example, but consider something like this) these approximating exactly related to what? an also, Is it enough to check my formula by some samples and then chose the number of polynomial terms? ( four or five terms for instance)
By using either a piece of paper + your m4d m4th sk!llz, OR by using matlab or somesuch. Basically you have to decide what your error budget is, write down what the error will be in terms of constants, degree of polynomial, number of bits in your fixed point math, etc .. and then figure out a clever engineering compromise.
If you're totally lost, you can simply do a simple matlab script to plot the influence of error of your constant/etc. As in ERROR = ideal value - your calculated value. Plot that error while playing with the values and you'll get a feeling for what's going on. After that you can always get analytical on it's posterior.