class c2;
rand bit[1:0] a;
rand bit[1:0] b;
function void my_print();
$display("a = %b", a);
$display("b = %b", b);
endfunction
endclass
class c1;
rand bit[1:0] i;
rand bit[1:0] j;
rand c2 o2;
function new();
o2 = new();
endfunction
function void my_print();
$display("i = %b", i);
$display("j = %b", j);
endfunction
endclass
program p1;
c1 o1 = new;
c2 o2_local = new;
initial begin
if (o1.randomize() with {o2 == o2_local;}) begin
o1.my_print();
o2.my_print();
end
endprogram
class c2;
rand bit[1:0] a;
rand bit[1:0] b;