Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
15474 Discussions

How do you initialize a ROM for simulation?


I am using a 1-Port ROM in a max 10 device. When I configured the IP I selected and generated an intel hex file for memory content data. But during simulation the values are all 0. Is there a way to initialize a ROM for simulation like we do for UFM?

0 Kudos
3 Replies
New Contributor III

Hi KLohr!


First of all, I would like to recommend using *.mif file instead of hex file for simulation of initial content in ROM.


Hope that helps.



Best regards,



OK, so I switched to using *.mif file and I still get all 0's in my simulation. Any further ideas? The ROM .v file has the following line in it. But it doesn't seem to be looking at it:


altsyncram_component.init_file = "lookuptable.mif",


Valued Contributor II

Are you using the tool generated compile/simulation script - msim_setup.tcl ? If not, then copy the hex/mif file to the simulation directory from where you invoke modelsim and then run the simulation.


If using the msim_setup.tcl script, there's a section in the script that does the file copy for all memory init files.. you will have to include your ROM hex/mif file in that section and then start the compile/simulation using that script.


Here's what the file copy part of script looks like (msim_setup.tcl)

alias file_copy { echo "\[exec\] file_copy" file copy -force $QSYS_SIMDIR/submodules/nios_timer_system_nios_cpu_cpu_ociram_default_contents.dat ./ file copy -force $QSYS_SIMDIR/submodules/nios_timer_system_nios_cpu_cpu_ociram_default_contents.hex ./ file copy -force $QSYS_SIMDIR/submodules/nios_timer_system_nios_cpu_cpu_ociram_default_contents.mif ./ file copy -force $QSYS_SIMDIR/submodules/nios_timer_system_nios_cpu_cpu_rf_ram_a.dat ./ file copy -force $QSYS_SIMDIR/submodules/nios_timer_system_nios_cpu_cpu_rf_ram_a.hex ./ file copy -force $QSYS_SIMDIR/submodules/nios_timer_system_nios_cpu_cpu_rf_ram_a.mif ./ file copy -force $QSYS_SIMDIR/submodules/nios_timer_system_nios_cpu_cpu_rf_ram_b.dat ./ file copy -force $QSYS_SIMDIR/submodules/nios_timer_system_nios_cpu_cpu_rf_ram_b.hex ./ file copy -force $QSYS_SIMDIR/submodules/nios_timer_system_nios_cpu_cpu_rf_ram_b.mif ./ file copy -force $QSYS_SIMDIR/submodules/nios_timer_system_system_RAM.hex ./ }

 The last line in that is what I added in after generating the NIOS SW code that resides in the on-chip RAM. What this line does is copy the generated hex file to the simulation folder from where the simulator can pick it up during simulation.