UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor clim2
Visitor
12,036 Views
Registered: ‎02-25-2011

Initializing BRAM via CoreGen File Size Problem

Jump to solution

Hi,

 

What I would like to do is store data of a single 252x316 8bit gray scale image in BRAM. Thus the total usage should be ~80KB but I am having problems with the file sizes.

 

Here is my current flow for initializing BRAM.

 

1. Using Matlab, read in AVI file and select a frame

2. Write the pixel values into a text file separated by commas (using fprintf function)

3. Modify the text file to fit the COE specifications

    i.e: memory_initialization_radix = 10;

          memory_initialization_vector = pixel1,pixel2,...,pixelN;

4. Using CoreGen's Block Memory Generator (v3.3) initialize the core using the converted text file from step 3

5. Generate the core (blk_mem_gen.xco)

 

There's no problem with these steps, it work fine however I noticed that blk_mem_gen.ngc is ~306KB which is much larger than the expected 80KB.I traced the file size back to the text file generated in step 2; the data written is in ASCII format (8 bits per character). I've tried using Matlab's fwrite function which writes raw data (8 bits per integer) into a binary file with COE specifications and loaded it into the Block Memory Generator and found that the generator was unable to read the file.

 

Here are my list of questions:

1. Does COE files have to be ASCII (or human readable) format?

2. Even though I specified the core to be Single Port ROM (width = 8 bit, depth = 79632) why is the NGC file so large (306 KB)?

3. Is there a way to initialize the BRAM with just raw binaries and if so, how would I read it back?

 

 

Thank you!

0 Kudos
1 Solution

Accepted Solutions
Teacher eteam00
Teacher
8,908 Views
Registered: ‎07-21-2009

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

Can you summarise for us, please, your intended usage of BRAM.  In other words, how many 18K and 36K BRAM blocks do you think your design should be using?  It would be even more helpful if you listed the "configurations" of the BRAMs you are using (e.g.  2Kx16, 4Kx24, etc.)

 

If I understand you correctly, the synthesised design is using more BRAM blocks than you expect.  Is this correct?

 

P.S.  Do you understand that the BRAM parcel increment is 18Kbit?  If you use less than 18Kbit for a single purpose, you consume the entire 18Kbit parcel, and the "Design Summary" statistics reflect this.  If you use more than 18Kbit (for example, 20Kbit), you will be using an entire 36Kbit BRAM (or more).

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
12 Replies
Xilinx Employee
Xilinx Employee
12,021 Views
Registered: ‎11-28-2007

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution
The NGC file contains the netlist for the BRAMs in addition to the initialization values. Anyway, why do you care about the size of the NGC file?
Cheers,
Jim
0 Kudos
Visitor clim2
Visitor
11,933 Views
Registered: ‎02-25-2011

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

Hi Jim

 

Thank you for responding.

 

My main concern is that think I am initializing the BRAM with 80KB worth of data however in ISE after synthesis, I'm using around 200KB.

 

Would you mind telling me how COE files are being used in the Block Memory Generator? I would assume that CoreGen parses the COE file and store the raw binary data into BRAM but it doesn't seem to do that. Please explain how COE files are being used.

 

Thank you so much for your help!

0 Kudos
Xilinx Employee
Xilinx Employee
11,917 Views
Registered: ‎11-28-2007

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

Why do you want to know whether or not the BRAM initialiazation data are stored as binray or ASCII format in NGC? I wouldn't worry about a couple hundred KBytes of disk space these days as you can get tera bytes hard drive for a couple of hundred dollars.

 


@clim2 wrote:

Hi Jim

 

Thank you for responding.

 

My main concern is that think I am initializing the BRAM with 80KB worth of data however in ISE after synthesis, I'm using around 200KB.

 

Would you mind telling me how COE files are being used in the Block Memory Generator? I would assume that CoreGen parses the COE file and store the raw binary data into BRAM but it doesn't seem to do that. Please explain how COE files are being used.

 

Thank you so much for your help!


 

Cheers,
Jim
0 Kudos
Teacher eteam00
Teacher
11,909 Views
Registered: ‎07-21-2009

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

I wouldn't worry about a couple hundred KBytes of disk space these days as you can get tera bytes hard drive for a couple of hundred dollars.

Jim,

 

The cost range you describe may have been accurate when you woke up this morning.  However, it is afternoon now, and prices have apparently dropped.

 

1TB internal drives are now selling for under $65 US, including shipping to USA addresses.

2TB internal drives are now selling for under $100 US, including shipping to USA addresses.

 

By tomorrow morning, this post will no doubt be out of date.

 

Having said that, I wonder if the original post was expressing concern over configuration image size rather than .NGC file size.  Does specifiying the start-up contents of BRAM increase the configuration data set size (assuming uncompressed bitstream file) ?  Do the nominal configuration bitstream sizes listed in the various Configuration User Guide docs account for BRAM initialisation values?

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Visitor clim2
Visitor
11,890 Views
Registered: ‎02-25-2011

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

Hi Jim,

 

Here's why I worry about very few KBs. Currently I have 1 frame in my BRAM initialization which is supposed to be ~80KB. Including my buffers /FIFOs in my core, I expect the BRAM to be ~160 KB. I stuck with 10MB in my BRAM and unfortunately cannot increase the size to TBs.

 

I'm asking how CoreGen uses the COE file to initialize BRAM because ideally I'd like to fit a video. With 10MB worth of space, I expect to be able to fit 120 frames give or take 5 frames depending on how much space my core uses up. If each frame takes up 20 KB more than expected then I'll end up with 80% of what I expect to store

 

I understand that there are other ways of sending test images but the way I'm doing it for now is through BRAM initialization thus I would like to know more about how it is being initialized. I'm asking to understand how things work.

 

Thank you for your responses

0 Kudos
Historian
Historian
11,873 Views
Registered: ‎02-25-2008

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

 


@clim2 wrote:

Hi Jim,

 

Here's why I worry about very few KBs. Currently I have 1 frame in my BRAM initialization which is supposed to be ~80KB. Including my buffers /FIFOs in my core, I expect the BRAM to be ~160 KB. I stuck with 10MB in my BRAM and unfortunately cannot increase the size to TBs.

 

I'm asking how CoreGen uses the COE file to initialize BRAM because ideally I'd like to fit a video. With 10MB worth of space, I expect to be able to fit 120 frames give or take 5 frames depending on how much space my core uses up. If each frame takes up 20 KB more than expected then I'll end up with 80% of what I expect to store

 

I understand that there are other ways of sending test images but the way I'm doing it for now is through BRAM initialization thus I would like to know more about how it is being initialized. I'm asking to understand how things work.

 

Thank you for your responses


 

You might wish to use the Google and search for "xilinx coe file example." Or at least look at one you might have lying around.

 

Had you done this, you would have discovered that the file is simple ASCII text, which of course is not very efficient regarding storing binary data. So you can assume that the COE file will be larger than the data it holds.

----------------------------Yes, I do this for a living.
0 Kudos
Visitor clim2
Visitor
11,865 Views
Registered: ‎02-25-2011

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

Hi

 

I've already generated a COE file for the Block Memory Generator and everything works well. I know that the COE file is using ASCII. What I'm interested to know is how is the information being initialized in BRAM?

 

I'm not worried about the COE file, I'm interested in how the COE file is used to initialize the BRAM.

 

Is the COE file parsed in CoreGen so that only the raw binary data are stored in BRAM or is there something else going on? If CoreGen parses the COE file so that only the raw binaries are stored, do I see an expansion in the data?

 

Here's my process and what I expect to see

1. Generate COE file using Matlab

2. Generate Block Memory Generator Core and initialize it with data in COE file - I expect the resulting core to take up only 80KB

3. Program the FPGA with the generated core in step 2 with my core wrapped around it - I expect the BRAM usage to be ~2x 80KB to account for buffers

 

What I'm seeing however is ~20KB usage more of what I expect. If one was supposed to calculate the theoretical resource usage how does this relate to the actual resource usage?

 

Thank you

Chester

0 Kudos
Teacher eteam00
Teacher
11,863 Views
Registered: ‎07-21-2009

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

2. Generate Block Memory Generator Core and initialize it with data in COE file - I expect the resulting core to take up only 80KB

What does "resulting core to take up only 80KB" mean?

3. Program the FPGA with the generated core in step 2 with my core wrapped around it - I expect the BRAM usage to be ~2x 80KB to account for buffers

An init file (e.g. .COE) does not use BRAM, and doesn't affect BRAM or usage.  Would you please be specific:  what file size is affected by your BRAM intialisation?

What I'm seeing however is ~20KB usage more

What usage are you (not) describing?

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Visitor clim2
Visitor
11,861 Views
Registered: ‎02-25-2011

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

When I use ISE, at the end of synthesis, it tells me the % of BRAM used. I'm referring to that percentage.j

 

When I say, for example, I expect the resulting core to take up only 80KB, I'm expecting ISE to tell me that I used 80KB of BRAM. i.e:

Device Utilization Summary

[-]

Slice Logic Utilization                                  

Used  

Available

Utilization

Note(s)

Number of BlockRAM/FIFO

74

298

24%

 

    Number using BlockRAM only

74

 

 

 

        Number of 36k BlockRAM used

70

 

 

 

        Number of 18k BlockRAM used

6

 

 

 

    Total Memory used (KB)

2,628

10,728

24%

 

 

Theoretically if I just had a single frame in the Block Memory Generator and synthesized it, I expect the Total Memory used (KB) to be ~80KB.

I'm wondering how is the COE file being used in the Block Memory Generator and how does it initialize the BRAM?

 

If I had in my COE file

memory_initialization_radix = 10;

memory_initialization_vector=1,2,3,4,5;

 

And I synthesized it without any "wrappers", e.g 

 

module name( input clk, output data)

 

integer [2:0]  addra;

 

always@(posedge clk)

 addra<= addra +1;

 

blk_mem data

   .clk(clk),

  .addra(addra),

  .douta(data));

 

endmodule

 

I  now expect Total Memory used (KB) to be close to 40 bytes.  Is it safe to expect this? If not what should I expect?

 

Thank you hopefully this clear things up?.....I hope

 

Edit: Also if I made Block Memory Generator core to be a single port ROM with read width of 8bits and depth of 5.

A small correction: addra is restricted to < 6 but that's besides the main point. My main point is that if I simple just instantiate the core in the simplest way, what can I expect in terms of Total Memory used (KB)

Teacher eteam00
Teacher
8,909 Views
Registered: ‎07-21-2009

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

Can you summarise for us, please, your intended usage of BRAM.  In other words, how many 18K and 36K BRAM blocks do you think your design should be using?  It would be even more helpful if you listed the "configurations" of the BRAMs you are using (e.g.  2Kx16, 4Kx24, etc.)

 

If I understand you correctly, the synthesised design is using more BRAM blocks than you expect.  Is this correct?

 

P.S.  Do you understand that the BRAM parcel increment is 18Kbit?  If you use less than 18Kbit for a single purpose, you consume the entire 18Kbit parcel, and the "Design Summary" statistics reflect this.  If you use more than 18Kbit (for example, 20Kbit), you will be using an entire 36Kbit BRAM (or more).

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Historian
Historian
4,882 Views
Registered: ‎02-25-2008

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

 


@clim2 wrote:

Hi

 

I've already generated a COE file for the Block Memory Generator and everything works well. I know that the COE file is using ASCII. What I'm interested to know is how is the information being initialized in BRAM?

 

I'm not worried about the COE file, I'm interested in how the COE file is used to initialize the BRAM.

 

Is the COE file parsed in CoreGen so that only the raw binary data are stored in BRAM or is there something else going on?


 

 

It is parsed so that  yes, the raw binary data are stored in the BRAM.

 

 

 


 

If CoreGen parses the COE file so that only the raw binaries are stored, do I see an expansion in the data?

 


 

 

What does that mean?


 

 

 


 

Here's my process and what I expect to see

1. Generate COE file using Matlab

2. Generate Block Memory Generator Core and initialize it with data in COE file - I expect the resulting core to take up only 80KB

3. Program the FPGA with the generated core in step 2 with my core wrapped around it - I expect the BRAM usage to be ~2x 80KB to account for buffers


 

 

What do you mean, "account for buffers?"

 

LOOK AT THE FILE GENERATED BY MATLAB. WHAT IS THE SIZE OF THE MEMORY IT WANTS?

 

NB that BRAMs are a particular size, so unless the desired memory amount is modulo the native BRAM size, the tools have no choice but to bump up in depth and/or width to create a memory that meets the request.

 

----------------------------Yes, I do this for a living.
0 Kudos
Visitor clim2
Visitor
4,875 Views
Registered: ‎02-25-2011

Re: Initializing BRAM via CoreGen File Size Problem

Jump to solution

Hi Mr. Elkind

 

I would like to store test data in BRAM. At the time I was looking for the most simplest way to get test data into my core. I found that CoreGen had a Block Memory Generator core which does exactly what I wanted (simple initialization of memory with test data).

 

"P.S.  Do you understand that the BRAM parcel increment is 18Kbit?  If you use less than 18Kbit for a single purpose, you consume the entire 18Kbit parcel, and the "Design Summary" statistics reflect this.  If you use more than 18Kbit (for example, 20Kbit), you will be using an entire 36Kbit BRAM (or more)."

 

That was the answer I was looking for. Sorry I didn't know that BRAM worked the way you described it there.

 

Thank you so much for your patience and answers!

 

.....How do I kudos?...

0 Kudos