i am trying to convert matlab file to verilog file.but i got the error"HDL Code generation does not support 2D-matrices as function inputs."can anyone tell me how to rectify this error.

1 次查看(过去 30 天)
First, i have converted the matlab to embedded matlab by using functions.
This is my code
UPTO COLUMN PERMUTATION:
(I)MAIN CODE:
%key generation
maxpoints = 25;
N = 95;
a = 0;
b = 4;
rs = linspace(a,b,N);
M = 500;
for j = 1:length(rs)
r=rs(j);
x=zeros(M,1);
x(1) = 0.5;
a1=4-r;
for i=1:M
if (x(i)<=0.5 )
x(i+1)=mod(((r*x(i))/2+(a1*sin(pi*x(i)))/4),0.999);
else
x(i+1)=mod(((r*(1-x(i)))/2+(a1*sin(pi*(1-x(i)))/4)),0.999);
end
end
out{j} =x(end-maxpoints:end);
end
data = [];
for k = 1:length(rs)
n = length(out{k});
data = [data; rs(k)*ones(n,1),out{k}];
end
% h=plot(data(:,1),data(:,2),'k.');
op1=data(:,2).*95;
res=round(op1);
a =res;
[b,m1,n1] = unique(a);
[c1,d1] =sort(m1);
b = b(d1);
rckey=b;%final key
img = imread('lenacolor32.tif'); % Read image
%algorithm
actu1=permtest(rckey,img);
%output
actu1=permtest(rckey,img);
figure, imshow(actu1),title('Column permutation');
(II)FUNCTION:
%algorithm
function actu1=permtest(rckey,img)
red = img(:,:,1); % Red channel
% figure, imshow(red), title('red')
green = img(:,:,2); % Green channel
% figure, imshow(green), title('green')
blue = img(:,:,3); % Blue channel
% figure, imshow(blue),title('blue')
a = zeros(size(img, 1), size(img, 2));
% figure, imshow(a),title('a')
R = cat(3, red, a, a);
G = cat(3, a, green, a);
B = cat(3, a, a, blue);
% figure, imshow(img), title('Original image');
% figure, imshow(R), title('Red plane');
% figure, imshow(G), title('Green plane');
% figure, imshow(B), title('Blue plane');
% convert to vert plane
op=vertcat(R,G,B);
% figure, imshow(op),title('Vertical format');
%row perm
actu=zeros(size(op));
actu=op(:,:,:);
chang=zeros(size(actu));
chang=actu(:,:,:);
for i=1:1:length(rckey);
pos=rckey(i);
if(rckey(i)==0);
else
actu(i,:,:)=chang(pos,:,:);
end
end
% figure, imshow(actu),title('Row permutation');
% convert to horz plane
[r,c,n]=size(actu);
id=fix(r/3);
im1=actu(1:id,:,:);
im2=actu(id+1:2*id,:,:);
im3=actu(2*id+1:r,:,:);
op1=horzcat(im1,im2,im3);
% figure, imshow(op1),title('Horizontal format');
%colperm
actu1=zeros(size(op1));
actu1=op1(:,:,:);
chang1=zeros(size(actu1));
chang1=actu1(:,:,:);
for i=1:1:length(rckey);
pos=rckey(i);
if(rckey(i)==0);
else
actu1(:,i,:)=chang1(:,pos,:);
end
end
end

采纳的回答

Walter Roberson
Walter Roberson 2018-2-5
When you have a 2D matrix of input to HDL, you are requesting that the FPGA has as many pins as necessary to input all of those entries simultaneously. So for example for a 1024 * 768 RGB matrix you would need nearly 2.4 million pins. Clearly that is not feasible. So you need to reshape your data to a vector and stream the vector in through a limited number of pins until it is all in to the hardware; once through the pins, the hardware can reshape to 2D as needed for the calculations.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by