SV Constraint Error Resolution

In reply to arpitg:

Add a constraint for the array size. If you have all 5s, the array size would be 20. If you have all 2s, the array size would be 50.


class random_const_1 ;
 
  rand int stream_0s_1s [];
  constraint c0 { foreach (stream_0s_1s[i]) stream_0s_1s[i] inside {[2:5]};};
  constraint c1 { stream_0s_1s.sum() == 100 ;};
  constraint c2 { stream_0s_1s.size() inside {[20:50]};};
 
  function void post_randomize();
    foreach (stream_0s_1s[i])
      $display("Post Randomized Array : %d\n",stream_0s_1s[i]);
  endfunction
endclass
 
module test;
  random_const_1 t1;
  initial
    begin
      t1 = new();
      t1.randomize();
    end
endmodule