DUT 2-dimensional memory read using $writememh is not working

I’m stuck with an issue while reading a DUT 2-dimensional memory via backdoor using $writememh.
I’m trying to read a DUT 2-dimensional memory via backdoor using $writememh. But it’s not working and I’m getting junk data.

Syntax used: $writememh(“rtl_memory_hex.txt”,DUT.mem.MEMORY);

I even tried with the below syntax by giving start address & end address, but no use, still getting junk data instead of actual data.

Syntax used: $writememh(“rtl_memory_hex.txt”,DUT.mem.MEMORY,32’d0,32’d1023);

NOTE : In both of the above scenarios, I can see my actual data in dump. But in text file, I’m getting junk data.

NOTE: Here, MEMORY is a 2-dimensional array, and in each cell 136-bit data is written/stored and we are trying to read that 136-bit data, not address.

Whereas, when I try to read from a 1-dimensional array, it is working fine.

Syntax : $writememh(“rtl_memory_hex.txt”,DUT.mem.mem);

In reply to SV_UVM_Learner:

I am confused by your terminology. $writemem dumps a memory to a text file. What is it that you are reading and with what command?

What is the declaration of your memory?

Maybe try with an example of a much smaller 2-D memory where you can show us the entire contents and the text file that it dumps.

Hi Dave,

Thanks or your reply.
Yes, we are trying to read from DUT memory using $writememh and dumping that into a text file for later comparison.
Our AXI master VIP will send write transactions to DUT & all those transactions gets stored in this memory. As per UVM, we are doing comparison by sending data from both AXI WRITE & READ monitors to the UVM scoreboard. This is a level-1 check and it is already PASSING in our scenario.

For level-2 check, we want to read data from DUT memory and compare it with our write data from AXI VIP(by doing file comparisons). I’ve stored all data sending from AXI VIP into expected_file.txt. But when trying to read from memory using $writememh, I’m facing issue as mentioned.

declaration of our 2-dimesional memory is as follows :
reg [136:0] MEMORY [255:0][3:0];
NOTE : Here, 136, 255 & 3 are declared as parameters

declaration of our 1-dimesional memory is as follows :
reg [136:0] mem [1023:0];
NOTE : Here, 136, 1023 are declared as parameters

For 2-dimesional memory, I can see my actual data in the dump, but I’m always getting junk data into text file instead of actual data.
Syntax used: $writememh(“rtl_memory_hex.txt”,DUT.mem.MEMORY);

Whereas, when I try to read memory from a 1-dimensional array and dump into a text file, it is working fine.
Syntax : $writememh(“rtl_memory_hex.txt”,DUT.mem.mem);