I want to read a data file and take the data in memory,
while using following
$readmemb("data.dat", memory); (memory is a register array)
modelsim giving following error
** Warning: (vsim-7) Failed to open readmem file "data.dat" in read mode.
and it is not reading the correct data.
Why this error is coming and what is the solution.contents of data.dat are :
this is the code . 1 thing here that code was working fine to me previously but now its not working . i wanted to know is there a problem in s/w shud i reinstall it ..
module readfile;
reg [7:0] memory[0:7];
integer i;
initial
begin
$readmemb("data.dat", memory);
for(i=0; i < 8; i = i + 1)
$display("Memory [%0d] = %b", i, memory);
Did the problem begin after you updated your ModelSim? Here are comments from various Release Notes:
Verilog Defects Repaired in 5.8e:
* A problem relating to $readmem resulted in memory leaks and large load times.
Verilog Defects Repaired in 6.0b:
* The system tasks $readmemh and $readmemb used to report an error when called with a memory that was either an automatic variable or a System Verilog class property
General Defects Repaired in 6.0e:
* $readmem for dynamic arrays did not work.
module test;
reg [7:0] memory [0:7];
integer n;
initial begin
//Path of the file which needs to be opened and read.
$readmemb("$NC_HOME/data.dat", memory);
for (n=0; n<8; n=n+1)
$display("%b", memory[n]);
end
endmodule
This problem is due to the fact that you didn't place the text file in your sim folder. Place the RAM file in the same directory from where you are running the simulation