Configuring variables present in agent using set_config_int

Hi ,

I had multiple masters of an i2c ovc. I want to use an for loop for setting the variables in multiple i2c masters by using set_config_int statement in ovm. For this i had done in this way

//STANDARD WAY IS THIS ONE
set_config_int(“i2c0.master[0]”,“is_active”,OVM_ACTIVE);
set_config_int(“i2c0.master[1]”,“is_active”,OVM_ACTIVE);
set_config_int(“i2c0.master[2]”,“is_active”,OVM_ACTIVE);

Instead of using above style, i tried with below style but got issues with it
for(int i=0;i<=i2c_masters;i++)
begin
set_config_int($psprintf(“i2c0.master[%d]”,i),“is_active”,OVM_ACTIVE);
end

But i am getting issue that is_active value is not getting passed to i2c environemnt. Is there another way to write this logic so that i dont have to manually set the variables and can use arrays to set variables.
Thanks in advance for your responses.

‘$psprintf()’ is not an official part of the SystemVerilog LRM. You should be using ‘$sformatf()’ instead.

Additionally, the format specifier of “%d” is probably not giving you what you expect. Try printing out the string generated and seeing what it shows, and then try to determine what the correct specifier should be. Hint: Try $sformatf(“i2c0.master[%0d]”, i)