Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21615 Discussions

Initialization Altsyncram

Altera_Forum
Honored Contributor II
4,207 Views

Hi, 

 

I would like to reload an initialization on an Altsyncram. 

 

More precisely, I initialize the RAM with a .mif during the built in Quartus II and during the simulation (NCsim), I want to reload the .milf, but I don't know the good signals to force in order to do again the initialization process.  

 

Someone can help me? 

 

thanks
0 Kudos
10 Replies
Altera_Forum
Honored Contributor II
2,552 Views

you cannot re-initialise a ram during simulation or runtime.

0 Kudos
Altera_Forum
Honored Contributor II
2,552 Views

Hi Tricky,  

 

Are you shure? the initialization is doing with a process in the altsyncram architecture, don't you think that it will be possible to reload the process (the comment say : "initialize and update the contents")? 

 

 

-- This process initializes and updates the memory content in the RAM accordingly 

MEMORY: process (i_read_flag_a, i_write_flag_a, i_read_flag_b, i_write_flag_b, default_val, i_reread_flag_a, i_reread_flag_b, i_reread_flag2_a, i_reread_flag2_b)
0 Kudos
Altera_Forum
Honored Contributor II
2,552 Views

You cant do it, because you cannot do it in hardware. You cannot re-initialise a ram or reset it. You have to write a bit of code to do it manually if you want to do it. 

The code you're quoting (that I cannot find) will be for the simulation model only.
0 Kudos
Altera_Forum
Honored Contributor II
2,552 Views

I found the code. 

If you look at the code, you'll see it can only ever run initialisation once, because the need_init_var variable gets set to false after initialisation. It starts as true and is never ever again set to true.
0 Kudos
Altera_Forum
Honored Contributor II
2,552 Views

Thank you. 

 

Just a last precision, I just wont to load the .mif for the simulation, I dont wont to modify my HW, the aim is to load a context in simulation saved with In-memory system in a .mif and continue the execution virtually. 

 

And in order to do that I think to Force the re-initialization just in simulation with force command. 

 

But I have to find a new way... 

 

Thank you ;)
0 Kudos
Altera_Forum
Honored Contributor II
2,552 Views

and just a thing,  

 

When you reload the initialization process, there is this declaration  

 

variable need_init_var : boolean := true; 

 

So each time you enter in the initialization process, need_init_var is set to true... No?
0 Kudos
Altera_Forum
Honored Contributor II
2,552 Views

The process is only entered at the start of simulation. A process is not a function that can be re-run whenever you like. It starts at the beginning of the sim and loops forever. If it has a sensitivity list, each loop is triggered when one of the signals in the list changes. So all variables are initialised at time zero only.

0 Kudos
Altera_Forum
Honored Contributor II
2,552 Views

 

--- Quote Start ---  

Thank you. 

Just a last precision, I just wont to load the .mif for the simulation, I dont wont to modify my HW, the aim is to load a context in simulation saved with In-memory system in a .mif and continue the execution virtually. 

And in order to do that I think to Force the re-initialization just in simulation with force command. 

But I have to find a new way... 

Thank you ;) 

--- Quote End ---  

 

 

Are you asking how you initialise a ram with a MIF for a simulation? 

 

If you generate the ram with the megawizard I think there's a step to select an initialisation file. 

 

If you've inferred the ram I'm not sure if you can initialise it with a mif. 

 

Nial.
0 Kudos
Altera_Forum
Honored Contributor II
2,552 Views

Hi Nial, 

 

I know how to initialise a RAM during the creation with Megawizard, my problem is different I will try to explain clearly :  

 

1- RAM initialization with .mif during the megawizard creation 

 

2- place & route and FPGA running 

 

3- save the new data RAM in an other .mif thanks to In-system memory 

 

4- How can I say to the simalution model to select the second .milf to initialise my RAM and start my simulation with the new data 

 

In the simulation model, the init file is declare as a generic and is pointing on the first .milf, it's not possible to force it (with FORCE or DEPOSIT command) in a tcl script in order to consider the second .milf as the good initialization file. 

 

I find a nex method wich consist in adding a RAM initialiser (megawizard IP) in order to reinitialise as I want the RAM, but I think that it's not a good solution because I need an Initializer for each RAM...
0 Kudos
Altera_Forum
Honored Contributor II
2,552 Views

 

--- Quote Start ---  

 

4- How can I say to the simalution model to select the second .milf to initialise my RAM and start my simulation with the new data 

 

--- Quote End ---  

 

 

I think this is really a Modelsim question: 

 

What I have done in the past is something like this: 

 

1. leave the original .MIF alone 

2. when the simulation starts, when the memory comes out of reset, the simulation will be initialized with your original .MIF file. 

3. use Modelsim "when" statement to wait for the memory to be out of reset 

4. use Modelsim "mem load" statement to override the contents of the memory with data from your 2nd .MIF file. 

 

Something like this in a Modelsim TCL script (I use hex files): 

 

when "$TOP/reset_n == 1" { echo "out of reset, loading new memory contents" # # Initialize the onchip regload table mem load -i onchip_memory2_0.dat -format hex /test_bench/DUT/the_onchip_memory2_0/the_altsyncram/mem_data }
0 Kudos
Reply