unexpected matlab expression during hdl code generation

2 Ansichten (letzte 30 Tage)
Abhimanyu
Abhimanyu am 18 Mär. 2014
Beantwortet: Tim McBrayer am 18 Mär. 2014
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.

Antworten (1)

Tim McBrayer
Tim McBrayer am 18 Mär. 2014
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) .

Kategorien

Mehr zu Code Generation finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by