Hello. I'm traying to generate un HDL code from matlab user-definded function algorithm and got an error about function specialisation that I didn't understand.

2 vues (au cours des 30 derniers jours)
this is the error msg that I got :
The function 'AppDec_Fun2' contains persistent variables 'dataAppFun2' and has specialization 'AppDec_Fun2_s1' associated with it. Function specializations containing persistent variables are not supported for fixed-point conversion. Consider rewriting your algorithm such that it does not use persistent variables within functions that require specialization.
  3 commentaires
Bouchra BENDAHANE
Bouchra BENDAHANE le 3 Sep 2021
Modifié(e) : Walter Roberson le 3 Sep 2021
Thank you for your answer. I understood that the output of the called function shoudn't be inside any loop but I'm working with signals and wich impose the use of loop inorder to generate output signal.
this is my function code:
function [Output_vect,output_ENB] =AppDec_Fun2(Input_vect,input_ENB)
LFD1=-0.0106;
LFD2=0.0329;
LFD3=0.0308;
LFD4=-0.1870;
LFD5=-0.0280;
LFD6=0.6309;
LFD7=0.7148;
LFD8=0.2304;
Output_vect=zeros(1,8);
persistent dataAppFun2;
if isempty(dataAppFun2)
dataAppFun2=zeros(1,8);
end
if input_ENB==1
j=1;
for i=1:1:length(Input_vect)
dataAppFun2(1)=dataAppFun2(2);
dataAppFun2(2)=dataAppFun2(3);
dataAppFun2(3)=dataAppFun2(4);
dataAppFun2(4)=dataAppFun2(5);
dataAppFun2(5)=dataAppFun2(6);
dataAppFun2(6)=dataAppFun2(7);
dataAppFun2(7)=dataAppFun2(8);
dataAppFun2(8)=Input_vect(i);
if mod(i,2)==0
Output_vect(j)=dataAppFun2(1)*LFD1+dataAppFun2(2)*LFD2+dataAppFun2(3)*LFD3+dataAppFun2(4)*LFD4+dataAppFun2(5)*LFD5+dataAppFun2(6)*LFD6+dataAppFun2(7)*LFD7+dataAppFun2(8)*LFD8;
j=j+1;
end
end
output_ENB=1;
else
output_ENB=0;
end
Walter Roberson
Walter Roberson le 3 Sep 2021
Memory Store perhaps ?
Or you could probably avoid the problem by coding the function in fixed-point yourself, so that it did not need to be specialized to convert from double to fixed point.

Connectez-vous pour commenter.

Réponses (1)

Kiran Kintali
Kiran Kintali le 7 Sep 2021
Can you share a sample design.m, testbench.m and project file used for fixed point conversion?
Thanks
  3 commentaires
Kiran Kintali
Kiran Kintali le 7 Sep 2021
I was looking for project file containing 'AppDec_Fun2' to see the fixed point settings and a testbench driving the function to analyze the ranges.
Bouchra BENDAHANE
Bouchra BENDAHANE le 8 Sep 2021
The function 'AppDec_Fun2'is not my principale function from wich I'm generating HDL code. I gave its matlab code in previous comments.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Code Generation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by