Forum Discussion

obruendl's avatar
obruendl
Icon for New Contributor rankNew Contributor
9 months ago

RAM inference not working for initialized RAM

According to documentation RAM initialization should work in VHDL by simply adding an initialization value to the memory array.

https://www.intel.com/content/www/us/en/docs/programmable/683082/21-3/specifying-initial-memory-contents-at.html

However, In my code (see attached), this is not the case. Without initialization value (resp. with initializing all content to zero) the code infers 8kb RAM - so the syntax seems fine for RAM inference. As soon as I add any other initialization content than zeros, registers are inferred (not RAM).

I have attached my code containing both cases.

With line 109 uncommented, RAM inferrence works:

signal Mem_v : Data_t(Depth_g - 1 downto 0) := (others => (others => '0'));

With line 108 uncommented, RAM inferrence fails:
signal Mem_v : Data_t(Depth_g - 1 downto 0) := (0 => x"1234", 1 => x"5678", others => (others => '0'));


Why is RAM inference not working? What can I do to make it work?

18 Replies

  • JoE's avatar
    JoE
    Icon for New Contributor rankNew Contributor

    obruendl​: I had a similar problem today. In my design, multiple DPRAMs are instatiated using a "for ... generate" loop, similar to your example.

    Without initialization, the memories are inferred in RAM, but when i add an initialization function, only the MSB of these memories gets infered and the rest is implemented as registers.

    Modifying the code as suggested above is not a solution for me, because the number of memories depends on a generic in my design, so i need the generate loop.

    Then i found a solution: I added a separate entity for the DPRAM, including the initialization function and instantiated the DPRAM as component multiple times in the "for ... generate" loop. With this modification all memory bits were inferred in RAM without any problem.

    Maybe this could also be a solution for your project.

  • ShengN_altera's avatar
    ShengN_altera
    Icon for Super Contributor rankSuper Contributor

    Sorry for late reply. The enhancemnet request had been rejected by internal team