HDL Coder Variable Size Matrix

8 ビュー (過去 30 日間)
Caner KOREL
Caner KOREL 2022 年 11 月 17 日
コメント済み: Hau 2025 年 2 月 13 日 3:14
Hello, I'm trying to do matrix multipication in fpga. For this, I would like to convert my .m function given below.
function y=sindy_product(x1,x2)%mxn . nxk
y=zeros(1,225);%mxk
iteration=1;
coder.varsize('A',[1 1000001]);
coder.varsize('B',[1 1000001]);
for i = 1:1000001:1000001*15%n,mxn
for j =1:15%k
A=x1(i:i+1000001-1);%n
B=x2(j:15:1000001*15);%k,nxk
C=0;
for k = 1:1000001
C=C+A(k)*B(k);
end
y(iteration)=C;
iteration=iteration+1;
end
end
end
Error I get:
sindy_product_fixpt:17Error'B' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:20Error'A' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:16Error'A' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:20Error'B' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:20Error'A' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:17Error'B' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:16Error'A' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:16Error'varargin_1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:16Error'varargin_1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:17Error'varargin_1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:17Error'varargin_1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:16Error'varargin_1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:16Error'varargin_1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:17Error'varargin_1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:17Error'varargin_1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:16Error'var1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:16Error'A' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:16Error'var1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:17Error'var1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:17Error'B' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:17Error'var1' : Error: variable-size matrix type is not supported for HDL code generation.sindy_product_fixpt:0ErrorMATLAB HDL Coder failed in the code generation phase. See HDL Coder conformance report.
I use matricies' row vector form because hdl coder doesnt allow to use matrix form. I think my all the variables have constant size but i still get the variable-size matrix error.

採用された回答

Ryan Baird
Ryan Baird 2022 年 11 月 18 日
coder.varsize is declaring a variable size matrix:
Initializing the matrix with the zeros function may solve your issue.
  1 件のコメント
Hau
Hau 2025 年 2 月 13 日 3:14
I have read the problem and read the proposal solution and i write this code but i still have the same problem. Can i have some ideas ?
function out = test(in, n, intrlv)
% Define the maximum possible input length (adjust to your needs)
max_len = 100;
% Pre-allocate output array with a fixed size
out = zeros(1, max_len);
% Calculate the block size
bl_n = n * intrlv;
% Calculate the maximum number of blocks (fixed size)
max_blocks = max_len / bl_n;
% Loop through each block with fixed indexing
for b = 1:max_blocks
% Calculate the index range (fixed)
idx_start = (b-1) * bl_n + 1;
idx_end = b * bl_n;
% Ensure indices are within the input length
if idx_end <= length(in)
% Copy the block to the output
out(idx_start:idx_end) = in(idx_start:idx_end);
end
end
end

サインインしてコメントする。

その他の回答 (1 件)

Kiran Kintali
Kiran Kintali 2022 年 11 月 17 日
Can you share your design and testbench and the project file used?
Thanks

カテゴリ

Help Center および File ExchangeCode Generation についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by