FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
6343 Discussions

Initialization file when infer a RAM IP

XCui0
Beginner
698 Views

Hi,

 

I am using VHDL code to infer a RAM IP of stratix 10. There are two choices to initialize RAM: use a function as provided by the VHDL template, or use attribute as shown in following:

type mem_t is array(0 to 255) of unsigned(7 downto 0);

signal ram : mem_t;

attribute ram_init_file : string;

attribute ram_init_file of ram :

signal is "my_init_file.mif";

 

My problem is that the initialization file is optional. Before we set the ip parameter of "init_file" to "unused" when we don't want a initialization file. Now we are moving to VHDL to infer a RAM block. But "unused" doesn't work for the attribute above. It has to be an effective file name with the attribute. Is there any solution for this one?

 

Thanks,

Xin

 

 

0 Kudos
7 Replies
sstrell
Honored Contributor III
407 Views

I don't understand. If you don't want to initialize the RAM, simply don't include the attribute in your code.

 

#iwork4intel

0 Kudos
XCui0
Beginner
407 Views

Hi,

 

We use the RAM as a generic_ram in our project. And the initialization file is optional depends how the upper layer uses it. And we also have other project use the generic_ram as well which is on Arria 10. They are still using the old generic_ram which is not inferring RAM with VHDL, but setting ip parameters of RAM IP. They have the option to use or not use initialization file. For the compatibility, we also need this option.We are trying to use inferring RAM because this method is device independent and parameters independent, and it is easier to maintain when we move from device to another, such as the situation we have now is moving from Arria 10 to Stratix 10, there are a lot of extra work to update the device related primitives. Please let me know if you have any idea.

 

Thanks,

Xin

0 Kudos
sstrell
Honored Contributor III
407 Views

The only thing I can think of would be if you could make the attribute conditional. Google brought up this though it's not clear if it works or not and I don't know if it would synthesize in Quartus:

 

https://stackoverflow.com/questions/17492197/vhdl-conditional-attribute-declaration-depending-on-a-generic

 

That might give you a starting point.

 

#iwork4intel

0 Kudos
XCui0
Beginner
407 Views

Hi SStrell,

 

Thanks a lot for you recommendation. The problem for the method provided by the link is that the attribute only works inside the scope of generate. That means I need to repeat my generic_ram twice for with init_file and without init_file, and also I have to declare my data type and ram signal inside the generation, twice. My code is pretty long now, because I have all ram function in one file, such as single/dual port, single/dual clock, with/without byte enable, mixed ports or non mixed ports. Upper level uses different generic settings to choose the function of ram. So, it seems not a good solution for me. Thank you anyway. Please let me know if you have other ideas.

 

Thanks,

Xin

0 Kudos
CheePin_C_Intel
Employee
407 Views

Thanks Steven for the guidance.

 

Hi Xin,

 

As I understand it, Quartus will expect you to specify the mif file whenever you specify the ram_init_file attribute. The current available workarounds would be as discussed above by Steven:

 

  1. Use RAM IP
  2. Use VHDL infer RAM but no specify the init_file attribute
  3. Use the conditional attribute

Sorry for the inconvenience.

 

0 Kudos
XCui0
Beginner
407 Views

@cheepinc_Intel​ , @sstrell​ 

 

Thanks a lot for your help. It is good to know that a valid .mif file is required when attribute is used. Now we decide use a workaround to give a default .mif file when the generic of init_file is set to "UNUSED", and give the init_file otherwise.

 

Xin

0 Kudos
CheePin_C_Intel
Employee
407 Views

Hi Xin,

 

Thanks for your update. I would set this case to close-pending at this moment. Please let me know if there is any concern. Thank you.

0 Kudos
Reply