Using of uvm_config_db# in virtual sequence

In reply to chr_sue:

Thanks again chr_sue. Now I clearly understand the difference.

Here is my another example. For instance, I have a configuration object:


class my_config extends uvm_object;
     int a = 0;

    `uvm_object_utils( my_config )

    function new ( string name = "my_config" );
       super.new( name );
    endfunction : new
endclass: my_config

And also I have a driver like this:


class my_driver uvm_driver #(my_item);
    my_config cfg;

    `uvm_component_utils_begin( my_driver )
          `uvm_field_object(  cfg , UVM_DEFAULT )
    `uvm_component_utils_end
    

     function new (string name = "my_driver", uvm_component parent);
        super.new(name, parent);
     endfunction

     function void build_phase( uvm_phase phase );
        super.build_phase( phase );
        if( !uvm_config_db#( my_config )::get( this, "", "cfg", cfg ) )
            `uvm_error( "NOCONFIG", 
                      { "Config not set for...", get_full_name() } )   
     endfunction: build_phase

     ....
endclass: my_driver

And there is a simple test:


class my_test extends uvm_test;
    `uvm_component_utils(my_test)

    my_driver driver;
    my_config cfg;

    virtual function void build_phase( uvm_phase phase );
        super.build_phase(phase);
        driver = my_driver::type_id::create( "driver", this );

        //this slice of code changes "a" value in configuration
        cfg = my_config::type_id::create( "cfg", this );
        cfg.a = 1;
        uvm_config_db#(my_config)::set( uvm_root::get(), "driver*", "cfg" , cfg );
        // but if i want to change "a" value like this, it doesn't work
        uvm_config_db#(int)::set( uvm_root::get(), "driver.cfg", "a" , 1 );
     endfunction
endclass

Could you explain why?