Matlab 2014b HDL coder, code generation failed.

I've been quickly testing out MATLAB HDL coder to determine how suitable it is to make some very simple VHDL signal processing components. Unfortunately it seems that the fixed point code it generates as part of the process fails to pass its own error checking when it reaches the HDL conversion stage.
The function below its just a quadrature demodulator with a complex input. This is MATLAB's auto generated fixed point version of my original function (which used doubles).
function out_var = quad_demod_fixpt(input_var)
fm = fimath('RoundingMethod', 'Nearest', 'OverflowAction', 'Wrap', 'ProductMode', 'FullPrecision', 'sumMode', 'FullPrecision');
persistent previous
if isempty(previous)
previous = fi(0 + 0I, 1, 16, 14, fm);
end
multi_result = fi(input_var * conj(previous), 1 ,16 ,14, fm);
out_var = fi(atan2( imag(multi_result), real(multi_result)), 1, 16, 13, fm);
previous(:) = input_var;
end
Error line 11: "HDL code generation for fixed point division is only supported when RoundingMethod is Zero or Nearest." As far as I can tell it is using a RoundingMethod of Nearest. This is just one of several errors we've encountered where on examination of the code there does not seem to be an issue.
Any ideas on what is going wrong (or what I'm doing wrong!) ?

回答 (1 件)

Kiran Kintali
Kiran Kintali 2015 年 5 月 27 日

0 投票

Hello,
Thank you for your question; we would like to investigate further on this issue and provide a workaround.
Can you tell us what release of MATLAB you are using? Can you share your design, testbench and MATLAB to HDL project files so that we can reproduce this issue?
Thank you again for your feedback.

1 件のコメント

abjad
abjad 2015 年 5 月 28 日
Hello, thanks for the reply.
The MATLAB version used was MATLAB for Linux R2014a 64bit. I have also tested it on MATLAB for Windows R2014a with identical results.
The test bench code is:
%quad_demod_tb.m Fs = 1000; N = Fs – 1; out = zeros(Fs^2,1); for k = 0:N for n = 0:N out((k*Fs)+n+1 = exp(-2i*pi()*k*n/N); end end
result = zeros(length(out),1); for x = 1:length(out) result(x) = quad_demod(out(x)); end; plot(fftshift(result));
The steps to replicate the problem are: 1. Open the HDL coder app. 2. Select the quad_demod function and set the input type as a complex(double(1x1)). 3. Select the quad_demod_tb.m script as the testbench. 4. Start the workflow adviser. 5. Run the simulation with the the quad_demod_tb.m test bench 6. The correct max and min values for each variable are correctly determined by the simulation. The proposed acceptable. 7. Set the default word length as 16. 8. In the advanced settings set the rounding method to “nearest” and the signedness to “signed”. 9. Manually set the rounding method for each variable to “nearest” by clicking on each variable in the code and selecting “nearest” in the popup menu that appears. 10. Click “Validate types”. The validation is successful. 11. Click “Test Numerics”. This produces an acceptable result from the test bench. 12. In the HDL code Generation window click run. 13. This fails and the error is shown as described in the original post.

サインインしてコメントする。

質問済み:

2015 年 5 月 27 日

コメント済み:

2015 年 5 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by