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.

1 次查看(过去 30 天)
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 个评论
Bouchra BENDAHANE
编辑:Walter Roberson 2021-9-3
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 2021-9-3
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.

请先登录,再进行评论。

回答(1 个)

Kiran Kintali
Kiran Kintali 2021-9-7
Can you share a sample design.m, testbench.m and project file used for fixed point conversion?
Thanks
  3 个评论
Kiran Kintali
Kiran Kintali 2021-9-7
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
The function 'AppDec_Fun2'is not my principale function from wich I'm generating HDL code. I gave its matlab code in previous comments.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Code Generation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by