HDL Coder: Replace the exp Function with a Lookup Table
15 ビュー (過去 30 日間)
古いコメントを表示
Fabig
2017 年 4 月 19 日
コメント済み: Bharath Venkataraman
2017 年 4 月 20 日
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
0 件のコメント
採用された回答
Bharath Venkataraman
2017 年 4 月 19 日
You can try using a lookup table to implement exponent for a given input range. Another option is to try the CORDIC implementation .
2 件のコメント
Bharath Venkataraman
2017 年 4 月 20 日
In MATLAB, you can have one lookup table with complex values and HDL Coder will do the right thing in generating code for the complex numbers. You may also split it up if that is more readable.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!