class base_const;
rand int x;
constraint c1 {
x == 10;
}
endclass
class child1_const extends base_const;
rand int x;
constraint c1 {
x == 20;
}
endclass
class child2_const extends base_const;
rand int x;
constraint c1 {
x == 30;
}
endclass
module top_const;
base_const base;
child_const child1;
child1_const child2;
initial begin
base = new();
child1 = new();
child2 = new();
base.c1.constraint_mode(0);
child1.c1.constraint_mode(0);
child2.c1.constraint_mode(0);
base.randomize();
child1.randomize();
child2.randomize();
end
endmodule
Instead of calling 'constraint_mode(0) for each of the extended classes, I want to turn of constraint mode for all ānā extended classes in a single line of code. Is it possible?