How do the set_config_* ( set_config_int , set_config_string , and set_co…
How do the set_config_* ( set_config_int , set_config_string , and set_config_object ) methods work in UVM?
Model answer
In UVM, set_config_int , set_config_string , and set_config_object are uvm_component convenience methods (inherited from OVM and **deprecated in UVM 1.2** in favor of uvm_config_db ) that allow a higher-level component in the hierarchy to configure integer/bitstream, string, and uvm_object variables in lower-level components without hardcoding hierarchical paths. **Method Signatures:** **How They Work:** 1. **Setting Configuration Data**: When a parent component calls set_config_* , the value is stored in the configuration database indexed by the hierarchical path ( inst_name , supports wildcards like "env.agnt.*" ) and variable name ( field_name ). For set_config_object , clone = 1 (the default) stores a deep clone of value , whereas clone = 0 passes the shared object handle reference. 2. **Retrieving Configuration Data**: The lower-level uvm_component retrieves the value either explicitly via get_config_int / get_config_string / get_config_object in build_phase , or automatically when super.build_phase(phase) is called if the field is registered with uvm_field_int / uvm_field_string / uvm_field_object . 3. **Mapping to uvm_config_db **: Under the hood in UVM, these methods map directly to: - uvm_config_db#(uvm_bitstream_t)::set(this, inst_name, field_name, value) - uvm_config_db#(string)::set(this, inst_name, field_name, value) - uvm_config_db#(uvm_object)::set(this, inst_name, field_name, clone ? value.clone() : value)