Not able to add constraints from testcase for uvm_object class

Hi All,

I have a config class…

class config extends uvm_object;

rand int rate;

endclass

class my_test extends uvm_test;
config cfg;
cfg=new();
constraint bit_rate_1{cfg.rate==1;} //This constraint is not working …
assert(cfg.randomize()); //doing it in build phase
endclass

The constraint bit_rate_1 is for the my_test class - it would only work if you randomized my_test. You need to either extend the class config with that constraint and construct the extended class in my_test, or use the randomize ‘with’ clause.