unexpected matlab expression during hdl code generation

조회 수: 2 (최근 30일)
Abhimanyu
Abhimanyu 2014년 3월 18일
답변: Tim McBrayer 2014년 3월 18일
Dear sir/madam, whenever I am trying to generate a verilog code I am getting an 'Unexpected Matlab Expression' error.. I googled the solution, but I am unable to understand what's wrong... plz help.. Here's my code
function y = fir_project(x,h)
% x = [1/5,2/5,3/5,4/5];
% h = [1/3,1/3,1/3];
% initialize
x1 = 0;
x2 = 0;
y = zeros(1,length(x));
for k = 1:length(x)
if k-2 == -1 || k-2 == 0
x2 = 0;
else
x2 = x1;
end
if k-1 == 0
x1 = 0;
else
x1 = x(k-1);
end
y(k) = (h(1)*x(k))+(h(2)*x1)+(h(3)*x2);
end
end
The x and h values are given in comments. Thanks in advance. This is the error I am getting
emlhdlcoder.WorkFlow.Manager.instance.wfa_generateCode(' C:\Documents
\matlab\fir's project\firproj2.prj ');
|
Error: Unexpected MATLAB expression.

답변 (1개)

Tim McBrayer
Tim McBrayer 2014년 3월 18일
I think that HDL Coder will have a hard time with your variable loop bound; this is hard to build hardware for. I have no issues when I use a constant 4 instead of the expression length(x) .

카테고리

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