title: Confused with ripple carry adder output
body: <p>I am working on a ripple carry adder using structural verilog, which is supposed to take in two random inputs and calculate accordingly. </p>
  
  <p>The general rca I created calculated correctly, but for some reason I get weird outputs when I add a for loop and use the <code>$random</code> to generate. </p>
  
  <p>Could someone kindly explain where I'm going wrong? Below is my code:</p>
  
  <pre><code>module full_adder(x,y,z,v,cout);
      parameter delay = 1;
  
      input x,y,z;    //input a, b and c
      output v,cout;  //sum and carry out
  
      xor #delay x1(w1,x,y);
      xor #delay x2(v,w1,z);
      and #delay a1(w2,z,y);
      and #delay a2(w3,z,x);
      and #delay a3(w4,x,y);
      or #delay o1(cout, w2,w3,w4);
  endmodule
  
  module four_bit_adder(a,b,s,cout,cin);//four_bit_adder
      input [15:0] a,b;       //input a, b
      input cin;              //carry in
      output [15:0] s;        //output s
      output cout;            //carry out
      wire [15:0] c;
  
  
      full_adder fa1(a[0],b[0],cin,s[0],c0);  
      full_adder fa2(a[1],b[1],c0,s[1],c1);
      .
      .
      .
      full_adder fa16(a[15],b[15],c14,s[15],cout); 
  endmodule
  
  
  
  module testAdder(a,b,s,cout,cin);
      input [15:0] s;         
      input cout;             
      output [15:0] a,b;      
      output cin;             
      reg [15:0] a,b;
      reg cin;
      integer i;
      integer seed1=4;
      integer seed2=5;
      initial begin
           for(i=0; i&lt;5000; i=i+1) begin
              a = $random(seed1);
              b = $random(seed2);
              $monitor("a=%d, b=%d, cin=%d, s=%d, cout=%d",a,b,cin,s,cout);
              $display("a=%d, b=%d, cin=%d, s=%d, cout=%d",a,b,cin,s,cout);
              end
      end            
  endmodule
  </code></pre>
  
  <p>Here are two lines from the output that I get:</p>
  
  <pre><code>a=38893, b=58591, cin=x, s=    z, cout=z
  a=55136, b=58098, cin=x, s=    z, cout=z
  </code></pre>