SystemVerilog $feof()

In reply to mukeshkumar.saha@reliabletechsys.com:
It’s because after the read of the last data value in the file, there are still more characters in the file (like a newline) and the final call to
$fscanf
fails and leaves
addr
and
data
unmodified. What you need to do is check the return value of
$fscanf
.

file = $fopen("data_file.txt","r");
while ($fscanf(file,"%h %h",addr,data)==2) begin
    $display("addr:%h <<< -- >>> data:%h",addr,data);
      end