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.

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 Comments

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
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.

Sign in to comment.

Answers (1)

Can you share a sample design.m, testbench.m and project file used for fixed point conversion?
Thanks

3 Comments

For fixed point conversion I watched a video and I'm reading in matlab documentation there are more details.
I hope it was helphul for you.
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.
The function 'AppDec_Fun2'is not my principale function from wich I'm generating HDL code. I gave its matlab code in previous comments.

Sign in to comment.

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!