| |
ILA是VIVADO下的一个DEBUG- IP,类似于片上逻辑分析仪,通过在RTL设计中嵌入ILA核,可以抓取信号的实时波形,帮助我们定位问题。
write_hw_ila_data -csv_file wave [current_hw_ila_data] 保存的.ila格式的包,解压后,数据在.csv文件中
%% Open the Text File for Reading
InputFile = 'waveform.csv';
fid = fopen(InputFile,'r'); % Open text file
C = textscan(fid,'%s','delimiter','\n','headerlines',1);
fclose(fid);
disp(C); %{131072x1 cell}
len = length(C{1});
%% Fetch Data from ILA File
for k = 1:1:len
% k
lenofcell = length(C{1}{k});
% disp(lenofcell);
% disp(data(k));
% disp(C{1}{k});
% disp(C{1}{k}(1,lenofcell-8:lenofcell-3));
% data(k) = hex2dec(C{1}{k}(1,lenofcell-8:lenofcell-3));
% disp(data(k));
% disp(dec2hex(data(k),6));
% Bit and operation to take the lowest bit of data
% comp1(k) = bitand(data(k),a);
% bitshift(A,k) returns A shifted to the left by k bits,
% equivalent to multiplying by 2k.
% comp2(k) = bitand(bitshift(data(k),-1),a);
% i = 1+floor(k/2);
i = k;
% disp(C{1}{k}(1,lenofcell-62));
% class(C{1}{k}(1,lenofcell-64))
comp1(i) = str2num(C{1}{k}(1,lenofcell-2)); % sdm_out1
% disp(comp1(i));
% disp(C{1}{k}(1,lenofcell-60));
comp2(i) = str2num(C{1}{k}(1,lenofcell)); % sdm_out2
% disp(comp2(i));
end;
%% Output Data to File
OutputFile = strcat('SDM_OUT',InputFile(length(InputFile)-6:length(InputFile)-4));
fid = fopen(OutputFile,'wt'); %写入文件路径
m = N;
n = 2;
for i=1:1:m
for j=1:1:n
if j==n
fprintf(fid,'%g\n',comp2(i));
else
fprintf(fid,'%g\t',comp1(i));
end
end
end
fclose(fid);
% disp('OutputtoFile is over!');