Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to Calculate an Exponential value?

Status
Not open for further replies.

sheikh

Advanced Member level 4
Joined
Sep 10, 2007
Messages
104
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
2,008
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. :p

- - - 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.
 
  • Like
Reactions: sheikh

    sheikh

    Points: 2
    Helpful Answer Positive Rating
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.
And no divisions at all if you replace with constant multiplications.
 
  • Like
Reactions: sheikh

    sheikh

    Points: 2
    Helpful Answer Positive Rating
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)
 

Another question: how do you determine the accuracy of constant numbers when you want to use them in your design?

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. :p
 
Thanks a lot :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top