User guide
24-109
SystemVerilog Testbench Constructs
repeat (10)
begin
int1 = bus.randomize() with {bitrand1[1:0] ==
2'b00;};
if (int1 ==1) $display("bitrand1 = %0b",
bus.bitrand1);
end
endtask
initial
inline(bus);
endprogram
The $display system task displays the following
bitrand1 = 100
bitrand1 = 100
bitrand1 = 100
bitrand1 = 0
bitrand1 = 100
bitrand1 = 100
bitrand1 = 0
bitrand1 = 100
bitrand1 = 100
bitrand1 = 0
In-line Constraint Checker
The randomize() method can act as a checker when a special “null”
argument is specified. In this case, randomize(null) assigns no
random values. It only returns a status. The status “1” is returned if
all constraints are satisfied. A “0” is returned otherwise. The in-line
random variable control mechanism can also be used to force the
randomize() method to behave as a checker.