User guide

24-74
SystemVerilog Testbench Constructs
All these values are equally probable.
In the following example, the inside operator is used to specify
possible values in an integer array:
program test;
class pkt;
integer bills[0:8] = { 1, 2, 5, 10, 20, 50, 100, 500,
1000 };
rand integer v;
constraint c4 { v inside bills; }
endclass
int result;
pkt Pkt=new();
initial
begin
repeat (10) begin
result = Pkt.randomize();
$display("v is %d\n",Pkt.v);
end
end
endprogram
The $display system task displays the following:
v is 1
v is 100
v is 1000
v is 500
v is 10
v is 1
v is 20
v is 1