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

What's wrong with my .mif file

Altera_Forum
Honored Contributor II
5,342 Views

Hi, 

 

I'm trying to initialize a ROM with a .mif file. I'm doing this for the first time, so probably there is just a simple mistake in my file. 

I used this guide http://quartushelp.altera.com/15.0/mergedprojects/reference/glossary/def_mif.htm to create a MATLAB function, generating the .mif file from a Vector. 

 

When I try to run Analysis & Synthesis I get the error  

Error (127000): Can't read Memory Initialization File or Hexadecimal (Intel-Format) File ./memoryInit/HRTF_L_real_memory_init.mif for ROM instance ALTSYNCRAM. If the file exists, it is not in correct format.  

 

As the file definetively exists, I think there is an error in the generated .mif file, but I cant find it. This is the content of my file: 

 

-- Initializes Memory with real part of HRTF DEPTH = 128; WIDTH = 24; ADDRESS_RADIX = DEC; DATA_RADIX = DEC; CONTENT BEGIN 0 : 1453995; 1 : -407270; 2 : -1036098; 3 : 611439; 4 : 758496; 5 : -898662; 6 : -290369; 7 : 952990; 8 : -273384; 9 : -645373; 10 : 674711; 11 : 44172; 12 : -795250; 13 : 732454; 14 : 131981; 15 : -676438; 16 : 244137; 17 : 426225; 18 : -442342; 19 : -7580; 20 : 237441; 21 : -116884; 22 : 109939; 23 : -244708; 24 : 62768; 25 : 326625; 26 : -295678; 27 : -348030; 28 : 632600; 29 : -22360; 30 : -761058; 31 : 600332; 32 : 386669; 33 : -693439; 34 : 94945; 35 : 462130; 36 : -309804; 37 : -112644; 38 : 115880; 39 : 108653; 40 : -11007; 41 : -253252; 42 : 151222; 43 : 291637; 44 : -412082; 45 : -53376; 46 : 420135; 47 : -184003; 48 : -207262; 49 : 137134; 50 : 118460; 51 : -60077; 52 : -20043; 53 : 12417; 54 : -4027; 55 : 4579; 56 : -3210; 57 : 4502; 58 : -1979; 59 : 3468; 60 : -1226; 61 : 1857; 62 : -2058; 63 : 1855; 64 : 333; 65 : 1855; 66 : -2058; 67 : 1857; 68 : -1226; 69 : 3468; 70 : -1979; 71 : 4502; 72 : -3210; 73 : 4579; 74 : -4027; 75 : 12417; 76 : -20043; 77 : -60077; 78 : 118460; 79 : 137134; 80 : -207262; 81 : -184003; 82 : 420135; 83 : -53376; 84 : -412082; 85 : 291637; 86 : 151222; 87 : -253252; 88 : -11007; 89 : 108653; 90 : 115880; 91 : -112644; 92 : -309804; 93 : 462130; 94 : 94945; 95 : -693439; 96 : 386669; 97 : 600332; 98 : -761058; 99 : -22360; 100 : 632600; 101 : -348030; 102 : -295678; 103 : 326625; 104 : 62768; 105 : -244708; 106 : 109939; 107 : -116884; 108 : 237441; 109 : -7580; 110 : -442342; 111 : 426225; 112 : 244137; 113 : -676438; 114 : 131981; 115 : 732454; 116 : -795250; 117 : 44172; 118 : 674711; 119 : -645373; 120 : -273384; 121 : 952990; 122 : -290369; 123 : -898662; 124 : 758496; 125 : 611439; 126 : -1036098; 127 : -407270; END; 

 

Does anybody see an obvious mistake?
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
3,335 Views

The .mif file looks fine to me. I would re-generate the ROM core and re-select the .mif file when you do that. The path to the .mif file is placed as a parameter in the rtl file that is created when you generate the core, and it's that parameter that tells Quartus where to find the .mif file. I'm guessing the path or file name changed and Quartus can't find the file.

0 Kudos
Altera_Forum
Honored Contributor II
3,335 Views

try set address radix to unsigned(uns)

0 Kudos
Altera_Forum
Honored Contributor II
3,335 Views

Good point, kaz. I always use hex format so wouldn't have thought of that.

0 Kudos
Altera_Forum
Honored Contributor II
3,335 Views

Okay. I Changed the Radix to UNS. No change. Then I changed my MATLAB function to generate HEX address values and regenerated the ROM in Quartus and loaded the new .mif file in the ROM. Now the error changes to: 

Error (113025): Missing syntax END in the Memory Initialization File "HRTF_L_real_memory_init.mif"  

 

This is even more confusing, since there definitively IS an END in the .mif file. 

 

This is how it looks like now: 

 

-- Initializes Memory with real part of HRTF DEPTH = 128; WIDTH = 24; ADDRESS_RADIX = HEX; DATA_RADIX = DEC; CONTENT BEGIN 00 : 1453995; 01 : -407270; 02 : -1036098; 03 : 611439; 04 : 758496; 05 : -898662; 06 : -290369; 07 : 952990; 08 : -273384; 09 : -645373; 0A : 674711; 0B : 44172; 0C : -795250; 0D : 732454; 0E : 131981; 0F : -676438; 10 : 244137; 11 : 426225; 12 : -442342; 13 : -7580; 14 : 237441; 15 : -116884; 16 : 109939; 17 : -244708; 18 : 62768; 19 : 326625; 1A : -295678; 1B : -348030; 1C : 632600; 1D : -22360; 1E : -761058; 1F : 600332; 20 : 386669; 21 : -693439; 22 : 94945; 23 : 462130; 24 : -309804; 25 : -112644; 26 : 115880; 27 : 108653; 28 : -11007; 29 : -253252; 2A : 151222; 2B : 291637; 2C : -412082; 2D : -53376; 2E : 420135; 2F : -184003; 30 : -207262; 31 : 137134; 32 : 118460; 33 : -60077; 34 : -20043; 35 : 12417; 36 : -4027; 37 : 4579; 38 : -3210; 39 : 4502; 3A : -1979; 3B : 3468; 3C : -1226; 3D : 1857; 3E : -2058; 3F : 1855; 40 : 333; 41 : 1855; 42 : -2058; 43 : 1857; 44 : -1226; 45 : 3468; 46 : -1979; 47 : 4502; 48 : -3210; 49 : 4579; 4A : -4027; 4B : 12417; 4C : -20043; 4D : -60077; 4E : 118460; 4F : 137134; 50 : -207262; 51 : -184003; 52 : 420135; 53 : -53376; 54 : -412082; 55 : 291637; 56 : 151222; 57 : -253252; 58 : -11007; 59 : 108653; 5A : 115880; 5B : -112644; 5C : -309804; 5D : 462130; 5E : 94945; 5F : -693439; 60 : 386669; 61 : 600332; 62 : -761058; 63 : -22360; 64 : 632600; 65 : -348030; 66 : -295678; 67 : 326625; 68 : 62768; 69 : -244708; 6A : 109939; 6B : -116884; 6C : 237441; 6D : -7580; 6E : -442342; 6F : 426225; 70 : 244137; 71 : -676438; 72 : 131981; 73 : 732454; 74 : -795250; 75 : 44172; 76 : 674711; 77 : -645373; 78 : -273384; 79 : 952990; 7A : -290369; 7B : -898662; 7C : 758496; 7D : 611439; 7E : -1036098; 7F : -407270; END; 

 

It would be a real help if anyone knew a solution, since I'm not able to continue working without any data in the ROM...
0 Kudos
Altera_Forum
Honored Contributor II
3,335 Views

Okay, I found a solution: 

If I generate a blank text file in Quartus and copy the content of the MATLAB-generated .mif to this new file, then save it as HRTF_L_real_memory_init.mif, everything compiles without errors. 

I'm running Quartus on a linux machine and MATLAB on a Mac under OS X. On the Linux host, both files (the MATLAB generated and the Quartus generated) look exactly the same in gedit, however I'm not able to open the MATLAB generated .mif in the Quartus editor. Seems like MATLAB on my Mac generates a somehow wrong encoded textfile. As MATLAB is able to generate 25 different encoding schemes when saving text files, there should be a solution. But what encoding scheme is right for Quartus? 

 

these (http://de.mathworks.com/help/matlab/ref/fopen.html) are the supported encoded schemes (scroll down to "encodingIn")
0 Kudos
Altera_Forum
Honored Contributor II
3,335 Views

It seems as if I only found half of the solution. 

While Analysis & Synthesis works with the solution posted above, Simulation won't work - with nearly the same error as Analysis & Synthesis had before. I set up Modelsim Altera Edition with the native link feature - I wrote my own vhdl testbench and launch it via Tool > Run Simulation Tool > RTL Simulation, which worked fine until now. But now 

# ** Fatal: (vsim-7) Failed to open VHDL file "./memoryInit/HRTF_L_real_memory_init.mif" in r mode. # No such file or directory. (errno = ENOENT) # Time: 0 ps Iteration: 0 Process: /testbench_ols_fft_fading/dut/HRTF_Manager/HRTF_A_L_real/altsyncram_component/MEMORY File: /home/nt-lab/Software/Altera/modelsim_ase/linuxaloem/../altera/vhdl/src/altera_mf/altera_mf.vhd # Fatal error in Process MEMORY at /home/nt-lab/Software/Altera/modelsim_ase/linuxaloem/../altera/vhdl/src/altera_mf/altera_mf.vhd line 40268 #  

appears in the Modelsim window and 

Error (138003): Can't write incremental compilation assignments. Quartus Prime Settings File /home/ --PATH TO MY DATA --/Testbench_OLS_FFT_Fading.qsf is unwritable. Error (140001): Can't write LogicLock assignments. The Quartus Prime Settings File /home/ --PATH TO MY DATA --/Testbench_OLS_FFT_Fading.qsf is unwritable. Error (138003): Can't write incremental compilation assignments. Quartus Prime Settings File /home/ --PATH TO MY DATA --/Testbench_OLS_FFT_Fading.qsf is unwritable. Error (140001): Can't write LogicLock assignments. The Quartus Prime Settings File /home/ --PATH TO MY DATA --/Testbench_OLS_FFT_Fading.qsf is unwritable. Error (113025): Missing syntax END in the Memory Initialization File "HRTF_L_real_memory_init.mif" Error (113025): Missing syntax END in the Memory Initialization File "HRTF_L_real_memory_init.mif"  

in the Quartus Window. 

 

Is this really only an encoding error or something different?
0 Kudos
Altera_Forum
Honored Contributor II
3,335 Views

a common problem with modelsim mif search is that it follows the path set when mif was generated. This then gets wrong relative to modelsim folder. 

you can either put a copy of mif in modelsim folder or adjust the mif path to be same as that written in memory code
0 Kudos
Altera_Forum
Honored Contributor II
3,335 Views

Thanks kaz, that worked! 

 

Now I still need to know the right character encoding scheme to generate these files automatically, but that was the smallest of my Problems...
0 Kudos
Reply