UVM_Config_db / Configuration Database

 UVM_Config_db 


The configuration database provide access to a centralized database where type specific information can be stored and received. config_db can contain scalar objects, class handles, queues, lists, or even virtual interfaces.

The database has both a name table and a type table and each resource is entered into both. Resources are stored in a database so that each resource can be retrieved by name or by type, and  database is globally accessible.

uvm_config_db::set and uvm_config_db::get methods are used to store and retrive the information from database respectively.

 set method: 

void uvm_config_db#(type T = int)::set(uvm_component cntxt, string inst_name, string field_name, T value);

Where,

 T  is the type of the element being configured.
      Type can be scalar objects, class handles, queues, lists, or even virtual interfaces).
 cntxt is the hierarchical starting point of where the database entry is accessible.
• inst_name is hierarchical path that limits accessibility of the database entry.
    example:
           top.env.agent.monitor
           top.*                       -  all of the scopes whose top-level component is top.
           top.env.*.monitor   -  all of the scopes in env that end in monitor;
field_name is the label used as a lookup for the database entry.
value is the value to be stored in the database.

Example:
Below example shows, setting the interface handle intf, type mem_if, label mem_intf with global scope. 

  mem_if intf(clk,reset);  //interface instance
  uvm_config_db#(virtual mem_if)::set(null,"*","mem_intf",intf);  //set method



The above diagrams illustrates how a resource whose name is mem_intf and type is mem_if is stored in the pool.

 get method: 

bit uvm_config_db#(type T=int)::get(uvm_component cntxt, string inst_name, string field_name, ref T value);

• value is the variable to which the value is  to be retreived from the database.
  * The other fields are same as in set method.

The method returns 1 if it is successful and 0 if there is no such resource of this type in database.

Example:
Below example shows. Using the get method to get virtual interface handle from database and assigns it to mem_vif. If get method fails, the fatal message will be displayed.

    virtual interface mem_if mem_vif;    //virtual interface declaration
    if( !uvm_config_db#(virtual mem_if)::get(this,"*", "mem_intf", mem_vif))
      `uvm_fatal(get_full_name(),{"virtual interface must be set for:",".mem_vif"} ); //get method