Hi Dave, I randomized the array 100 times, and when I saw the value for the sum its always 50 or 510. Can you explain why the sum is only 50 or 510?
// This is the class that we will randomize.
class my_item;
rand bit [2:0] rand_val;
rand bit[3:0] arr[];
// Randomization constraints.
constraint c {
arr.size()==510;
arr.sum with (int'(item)) dist {[1:50]:/90,[51:510]:/10};
//rand_val dist {0:/10 , 1 :/ 45 , 2 :/ 45};
}
// Print out the items.
function void print();
//$display("rand_val: %0d", rand_val);
$display("arr_sum: %0d", arr.sum with (int'(item)));
endfunction
endclass
module automatic test;
function void run;
my_item item = new();
for (int i = 0; i < 200; i++) begin
item.randomize();
item.print();
end
endfunction
initial run();
endmodule
Works for me. You might have a tool issue. This Mentor/Siemens EDA sponsored public forum is not for discussing tool specific usage or issues. Please read your tool’s user manual or contact your tool vendor directly for support.