cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Observer
Observer
833 Views
Registered: ‎09-05-2018

readmemh with concatenated string for file name

Jump to solution

I'm trying to use a string constant with the $readmemh statement in my system verilog testbench.  The Vivado (2018.2) simulator generates warnings that it cannot find the file.  If I explicitly define the file location it works.

Does not work:

const string saveDir = "C:/work/test_cases/test0";

$readmemh({saveDir,"/file.txt"}, file_data)

Also does not work:

const string saveDir = "C:/work/test_cases/test0";

$readmemh(sformatf({saveDir,"/file.txt"}), file_data)

Works:

$readmemh("C:/work/test_cases/test0/file.txt", file_data)

I've used $display to verify the concatenation is in fact producing the required directory/file string.  I have many $readmemh statements in my test bench and it would be nice to be able to quickly change the test directory by simply changing the value of 'saveDir'.  Is this a limitation in the Vivado simulator or system verilog, or am I doing something wrong?

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Observer
Observer
825 Views
Registered: ‎09-05-2018

Tried one more thing 5 minutes after posting my question and found that changing saveDir from a constant to a parameter solved the problem.

View solution in original post

0 Kudos
2 Replies
Highlighted
Observer
Observer
826 Views
Registered: ‎09-05-2018

Tried one more thing 5 minutes after posting my question and found that changing saveDir from a constant to a parameter solved the problem.

View solution in original post

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
803 Views
Registered: ‎05-22-2018

Hi @dblogicdesign ,

As the issue is resolved, do you have further queries on this? If not, please close this thread by marking it as accepted solution. 

Thanks,

Raj

 

0 Kudos