Community
cancel
Showing results for 
Search instead for 
Did you mean: 
KLohr
Novice
591 Views

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
IDeyn
New Contributor II
80 Views

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,

Ivan

KLohr
Novice
80 Views

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",

 

Abe
Valued Contributor II
80 Views

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.

Reply