Override configuration value in sequence

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!

In reply to Jessita J:

You are doing strange things. The sequence does not have a position in the hierarchy of your testbench. Commonly the test is used to configure your testbench. The agent belongs to the hierarchy.
A sequence should run on your testbench.

In reply to chr_sue:

Hello chr_Sue,

I am trying to change the configuration of the agent during run time.
My DUT is a UART controller and it has a provision to work in multiple modes with regards to its “sample rate” and “parity_type”. IN QVIP these values are configured at test. I want to override this configuration to see whether DUT is able to switch to the new settings for sample rates and parity.

could you let me know how this is possible?

Thanks.

In reply to Jessita J:

I understand what you have. But I do not believe that you have to change your UART configuration data during the execution of a sequence creating seq_items.
I think a good scenario for your application is like this:
(1) configure your UART
(2) generate seq_items and drive the virtual interface
(3) reconfiure your UART
(4) generate seq_items wrt to this configuration and so on.
This will reflected in your test
(1) configuration sequence
(2) operational sequence
(3) configuration sequence
(4) operational sequence