How to convert squareroot and arctan function to VHDL?
9 views (last 30 days)
Show older comments
Hello,
Please help me to get (transform) the square root function and arc tan function from MATLAB to VHDL code. I need to know how the underlying algorithm can be achieved by simple arithmetic operations (+, -, / , *) on hardware. I need to verify a hardware implementation of an algorithm which has squareroot and arctan functions. The verification language only supports simple arithmetic operations (it does not support exponent, squareroot and arctan functions). Your kind help in this regard would be much appreciated.
Thank You
0 Comments
Answers (2)
Tim McBrayer
on 3 Nov 2014
How would you implement this not on hardware, using the same set of operators that you have available? There are series expansions for both of these high level functions. You need to research them, find the one that best fits your use case, and implement an iterative solution. For hardware you may want to unwind the iteration into a pipeline.
For example, HDL Coder uses the Newton-Raphson algorithm, with a default of 3 iterations, when implementing the Square Root block in Simulink.
Finally, if you have a fixed input range, you can often build a lookup table that implements any function over the given range. With trig functions you can typically reduce your table size to 1/4 of a full cycle by exploiting the symmetry of the function as well.
0 Comments
James Tursa
on 3 Nov 2014
This doesn't really sound like a MATLAB problem to me, and I am not sure you will get much help on this forum. There are a variety of methods for getting sqrt & trig functions implemented using only basic operations which you can Google. Some methods might also use bit operations (masking & shifting etc) to get at the exponent and mantissa bits directly. They might employ reduced range rational function approximations, etc. Again, much of this can be found with Google searches, but getting fast and accurate solutions for these functions is not trivial and I don't think you will get much help on a MATLAB forum for this.
0 Comments
See Also
Categories
Find more on HDL Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!