title: image file reading in system verilog
body: <p>I have written system verilog code for reading data from an image file (800*600 -<br>
      *.raw).
      The file actually contains 800 * 600 * 3 bytes. But my code can only read upto almost 
      half the data.
      After that the read data seems to be "00".
      Valuable suggestions for resolving this is appreciated..</p>
  
  <pre><code>My code is as follows.
  
  
  //`define EOF 32'hFFFF_FFFF
  //`define EOF \n
  
  reg [7:0]data_byte;
  
  class input_video_IF;
  int count;
  integer input_file, fread_return,output_file;
  
  
  function new ();
  
  input_file = $fopen("test_800.raw","r");
  if(input_file)
  begin
  $display("File OPENED");
  end
  else
  begin
  $display("File error");
  end
  
  output_file = $fopen("output_800.raw", "w");
  endfunction:new
  
  task image_file_read();
  count = 0;
  //while (!$feof(input_file))
  while(count != 1440000)
  begin
  fread_return = $fread(data_byte,input_file);
  count++;
  $display("%d %h",count,data_byte);
  //$fwrite(output_file,data_byte);
  end
  $finish;
  $fclose(input_file);
  endtask : image_file_read
  
  endclass
  
  program Image_read_test;
  int input_file;
  input_video_IF In_IF = new();
  initial
  
  In_IF.image_file_read();
  
  
  endprogram
  </code></pre>