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
Bouchra BENDAHANE 2021년 9월 3일
편집: 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
Bouchra BENDAHANE 2021년 9월 8일
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