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 Center および File ExchangeCode Generation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by