Matlab power function passing HDL coder requirements

Which could be the easiest way of realizing the MATLAB function power(a,b) in order to fulfill HDL coder conversion requirements?
According to HDL code generation, none of the power functions are supported.
Thanks in advance.

 Respuesta aceptada

Tim McBrayer
Tim McBrayer el 15 de En. de 2014
Editada: Tim McBrayer el 15 de En. de 2014
There are several ways that you could approach this, depending on your data types and value requirements. One big question is, can your exponent be fractional, or is it limited to integer values? You could build a Stateflow chart or write a MATLAB Function block, if using Simulink. You could also build a subsystem that will repeatedly multiply by your value, using only basic blocks.
If generating HDL Code from MATLAB, you can write your own function, using whatever technique you wish.

4 comentarios

Jesus
Jesus el 16 de En. de 2014
The exponent can be fractional, and I'm using pure Matlab (not Simulink). Imagine that I have:
power(10,0.2032)
Leaving Simulink out of the mix, the approach I mentioned earlier is to implement the algorithm using supported functionality. Another alternative is, if your required input range is suitably limited, is to build a 2-D lookup table. The inputs will be your inputs to the power function, suitably quantized, and the table values will be the appropriate outputs. This technique works best when you know you have a limited input range; otherwise, the table gets very large.
Jesus
Jesus el 27 de En. de 2014
Okay, i get it. I have realized LUTs for log2, log, sqrt, etc. using the scripts provided in Mathworks:
but i have not tried with exp function. I understand that these functions are not valid for negative entries (it is explicitely written within them).
My question is if it's convenient to follow this structure (LUT table + normalization & leading zeros) and which might be the changes in order to accept negative numbers without losing functionality.
can you help me out?I need to realize LUT for exponential function

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Preguntada:

el 15 de En. de 2014

Comentada:

el 21 de Abr. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by