title: Read binary file data in Verilog into 2D Array
body: <p>I have an array that I want to load up from a binary file:</p>
  
  <pre><code>parameter c_ROWS = 8;
  parameter c_COLS = 16;
  reg [15:0]  r_Image_Raw[0:c_ROWS-1][0:c_COLS-1];
  </code></pre>
  
  <p>My input file is binary data, 256 bytes long (same total space as r_Image_Raw).  I tried using <code>$fread</code> to accomplish this, but it only works through the 4th column of the last row:</p>
  
  <pre><code>n_File_ID = $fopen(s_File_Name, "r");
  n_Temp = $fread(r_Image_Raw, n_File_ID);
  </code></pre>
  
  <p>I also tried using <code>$fscanf</code> for this, but I get an error about packed types when opening the synthesis tool:</p>
  
  <pre><code>while (!$feof(n_File_ID))
    n_Temp = $fscanf(n_File_ID, "%h", r_Image_Raw);
  </code></pre>
  
  <p>I feel like this should be easy to do.  Do I have create a 2D for loop and loop through the r_Image_Raw variable, reading in 16 bits at a time?  I feel like it should not be that complicated.</p>