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: 
Instructor
Instructor
8,321 Views
Registered: ‎08-14-2007

Error initializing memory using $readmemh, Xst:2319 - bug?

I struggled with this for a while but reached an answer by trial and error:

 

I inferred a 32 x 8 RAM using a simple single-port asynchronous RAM template from

the XST manual.  I initialized it with a $readmemh statement in an initial block.  So

far so good.  During the synthesis I got:

 

WARNING:Xst:2319 - "../../rtl/fc34_top.v" line 1069: Signal rb_ram in initial block is partially initialized. The initialization will be ignored.

 

Here's the line in question:

 

  $readmemh ("rb_mem_init_b.hex",rb_ram); // initialize readback from a file

 

which is inside an initial block.

 

The problem is that the ram is 32 x 8 and I had in my file 32 2-digit hex values separated by whitespace

as follows:

 

 05 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
11 22 33 44 55 66 77 88

 

so the ram should be completely initialized, right?

 

I tried adding a few extra lines to see if XST needed extra bytes.  No good.  Finally I

placed each value on a separate line like:

 

05
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
11
22
33
44
55
66
77
88

 

This worked!  However I would have expected the original file to work also.  In my Verilog

reference manual it says that the data entries in the file to be read by $readmemh should

be "separated by whitespace", not specifically newlines.  This seems to be a bug in XST.

I would also consider the behavior of not allowing partial initialization to be a bug as well.

Obviously not initializing the ram at all, which ends up causing the ram to come up all

zeroes after translation, is no closer to matching the simulation result than initializing

the requested portion of the ram and leaving the rest zero or any other value.

 

Just my 2 cents,

 

Gabor

-- Gabor
0 Kudos
3 Replies
Voyager
Voyager
8,312 Views
Registered: ‎08-30-2007

Re: Error initializing memory using $readmemh, Xst:2319 - bug?

I've found that XST barely supports $readmemh.  Want to add comments to your file?  It won't

work.  Have multiple data items per line?  That won't work.

 

It really is VERY picky about it's format, and, if it fails, it only puts a warning message in the

.syr file, not an ERROR.  So, if you don't closely examine the .syr file, you might not

notice that synthesis is actually incorrect.

 

 

I did a project that had a double buffered ram that I wanted to initialize half of.  XST couldn't

handle that - I had to make the file exactly the same size as the memory.

 

John Providenza

0 Kudos
Instructor
Instructor
8,298 Views
Registered: ‎08-14-2007

Re: Error initializing memory using $readmemh, Xst:2319 - bug?

I have also seen from other posts that XST won't accept addresses in the

data file, either.  This might be a side-effect of the inability to deal with

partial initialization.  In any case it seems to be a bug.  The least Xilinx could

do would be to document the acceptable data file format.  The XST manual

doesn't mention the file format at all.

-- Gabor
0 Kudos
Voyager
Voyager
8,292 Views
Registered: ‎08-30-2007

Re: Error initializing memory using $readmemh, Xst:2319 - bug?

Yes, Xilinx should document the $readmemh limitations.

 

It's sad that probably 10 to 20 lines of C code would properly handle this function.

 

John Providenza

0 Kudos