%Initialize constants and load register file
clc

delaynum = 2;
delay = delaynum;

fid_instr = fopen('binary\test01_add.txt.out');
instrfile = [];
while 1
    tline = fgetl(fid_instr);
    if ~ischar(tline),   break,   end
    for n = 1:length(tline)
        num(n) = str2num(tline(n));
    end
    instrfile = [instrfile; num];
end
fclose(fid_instr);

instrfile = instrfile';

%% gen r

r = zeros(32,32);

%for testing purposes, it is often more useful to initialize the register
%file with actual values

% for m = 1:32
%     a = dec2bin(m,32);
%     for n = 1:32
%         r(n,m) = str2num(a(n));
%     end
% end
% surf(r)
% view(2)
% shading interp
% axis square
% colormap gray
% colorbar
% saveas(gcf,'bittree.jpg')