Why do I get an error with system object calls in HDL Code Generation?

1 visualizzazione (ultimi 30 giorni)
error: hdlcoder:pirudd:systemobjectmultipleuse: System object methods can only be called once
My Code:
main fucntion:
[x,validOut] = mainfc(data_in,st)
persistent var ifft128 out1
if isempty(var)
var=0;
ifft128 = dsp.HDLIFFT('FFTLength',128);
end
if st==1
[out1] = func1(data);
%IFFT calculation
[Xt,validOut]=ifft128_fc(ifft128,out1,true)
elseif st==0
%To complete the IFFT calculation
[Xt,validOut]=ifft128_fc(ifft128,out1,false)
end
%ifft128_fc
function [yOut,validOut] = ifft128_fc(objeto,yIn,validIn)
[yOut,validOut] = step(objeto,yIn,validIn);
end
%My test bench for the main function
N = 128;
for i=1:1:N
[X,V] = main_fc(data_in,1);
end
for i = N+1:1:3*N
[X,V] = main_fv(data_in,0)
end

Risposta accettata

Tim McBrayer
Tim McBrayer il 18 Lug 2016
I'm not an expert in the DSP side of the product, but my understanding of your code is that you are invoking the same object twice in a single time step. You have a single dsp.HDLIFFT named ifft128 in your design. Each time that your function mainfc is called will correspond (in the simple case) to a single hardware clock cycle. In this single cycle you are calling the step function on ifft128 twice. This function can be thought of as the behavior of the IFFT implementation. So, in essence, you are attempting to run the same FFT twice in one cycle. This is not supported for HDL code generation for fairly straightforward reasons, although MATLAB has no issues executing the code that you have written. HDL Coder does not perform enough semantic analysis to notice that the two calls to step() are mutually exclusive from each other.
Your code looks easy to update. You need to make one call to your wrapper function:
[Xt,validOut]=ifft128_fc(ifft128,out1, st == 0);
If st can be any value besides 0 or 1, you may want to enclose this call inside the appropriate if statement:
if st == 0 || st == 1
[Xt,validOut]=ifft128_fc(ifft128,out1, st == 0);
end
  1 Commento
Pablo Medina
Pablo Medina il 22 Lug 2016
Thank you for hepling me. Your idea worked solve the problme of callig twice the system object. But now the HDL Coder give me this new error:
"System object methods, in file 'MODELO_fixpt' line 0, col 0, with more than one output cannot be called inside conditional statements or 'for','while' loops in HDL code generation."
Do you have any idea about what this is?

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 16 Lug 2016
You have
if isempty(var)
but you never assign to var so isempty will continue to be true, resulting in the next line being executed every pass.
  2 Commenti
Pablo Medina
Pablo Medina il 16 Lug 2016
Modificato: Pablo Medina il 16 Lug 2016
Yeah you are right but I only forgot to put it in the question. The Code is working perfectly in the simulation. The problem is at the HDL Code Generation "System object methods can only be called once". I hope you can help me on that. Thanks for the answer by the way.
Walter Roberson
Walter Roberson il 17 Lug 2016
Please post the actual code. For example should the first bit you posted a function definition where the "function" keyword has wandered off to the washroom, or is that code part of a script file? I don't think HDL can compile script files as the main entry.

Accedi per commentare.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by