HDL Coder Error. Undefined function or variable. The first assignment to a local variable determines its class.
4 次查看(过去 30 天)
显示 更早的评论
good day. im trying to convert my code to verilog using hdl coder but i encounter multiple errors with the same description, "Undefined function or variable. The first assignment to a local variable determines its class." can anyone help me resolve my problem? btw my input is Gen1 which is supposed to be the image captured by our camera.thank you
here is my code
function [ Y ] = Try( Gen1 )
[rows, columns, numberOfColorBands] = size(Gen1)
if numberOfColorBands > 1
grayG1 = Gen1(:, :, 2);
end
BinG1 = grayG1 > 200;
CanEdG1=imcomplement(BinG1);
[nonZeroRows nonZeroColumns] = find(CanEdG1);
topRow = min(nonZeroRows(:));
bottomRow = max(nonZeroRows(:));
leftColumn = min(nonZeroColumns(:));
rightColumn = max(nonZeroColumns(:));
CrpdG1 = CanEdG1 (topRow:bottomRow,leftColumn:rightColumn);
mPadded = padarray(CrpdG1, [125, 125]);
midx=ceil((size(mPadded,1)+1)/2);
midy=ceil((size(mPadded,2)+1)/2);
K=50;
x2=zeros([size(mPadded,1) size(mPadded,2)]);
y2=zeros([size(mPadded,1) size(mPadded,2)]);
for i=1:size(mPadded,1)
x=i-midx-K;
for j=1:size(mPadded,2)
%Cartesian to Polar co-ordinates
[theta1,rho1]=cart2pol(x,j-midy+K);
phi=theta1+(rho1/K);
%Polar to Cartesian co-ordinates
[l,m]=pol2cart(phi,rho1);
x2(i,j)=ceil(l)+midx;
y2(i,j)=ceil(m)+midy;
end
end
%The result may produce value lesser than 1 or greater than the image size.
x2=max(x2,1);
x2=min(x2,size(mPadded,1));
y2=max(y2,1);
y2=min(y2,size(mPadded,2));
for i=1:size(mPadded,1)
for j=1:size(mPadded,2)
Y(i,j,:)= mPadded (x2(i,j),y2(i,j),:);
end
end
end
0 个评论
回答(1 个)
Tim McBrayer
2015-9-25
What variables does the issue occur with? By inspection you do not define grayG1 if numberOfColorBands <= 1. Running the code in MATLAB interactively also shows that it fails due to this reason.
HDL Coder needs code that fits the expected idiom for HDL translation. One immediate issue is that you will probably never want to transfer an entire image in a single input variable; FPGAs simply do not have that many IO pins, for any decent sized image. The typical way of working with images is to stream the image in pixel by pixel, storing it in a persistent variable if desired.
In addition, functions like 'imcomplement' aren't supported for HDL code generation. The full list of HDL-supported functions are in the documentation:
web(fullfile(docroot, 'hdlcoder/ug/functions-supported-for-hdl-code-generation-alphabetical-list.html'))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 HDL Coder 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!