Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16619 Discussions

Efficiently Populating .mif File

Altera_Forum
Honored Contributor II
1,053 Views

Hi, this is my first post so I hope it is in the right section. I want to populate a .mif file with samples corresponding to one complete cycle of a sine wave. I generate the samples in matlab. At the moment I have 256 samples and I initially just wrote them into the .mif manually. Clearly this is rather tedious and will become more so since I want to include many more samples. Does anyone know of a more efficient means of achieving this?

0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
314 Views

Use Matlab to wite mif: 

 

fid = fopen('filename.mif','w'); 

fprintf(fid,'--MIF data generated by MATLAB\n'); 

fprintf(fid,'--Date: %s \n\n', date); 

fprintf(fid,'WIDTH=16;\n'); 

fprintf(fid,'DEPTH=256;\n'); 

fprintf(fid,'ADDRESS_RADIX=UNS;\n'); 

fprintf(fid,'DATA_RADIX=DEC;\n'); 

fprintf(fid,'CONTENT BEGIN\n'); 

for k = 1:256 

fprintf(fid,'%i : %i;\n',k-1,data(k)); 

end 

fprintf(fid,'END;'); 

fclose(fid); 

 

 

***************** 

you can also copy a column and paste to MIF in Quartus
0 Kudos
Altera_Forum
Honored Contributor II
314 Views

That is fantastic kaz, I just tried it and it worked perfectly. Thank you so much for your help. :D

0 Kudos
Reply