|
发表于 2019-4-30 09:53:14
|
显示全部楼层
class test;
bit [7:0] fib[7] = '{12,34,45,47,78,96,104};
rand bit [7:0] dt[2];
rand bit [7:0] number[];
rand bit in_or_not_in;
constraint number_cn{
number.size() inside {[2:5]};
unique {dt};
foreach(dt[i])
dt[i] inside {fib[0],fib[1]};//can change
foreach(dt[i])
if (in_or_not_in == 1)
dt[i] inside {number};
else
!(dt[i] inside {number});
in_or_not_in dist {1:=8,0:=2};
}
endclass
initial begin
automatic test utest = new();
for(int i=0;i<30;i++) begin
void'(utest.randomize());
$display("%0d,%p",utest.in_or_not_in,utest.number);
end
end
endmodule |
|