I am trying to change the configuration for agent in sequence.
1.firstly, inside my test class I have set the configuration class object in DB as shown below:
//INSIDE TEST CLASS
//INSIDE BUILD PHASE
uart_device_0_cfg_t::type_id::create("uart_device_0_cfg" );
uvm_config_db #(uart_device_0_cfg_t)::set(null, "*", "uart_device_0_cfg", uart_device_0_cfg);
2.Inside the sequence class I tried to set a new value to one of the configuration variables and set the new configuration object to the config db hoping to override the previously declared configuration class object using below code:
//INSIDE SEQUENCE CLASS
//INSIDE BUILD PHASE
if ( !uvm_config_db #(uart_device_0_cfg_t)::get(get_sequencer(), "", "uart_device_0_cfg", uart_device_0_cfg1) )
begin
`uvm_error("build_phase", "Unable to get virtual interface uart_device_0_cfg1 from uvm_config_db")
end
uart_device_0_cfg1.agent_cfg.num_samples = 312; // CHANGE CONFIGURATION VARIABLE
uvm_config_db #(uart_device_0_cfg_t)::set(null, "*", "uart_device_0_cfg", uart_device_0_cfg1);
However the field “num_samples” is not getting updated in runtime even though it is displayed in console with changed value.
I could see that, in the agent class, this configuration object is retrieved in the build phase and the value is passed to an object of the bfm class as shown below.
//INSIDE BUILD PHASE OF AGENT CLASS
// Get configuration object
if (cfg == null)
cfg = cfg_t::get_config(this);
if (cfg == null)
`uvm_fatal("AGENT/CFG/NOT_FOUND","The uart agent requires a config object")
else
set_mvc_config(cfg);
cfg.m_bfm.uart_cfg_num_samples = cfg.agent_cfg.num_samples; //BFM OBJECT UPDATED
To make this change in the bfm object also i tried to get the bfm object from DB and updated it with the new value and set it again. However the configuration variable is not updated.
//INSIDE SEQUENCE CLASS UPDATING BFM OBJECT
if ( !uvm_config_db #(uart_device_0_cfg_t)::get(get_sequencer(), "", "uart_device_0_cfg", uart_device_0_cfg1) )
begin
`uvm_error("build_phase", "Unable to get virtual interface uart_device_0_cfg1 from uvm_config_db")
end
if ( !uvm_config_db #(uart_device_0_bfm_t)::get(get_sequencer(), "", "uart_device_0", uart_device_0_cfg1.m_bfm) )
begin
`uvm_error("build_phase", "Unable to get virtual interface uart_device_0 for uart_device_0_cfg from uvm_config_db")
end
uart_device_0_cfg1.agent_cfg.num_samples = 312;
uvm_config_db #(uart_device_0_bfm_t)::set(null, "*", "uart_device_0", uart_device_0_cfg1.m_bfm);//UPDATING BFM OBJECT
uvm_config_db #(uart_device_0_cfg_t)::set(null, "*", "uart_device_0_cfg", uart_device_0_cfg1);
could you please let me know how i can update the configuration value in this scenario?
Thanks!