How to override uvm_config_db from extended class?

Hi,

I have a base test in that I have set default config values. I created another test extended from base test and now I want to override uvm_config_db from extended test.

In base test build_phase I have done set uvm_config_db for cfg_num[`num] that is default configuration.
In Build_phase of extended test I tried to override set uvm_config_db but when I do that getting a Fatal Error which says :

UVM_FATAL uvm_test_top.env.env_num[0].xmtr_agent [build_phase] A agent_configuration object provided to constructor is not valid for class svt_xmtr_agent. Update the configuration based on prior Warning messages.

Here is the code :

class test extends uvm_test;

Env env[`num];

top_env t_env;

config cfg_num[`num];
config cfg;

virtual function void build_phase(uvm_phase phase);
super.build(phase);


t_env=top_env::type_id::create("t_env",this);

for (int i=0; i<`num;i++) begin

cfg_num[i]=config::type_id::create($sformat("cfg_num[%0d]",i));
cfg_num[i].passive_cfg.intf_type="ABC";
cfg_num[i].t_m_init=10;
cfg_num[i].t_s_init=10;

uvm_config_db#(config)::set(this,$sformat("env.env_num[%0d]",i),$sformat("cfg"),this.cfg_num[i]);

env.env_num[i]=Env::type_id::create($sformat("env.env_num[%0d]",i),this);

end //forloop
uvm_config_db#(config)::set(this,"*","cfg",this.cfg_num[0]);


endfunction



endclass

class test_ext extends test;


virtual function void build_phase(uvm_phase phase);
super.build(phase);

for(int i=0;i<1;i++)begin
cfg_num[i].passive_cfg.intf_type="CDE";
cfg_num[i].t_m_init=100;
cfg_num[i].t_s_init=100;

uvm_config_db#(config)::set(this,$sformat("env.env_num[%0d]",i),$sformat("cfg"),this.cfg_num[i]);
end

endtask;

endclass

Please anyone help me on this.

Thanks,
Manish.

In reply to ms_1202:

Can you please share the agent code, as the error message is getting generated from the agent class.

In reply to ms_1202:
Can you please share the agent code, as the error message is getting generated from the agent class.

Hi Sharat,

The problem is that agent code is encrypted I can’t see that code.
in base test some configuration is done and set with uvm_config_db. now in drived test I am calling super.build_phase and making some change in configuration and doing again uvm_config_db same as it was done in base test case. There I am getting this error. If I comment out this forloop in drived test then it is not giving any fatal error.

Can we do again uvm_config_db set when it is already done in base test build phase ?

Regards,
Manish.

In reply to ms_1202:

There is no problem in doing a uvm_config_db set again. I think the issue might be with the values of the configuration that you are setting from the derived class.

In reply to ms_1202:

You don’t need to set it again in derived class as while setting the cfg_num through uvm_config_db::set in base test passes the handle of the cfg_num type object.Thus assigning it in derived test will override the values of the fields of the cfg_num type object.

In reply to Alay Patel:

In reply to ms_1202:
You don’t need to set it again in derived class as while setting the cfg_num through uvm_config_db::set in base test passes the handle of the cfg_num type object.Thus assigning it in derived test will override the values of the fields of the cfg_num type object.

Hi Alay Patel,

Thanks for your response.
Can you please explain it little bit more or better u give some example so that I can understand it more clearly.

Thanks,
Manish

In reply to ms_1202:

Hi Alay Patel,

I think I got it.

I took another handle of config class in derived class and updating required fields and then assigning handle of cfg_init (handle taken in derived class) to cfg_num (handle taken in base class).
Fatal Error is gone now.
class test_ext extends test;

config cfg_init[`num];
virtual function void build_phase(uvm_phase phase);
super.build(phase);

for(int i=0;i<1;i++)begin
cfg_init[i].passive_cfg.intf_type=“CDE”;
cfg_init[i].t_m_init=100;
cfg_init[i].t_s_init=100;

cfg_num[i] = cfg_init[i];
end

endtask;

endclass

Thanks,
Manish