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: 
Observer moshiko
Observer
1,477 Views
Registered: ‎01-08-2018

readmemh with string/parameter filename

Hi,

 

I would like to use readmemh within task/module where the filename comes from input string (to task) or as parameter (to module).

Both options pass xvlog and xelab. However, when using Vivado (2017.1) for simulation it gives me "fatal error" when using either of these options.  Only literal string of the filename works out.

 

Is there any way to pass filename as argument so that coding around memory initialization can be grouped into a task/module and only the filename is given as input/parameter?

 

-Moshe

0 Kudos
5 Replies
Scholar watari
Scholar
1,445 Views
Registered: ‎06-16-2013

Re: readmemh with string/parameter filename

Hi @moshiko

 

Could you show me more detail information or upload log file ?

0 Kudos
Observer moshiko
Observer
1,435 Views
Registered: ‎01-08-2018

Re: readmemh with string/parameter filename

Hi,

 

Attached an example of readmemh receiving filename as parameter + Error received from Vivado simulator when stepping over the readmemh call.

 

reg [DDRDATAW-1:0] ztlmem [9999:0];

module ztl_mem #(parameter FILENAME = "aaa.txt") (input en);
    integer ztladdr, i;
    always @(en)
         if (en) begin
             $readmemh(FILENAME, ztlmem, 0);
         end

endmodule

 

 

FATAL_ERROR: Vivado Simulator kernel has discovered an exceptional condition from which it cannot recover. Process will terminate. For technical support on this issue, please open a WebCase with this project attached at http://www.xilinx.com/support.

0 Kudos
Observer moshiko
Observer
1,399 Views
Registered: ‎01-08-2018

Re: readmemh with string/parameter filename

Hi,

 

Has anyone faced similar problem and maybe managed to find a workaround ?

 

Thanks,

-Moshe

0 Kudos
Scholar watari
Scholar
1,381 Views
Registered: ‎06-16-2013

Re: readmemh with string/parameter filename

Hi @moshiko

 

Would you use the following code ?

 

---------------------------------

reg [DDRDATAW-1:0] ztlmem [9999:0];

module ztl_mem #(parameter FILENAME = "aaa.txt") (input en);
    integer ztladdr, i;
    
    initial $readmemh(FILENAME, ztlmem, 0);

endmodule

---------------------------------

 

Best regards,

0 Kudos
Observer moshiko
Observer
1,369 Views
Registered: ‎01-08-2018

Re: readmemh with string/parameter filename

Hi,

 

I used the code below and still get the same fatal error.  (same code works if FILENAME is replaced by the literal "file.txt")

 

Besides, it would be better if I can load different files as simulation progresses, not only at initial time.

 

-Moshe

 

reg [DDRDATAW-1:0] ztlmem [99999:0];
module ztlload #(parameter FILENAME);

initial $readmemh(FILENAME, ztlmem, 0);

endmodule

ztlload #(.FILENAME("file.txt")) ztlload_i ();

 

0 Kudos