Question on uvm_config_db::set called with context as *

HI,
in the UVM cookbook page no. 33, there is an example of integration level testbench in which following config_db::set call is used in build_phase:


if (!uvm_config_db#(spi_env_config)::set( "*", "", "spi_env_config", m_spi_env_config )) 'uvm_error(...)


I have following questions with reference to above statement:

  1. .cntext parameter here is a string, it should be of type component.

  2. Also what is the significance of putting * as cntext parameter. Does it indicate that this call will be done for all the components in the hierarchy?
    This call is made in pss_test_base class build_phase. If * is used as context, does it mean all the components in the hierarchy will be used as context?

Can someone explain please.

Thanks,
-sunil

In reply to puranik.sunil@tcs.com:

I could not find the code you posted in the cookbook. (https://verificationacademy.com/resource/68003). I see null.

Hi Dave,
I am not able to attach the uvm_cook book version i have. I have copy-pasted the code from my version of uvm cookbook.
I have put a comment “I am referring to this line” just above the line of the code I am referring to. Please let me know if there is some issue with code. (could be a typo also)
Anyways I will be using the latest version of uvm cook book now.



//

// Class Description:

//

//

class pss_test_base extends uvm_test;



// UVM Factory Registration Macro

//

`uvm_component_utils(pss_test_base)



//------------------------------------------

// Data Members

//------------------------------------------



//------------------------------------------

// Component Members

//------------------------------------------

// The environment class          pss_env m_env;
// Configuration objects pss_env_config m_env_cfg; spi_env_config m_spi_env_cfg; gpio_env_config m_gpio_env_cfg;
//uart_env_config m_uart_env_cfg; apb_agent_config m_spi_apb_agent_cfg; apb_agent_config m_gpio_apb_agent_cfg; ahb_agent_config m_ahb_agent_cfg; spi_agent_config m_spi_agent_cfg; gpio_agent_config m_GPO_agent_cfg; gpio_agent_config m_GPI_agent_cfg; gpio_agent_config m_GPOE_agent_cfg;


// Register map
pss_register_map pss_rm;



//------------------------------------------

// Methods

//------------------------------------------

// Standard UVM Methods:

extern function new(string name = "spi_test_base", uvm_component parent = null); 
extern function void build_phase( uvm_phase phase);
extern virtual function void configure_apb_agent(apb_agent_config cfg, int index, logic[31:0] start_address, logic[31:0] range);



extern task run_phase( uvm_phase phase );



endclass: pss_test_base



function pss_test_base::new(string name = "spi_test_base", uvm_component parent = null); super.new(name, parent);
endfunction



// Build the env, create the env configuration

// including any sub configurations and assigning virtural interfaces 

function void pss_test_base::build_phase( uvm_phase );
m_env_cfg = pss_env_config::type_id::create("m_env_cfg");

// Register map - Keep reg_map a generic name for vertical reuse reasons pss_rm = new("reg_map", null);
m_env_cfg.pss_rm = pss_rm;

// SPI Sub-env configuration:

m_spi_env_cfg = spi_env_config::type_id::create("m_spi_env_cfg"); m_spi_env_cfg.spi_rm = pss_rm;
// apb agent in the SPI env:

m_spi_env_cfg.has_apb_agent = 1;

m_spi_apb_agent_cfg = apb_agent_config::type_id::create("m_spi_apb_agent_cfg"); configure_apb_agent(m_spi_apb_agent_cfg, 0, 32'h0, 32'h18);
if( !uvm_config_db #(virtual apb_if)::get(this, "","APB_vif",m_spi_apb_agent_cfg.APB) ) `uvm_error(...) m_spi_env_cfg.m_apb_agent_cfg = m_spi_apb_agent_cfg;
// SPI agent:

m_spi_agent_cfg = spi_agent_config::type_id::create("m_spi_agent_cfg");

if( !uvm_config_db #(virtual spi_if)::get(this, "" , "SPI_vif",m_spi_agent_cfg.SPI) ) `uvm_error(...) m_spi_env_cfg.m_spi_agent_cfg = m_spi_agent_cfg;
m_env_cfg.m_spi_env_cfg = m_spi_env_cfg;

//I am referring to this line below


if( !uvm_config_db #( spi_env_config )::set("*", "", "spi_env_config", m_spi_env_cfg) ) `uvm_error(...) 




// GPIO env configuration:

m_gpio_env_cfg = gpio_env_config::type_id::create("m_gpio_env_cfg"); m_gpio_env_cfg.gpio_rm = pss_rm;
m_gpio_env_cfg.has_apb_agent = 1; // APB agent used
 

m_gpio_apb_agent_cfg = apb_agent_config::type_id::create("m_gpio_apb_agent_cfg"); configure_apb_agent(m_gpio_apb_agent_cfg, 1, 32'h100, 32'h124);
if( !uvm_config_db #(virtual apb_if)::get(this, "" , "APB_vif",m_gpio_apb_agent_cfg.APB) ) `uvm_error(...) m_gpio_env_cfg.m_apb_agent_cfg = m_gpio_apb_agent_cfg;
m_gpio_env_cfg.has_functional_coverage = 1; // Register coverage no longer valid

// GPO agent

m_GPO_agent_cfg = gpio_agent_config::type_id::create("m_GPO_agent_cfg"); uvm_config_db #(virtual gpio_if)::get(this, "GPO_vif",m_GPO_agent_cfg.GPIO); m_GPO_agent_cfg.active = UVM_PASSIVE; // Only monitors m_gpio_env_cfg.m_GPO_agent_cfg = m_GPO_agent_cfg;
// GPOE agent

m_GPOE_agent_cfg = gpio_agent_config::type_id::create("m_GPOE_agent_cfg"); uvm_config_db #(virtual gpio_if)::get(this, "GPOE_vif",m_GPOE_agent_cfg.GPIO); m_GPOE_agent_cfg.active = UVM_PASSIVE; // Only monitors m_gpio_env_cfg.m_GPOE_agent_cfg = m_GPOE_agent_cfg;
// GPI agent - active (default)

m_GPI_agent_cfg = gpio_agent_config::type_id::create("m_GPI_agent_cfg");

if( !uvm_config_db #(virtual gpio_if)::get(this, "" , "GPI_vif",m_GPI_agent_cfg.GPIO) ) `uvm_error(...) m_gpio_env_cfg.m_GPI_agent_cfg = m_GPI_agent_cfg;
// GPIO Aux agent not present m_gpio_env_cfg.has_AUX_agent = 0;
m_gpio_env_cfg.has_functional_coverage = 1;

m_gpio_env_cfg.has_virtual_sequencer = 0;

m_gpio_env_cfg.has_reg_scoreboard = 0;

m_gpio_env_cfg.has_out_scoreboard = 1;

m_gpio_env_cfg.has_in_scoreboard = 1; m_env_cfg.m_gpio_env_cfg = m_gpio_env_cfg;
uvm_config_db #( gpio_env_config )::set( this , "*", "gpio_env_config", m_gpio_env_cfg);

// AHB Agent

m_ahb_agent_cfg = ahb_agent_config::type_id::create("m_ahb_agent_cfg");

if( !uvm_config_db #(virtual ahb_if)::get(this, "", "AHB_vif",m_ahb_agent_cfg.AHB) ) `uvm_error(...) m_env_cfg.m_ahb_agent_cfg = m_ahb_agent_cfg;
// Add in interrupt line

if( !uvm_config_db #(virtual icpit_if)::get(this, "", "ICPIT_vif",m_env_cfg.ICPIT) ) `uvm_error(...) uvm_config_db::set( this , "*", "pss_env_config", m_env_cfg);
m_env = pss_env::type_id::create("m_env", this);

// Override for register adapters: register_adapter_base::type_id::set_inst_override(ahb_register_adapter::get_type(), "spi_bus.adapter"); register_adapter_base::type_id::set_inst_override(ahb_register_adapter::get_type(), "gpio_bus.adapter");
endfunction: build_phase



//

// Convenience function to configure the apb agent

//





thanks,
-sunil

In reply to puranik.sunil@tcs.com:

I’ve searched through the latest version of the UVM Cookbook that Dave referenced and cannot find what you are referring to. Please download the latest version of the Cookbook.

In reply to puranik.sunil@tcs.com:

Do you refer to this line of code?

if( !uvm_config_db #( spi_env_config )::set("*", "", "spi_env_config", m_spi_env_cfg) ) `uvm_error(...)

Looks like an error. The first argument has to be of type uvm_component.

Hi,
thanks for the reply.
Context has to be component. So if I just give * instead of “*”, will it work. Does it mean function will take all the components in hierarchy as a context?
thanks,
-sunil

In reply to puranik.sunil@tcs.com:

No this is not a good idea. The context together with the hierarchy has to considered.
If context is ‘null’ the hierarchy is considered as an abolute path. ‘this’ is indicating a relative path starting in the component where the set/get is executed.