I am trying to re-randomize a variable "c’ in an object “item” using inline constraint inside a test class. The randomization of the whole object “item” is happening in the base class "example_base_test " and re-randomization is happening in the extended test “test_1”. The issue i am facing is that, after the inline constraint is applied, the constraint solver fails to solve c1 inside object “item”.
Kindly find code snippet below.
Thanks in advance.
class item extends uvm_object;
rand bit a, b ;
rand int c;
constraint c1{
if (a) b ==0;
}
endclass
class test_1 extends example_base_test ;
`uvm_component_utils(test_1)
// The test’s constructor
function new (string name = "test_1",uvm_component parent = null);
super.new(name, parent);
endfunction
virtual function build_phase();
super.build_phase(phase);
if(!item.randomize(c) with {
c > 30;
c < 150;
})begin
`uvm_error(get_type_name(), "randomization failed ");
end
uvm_config_db#(item)::set(this, "*", "item", item);
endfunction
endclass