dynamically created blockRAM contents?

Jan 05, 2007 5 Replies

I have some Verilog code that generates an array of blockRAMs to any dimensions that I want. For example, if I set LENGTH=3 and HEIGHT=4 then 12 blockRAMs get synthesized. I have a separate script written in Ruby that creates the initial blockRAM contents according to the position of each blockRAM in the array. What I'd like to do is be able to pass in the blockRAM init parameters dynamically as each blockRAM is generated.



I'm looking for suggestions on how to do this. Can XST execute and interact with scripts from the command line?



If you use VHDL, you can initialize block RAMs during synthesis. Check the "Initializing RAM" section in XST User Guide for examples.

Cheers, Jim

formatting link

matteo wrote:

I can infer blockRAMs and initialize their contents with a file using the $readmemh system task from an initial block. The problem now is how do I dynamically load a different file based on the parameters that get passed from an upper module? The syntax is

initial $readmemh("data.txt",Mem,0,7);

where 0 is the start address and 7 would be the end address if the depth was 8. Say I have a set of files for different blockram contents: data0.txt data1.txt data2.txt

the # comes in as a parameter. Is there a way that I can convert it to a string?

Matt

Does this help?

formatting link
Probably not, but just checking. Cheers, Syms.

Is there some reason why the code that generates the initial contents is written in Ruby? More to the point, is there some reason that this Ruby program can not be converted to VHDL or Verilog bundled up as a function that will return the memory contents?

Kevin Jennings

What I've found is that in Verilog, what gets passed in as module parameters has to be a constant. I wanted to use genvar's but that is not allowed. The workaround was to write another Ruby script that would generate the Verilog code itself. Instead of using the generate statement I pre-generate each module with Ruby. This creates a large Verilog file but the parameters are now constant and the synthesis tool is happy.

messagenews: snipped-for-privacy@51g2000cwl.googlegroups.com...

code that generates the initial contents is

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required