HDL Coder: Replace the exp Function with a Lookup Table
Mostrar comentarios más antiguos
Hello,
I want to use an exponential function with complex input values on an FPGA.
I followed the following guide to convert a not supported fixed point function into a lookup table: https://de.mathworks.com/help/hdlcoder/ug/replace-the-exp-function-with-a-lookup-table.html
If I run the example with complex input values then the replacing of the exp function with a lookup table fails. Using the same example with non complex input values succeeds. When looking at the fixpt function it can be seen that it still uses exp:
...
function y = custom_fcn(x)
fm = get_fimath();
y = fi(exp(x), 1, 14, 12, fm);
end
...
Which results in the error: ??? Function 'exp' is not defined for values of class 'embedded.fi'.
Which leaves me at the question how can an exponential function with complex inputs be implemented on an FPGA using the HDL coder?
I attached my files here. Testbench:
close all
nbrIterations = 10000;
LUT_result = zeros(nbrIterations,1);
diff = zeros(nbrIterations,1);
%Random values betwen -1.5705 and 1.5705
random_in = (3.141.*rand(nbrIterations,1) -1.5705)*1j;
for i=1:nbrIterations
LUT_result(i) = call_custom_fcn( random_in(i));
diff(i) = abs( LUT_result(i) - exp(random_in(i)) );
end
figure(1); plot(diff);
custom_fcn.m:
function y = custom_fcn(x)
y = exp(x);
end
call_custom_fcn.m:
function y = call_custom_fcn(x)
y = custom_fcn(x);
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Code Generation en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!