Wednesday, February 20, 2013

How to use coe file for initializing BRAM


   Normally we initialize all the memory locations in a BRAM to zero using the "Fill Remaining memory locations" option in core generator. But this article will tell you how to use coe file as an initialization vector. Follow the steps:
1) Create a BRAM of depth = 16 and read and write width = 8 bits.
2) Check the "Load Init File" under the "Memory Initialization" option. Also select the file named "bram_contents.coe".
3) Before clicking on the generate button create a new file named bram_contents.coe and paste the following contents into it:
memory_initialization_radix=10;
memory_initialization_vector=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16;
In the above text radix means the raidx of the data. I have written decimal data in the vector so my radix is "10". If you want to give the memory contents in binary form then change the coe file like this:
memory_initialization_radix=2;
memory_initialization_vector=0000,0001,0010,0011,0100,0101,0110,0111,1000,1001,1010,1011,1100,1101,1110,1111;
4) Now click on the generate button.

No comments: