Guest
Hi,
I am trying to read the data data from file using $fread. But data is
not loading into memory correctly.
Here is code.
module fileio;
integer r1,c1;
reg [7:0] mem1[0:100];
reg [7:0] mem2[0:100];
integer i;
initial
begin
r1 = $fopen("data2.log","rb");
c1 = $fread(mem1,r1);
for(i = 0;i < 7; i = i+1)
begin
$display("mem1[%0d] = %b" ,i,mem1);
end
$display("file1 = %0d ",c1);
end
endmodule
data2.log file contains the following data
11110000
10101010
01010101
I am getting the following the output..
# mem1[0] = 00110001
# mem1[1] = 00110001
# mem1[2] = 00110001
# mem1[3] = 00110001
# mem1[4] = 00110000
# mem1[5] = 00110000
# mem1[6] = 00110000
# file1 = 32
I am using questasim6.2b in windows. Can anybody explain me, what is
wrong in code i have written?
I am trying to read the data data from file using $fread. But data is
not loading into memory correctly.
Here is code.
module fileio;
integer r1,c1;
reg [7:0] mem1[0:100];
reg [7:0] mem2[0:100];
integer i;
initial
begin
r1 = $fopen("data2.log","rb");
c1 = $fread(mem1,r1);
for(i = 0;i < 7; i = i+1)
begin
$display("mem1[%0d] = %b" ,i,mem1);
end
$display("file1 = %0d ",c1);
end
endmodule
data2.log file contains the following data
11110000
10101010
01010101
I am getting the following the output..
# mem1[0] = 00110001
# mem1[1] = 00110001
# mem1[2] = 00110001
# mem1[3] = 00110001
# mem1[4] = 00110000
# mem1[5] = 00110000
# mem1[6] = 00110000
# file1 = 32
I am using questasim6.2b in windows. Can anybody explain me, what is
wrong in code i have written?