MATLAB Datapath アーキテクチャでは、​ループの反復でサイズ​が変化する式はサポー​トされていません。

조회 수: 6 (최근 30일)
kkdra57
kkdra57 2022년 5월 10일
답변: Atsushi Matsumoto 2022년 6월 3일
HDL Coderを利用してSimulinkモデルからHDLコードを生成する際、
下記に示すmatlab function block(fcn)を含むモデルを生成実行したところ、以下のエラーが出てしまいます。↓
”式 'output( (i-1)*length(mat(:,1))+1 : (i)*mat(:,1)) )' は、別のループの反復でサイズが変化します。MATLAB Datapath アーキテクチャでは、ループの反復でサイズが変化する式はサポートされていません。”
本エラーを回避するにはどうすればよろしいでしょうか。
宜しくお願いします。
%% matlab function block(fcn)
% mat:大きさ620×5の行列
function output = fcn(input,mat)
output = zeros(length(mat(:,1))*(224+2),1); % output:大きさ140120×1の行列
% 入力inputを4つ毎に区切り、2進数変換行列DataSym(大きさ1×35030の行列)を生成
Digit1 = input(1:4:length(input));
Digit2 = input(2:4:length(input));
Digit3 = input(3:4:length(input));
Digit4 = input(4:4:length(input));
DataSym = 8*Digit1+4*Digit2+2*Digit3+Digit4;
% Datasymの値に応じて行列matの列成分を配列outputに代入
for i = 1:length(DataSym)
switch DataSym(i)
case 0
output( (i-1)*length(mat(:,1))+1 : (i)*length(mat(:,1)) ) = mat(:,1);
case 1
output( (i-1)*length(mat(:,1))+1 : (i)*length(mat(:,1)) ) = mat(:,2);
case 2
output( (i-1)*length(mat(:,1))+1 : (i)*length(mat(:,1)) ) = mat(:,3);
case 3
output( (i-1)*length(mat(:,1))+1 : (i)*length(mat(:,1)) ) = mat(:,4);
case 4
output( (i-1)*length(mat(:,1))+1 : (i)*length(mat(:,1)) ) = mat(:,5);
end
end
end

채택된 답변

Atsushi Matsumoto
Atsushi Matsumoto 2022년 6월 3일
HDL Coderで生成するのは回路用の記述(HDL)なので、回路サイズが実行途中に変わるというのは物理的に難しく、可変サイズのForループには対応していません。
ループ回数が固定になるよう、最大ループ回数を固定回数実行するようにコードを書き換えればうまく行くようになると思います。

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Code Generation에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!