Can anyone please help me read decimal (just) values from a text file and store in memory?
My a.txt is: 3 4 14 3 24 5
and my code is:
`define Lenght 6
integer p,r,c;
integer file,stat,out,i;
reg [7:0] face[0:`Lenght-1];
initial
begin
file=$fopen("a.txt","r");
$display ("reading file.....");
i=0;
while (! $feof(file))
begin
stat=$fscanf(file,"%d\n",face[i]);
i=i+1;
end
$fclose(file);
for(i=0;i<`Lenght;i=i+1)
begin
$display("face[i]=%d",face[i]);
end
end
and my result is :
3
4
1
4
3
2
Why are my results wrong?