Error while using HDL coder: variable-size matrix type is not supported for HDL code generation

7 views (last 30 days)
please help!!
function [alphaijVHDL]=Inter_func(betaijVHDL,alphaijVHDL,EN_sp_i,sgn,pas,s2,sp,threshold)
temp1=0;
betaijSP=zeros(1,1152);
alphaijSP=zeros(1,1152);
for isp=0:sp-1
betaijSP=betaijVHDL(1+(pas+pas*(isp-1)) : pas+pas*isp);
coder.varsize('betaijSP',[1 1152]);
val1=betaijSP(betaijSP~=0);
dlin2=length(val1);
val3=zeros(1,dlin2);
if dlin2>=1
for j=1:dlin2
val2=val1;
val2=abs(val2);
val2(j)=10000;
min_local=min(val2);
%******************************************
if isp==0
if min_local<=threshold
val3(j)=s2*sgn(j+temp1)*min(val2);
elseif EN_sp_i(isp+2)==1
val3(j)=s2*sgn(j+temp1)*threshold;
else
val3(j)=s2*sgn(j+temp1)*min(val2);
end
else
if min_local<=threshold
val3(j)=s2*sgn(j+temp1)*min(val2);
elseif EN_sp_i(isp)==1
val3(j)=s2*sgn(j+temp1)*threshold;
else
val3(j)=s2*sgn(j+temp1)*min(val2);
end
end
end
alphaijSP=alphaijVHDL(1+(pas+pas*(isp-1)) : pas+isp*pas);
alphaijSP(betaijSP~=0)=val3;
alphaijVHDL(1+(pas+pas*(isp-1)) : pas+isp*pas)=alphaijSP;
end
temp1=dlin2+temp1;
end
end

Accepted Answer

Bilal MEJMAA
Bilal MEJMAA on 8 Jan 2023
Thank you so much for your answer
In general I need to split an Input vector into two partitions and process each partition inside the "for isp=0:sp-1" boucle (Line5) according to the other input parameters, then fed the output with the same size of the input vector.
  2 Comments
Kiran Kintali
Kiran Kintali on 8 Jan 2023
Thanks for sharing the design and the testbench.
for ii=1:n
% body of the loop
end
for such loops 'n' needs to be compile time constant. In your example 'sp' variable is defined as a variable (not a coder.Constant). You can change the variable 'sp' to an example constant in the input variable table and choose define as Constant.
If you keep this loop bound as a variable the number of iterations are not fixed and hence not synthesizable to hardware.
Similarly betaijSP is defined as a variable sized variable. Such dynamic sized variables are not currently supported for HDL code generation as they not synthesizable.
Bilal MEJMAA
Bilal MEJMAA on 9 Jan 2023
Thank you for your support Mr Kiran ,
I defined 'sp' as coder.Constant but I still have the Error that coder.Constant type does not support the parameter ':' I am still wondering how can I set loops in the program.

Sign in to comment.

More Answers (1)

Kiran Kintali
Kiran Kintali on 8 Jan 2023
Can you please share design (Inter_func.m) and testbench (Inter_func_tb.m) driving the design with valid inputs and the HDL Coder project file (.prj) with code generation settings?
HDL Code generation requires static matrix types (i.e., variable assignments should not change sizes dynamically) for successful hardware synthesis. The design seem to be changing variable sizes between multiple assignments or output sizes are not determinable with input sizes to operators and depend on the run time values of the variables.
  2 Comments
Achala G
Achala G on 1 Mar 2024
HDL Conformance check complete with 23 errors, 0 warnings, and 4 messages.
Function LocationLevelDescription
eucleds_verilog_fixpt:55Error'var1' : HDL code generation does not support variable-size matrix type
eucleds_verilog_fixpt:55Error'res' : HDL code generation does not support variable-size matrix type
eucleds_verilog_fixpt:55Error'hfi' : HDL code generation does not support variable-size matrix type.
I have defined some of variables like
coder.varsize('X',[1 10]);
coder.varsize('Y',[1 10]);
inside the matlab code. Still i get above error while running HDL code generation part.
Could you please help me in solving above issue?
Since I have written code for polynomial devision and hence each time quotient and reminder polynomial size varies.
Kiran Kintali
Kiran Kintali on 1 Mar 2024
Can you share your model?
You would need to review the data type inference related issues. You can use code generation report for the MATLAB constructs in question and remove unsynthesizable variable matrix types. The code generation report is accessible in MATLAB function block and MATLAB to HDL workflows.

Sign in to comment.

Categories

Find more on Code Generation in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!