title: read and write in verilog when having negative numbers and array
body: <p>I am now doing reading input data from txt file and write the results into txt file. </p>
  
  <p>However the results runs in the simulation works well but it fail to link back the the conv module which is o = a+b; the system able to read the values in x.txt and d.txt but cannot link it back to a and b. What is my mistake and how to correct it?</p>
  
  <p>And from the same cases in  i found out that the system cannot write out negative decimal value although it is change to "%d\n" in $fwrite. Any method to solve that? Should i use $dumpfile to get negative number as output??</p>
  
  <p>Here is the content in d.txt</p>
  
  <pre><code>56
  272
  1
  -62
  75
  </code></pre>
  
  <p>Content in x.txt</p>
  
  <pre><code>562
  2723
  14
  -620
  751
  </code></pre>
  
  <p>Here is my module code:</p>
  
  <pre><code>module conv (input signed[15:0]a,b,
           output signed[15:0] o);
  
  assign o = a + b;
  endmodule
  </code></pre>
  
  <p>My testbench code:</p>
  
  <pre><code>module conv_tb();
  
  reg clk;
  reg signed [15:0]a[4:0];
  reg signed [15:0]b[4:0];
  wire signed [15:0]o[4:0];
  
  integer ai,bi,oo,i;
  
  conv U1(.a(a),.b(b),.o(o));
  
  initial begin
      clk &lt;= 1'b0;
      forever
      #1 clk = ~clk;
  end
  
  initial begin
     ai = $fopen("x.txt","r");
     bi = $fopen("d.txt","r");
     oo = $fopen("o.txt","w");
     #1;
     for (i = 0; i&lt;5; i=i+1)
         a &lt;= $fscanf(ai,"%d\n",x);
         b &lt;= $fscanf(bi,"%d\n",d);
         #4;
         $fwrite(oo,"%d\n",o);
     end
     $fclose(ai);
     $fclose(bi);
     $fclose(oo);
     $finish;
     end
  endmodule
  </code></pre>