clear;
clc;
count = 1;
for num=pi/(1024):pi/(1024):2*pi
    x(count) = num;
    count = count + 1;
end
y = floor(sin(x)*127 + 127);
%plot(y);

%Make a .mif file
fileID = fopen('sine.mif','w');
%header required for Altera .mif file
fprintf(fileID,'-- Subscription Agreement, the Altera Quartus Prime License Agreement,\n');
fprintf(fileID,'-- the Altera MegaCore Function License Agreement, or other \n');
fprintf(fileID,'-- applicable license agreement, including, without limitation, \n');
fprintf(fileID,'-- that your use is for the sole purpose of programming logic \n');
fprintf(fileID,'-- devices manufactured by Altera and sold by Altera or its \n');
fprintf(fileID,'-- authorized distributors.  Please refer to the applicable \n');
fprintf(fileID,'-- agreement for further details.\n');
fprintf(fileID,'-- Quartus Prime generated Memory Initialization File (.mif)\n');
fprintf(fileID,'WIDTH=8;\n');
fprintf(fileID,'DEPTH=2048;\n');
fprintf(fileID,'ADDRESS_RADIX=UNS;\n');
fprintf(fileID,'DATA_RADIX=UNS;\n');
fprintf(fileID,'CONTENT BEGIN\n');
for count = 0:1:2047
    fprintf(fileID,'	%i	:	%i;\n',count,y(count+1));
end
fprintf(fileID,'END;');
fclose(fileID);