I have a multi-dimensional array:
logic [7:0] memory[1:0][1:0];
and a comma-separated file.txt:
1,2
3,4
I am not able to load this file with $readmemh:
initial
begin
$readmemh("file.txt", memory);
end
Could you suggest a solution?
logic [7:0] mem [1:0][1:0]
For the above 4 elements array each of 8 bits. Define the mem.dat file as follows
01 02
03 04
Then read the file in one shot using readmemh
initial
begin
$readmemh("mem.dat", mem);
end
readmemfiles can only contain white space, comments, addresses and/or numbers (either binary forreadmembor hex forreadmemh). So, to separate values, just use spaces and/or new lines. See section 21.4 of the 2012 LRM.