Using uvm field automation macros in uvm_object extended types

Hi Moderators,

In my legacy Tb the top_cfg class has the following code

class top_cfg extends base_cfg; // where base_cfg extends uvm_object

`uvm_object_utils_begin(top_cfg)
 `uvm_field_object(dig_xyz_cfg,UVM_ALL_ON|UVM_REFERENCE);
 `uvm_field_sarray_object(clkmon_cfg,UVM_ALL_ON|UVM_NO_PRINT|UVM_REFERENCE);
`uvm_object_utils_end

Generally I avoid defining these macros as I am aware that this forum discourages use of it.

However, since the legacy Tb uses it, I need to use to set respective properties

[Q1] Unlike component types where user would call super.build_phase() which internally calls apply_config_settings() how would UVM internally fetch these configurations in uvm_object class types ?

[Q2] Assuming obj. of top_cfg is created in top_env, how could one set these properties from test using uvm_config_db ?

uvm_config_db#(<arg1>)::set(this,"<arg2>", "<arg3>", <arg4>);

I believe arg2 would be env.top_cfg_name (where top_cfg_name is name arg. during create)

[Q3] What would arg1 and arg3 be ?

Thanks in Advance

The code generated by the UVM field macros for configuration is useless for non-component objects. You will need to manually set() and get() their values from the configuration database, just as if you had never used the field macros.

arg1 would be the same type as the field variable.
arg3 would be the name of the field variable.

arg2 depends on the relative locations of the calls to the set() and get() methods. Additionally, it may influence whether you use this or null as the first argument.

Hi Dave,

I am not clear on non-component objects.

(1) Does the instantiation of top_cfg decide whether it’s component based object (when instantiated in component) or non-component based object (when instantiated in another object) ?

(2) What’s the difference between `uvm_field_sarray_object and `uvm_field_object ?

Thanks

Since top_cfg is not an extension of uvm_component, it is a non-component object. Consequently, you cannot call the apply_config_settings() method, which is a method of uvm_component.

`uvm_field_sarray_object is used for a class member that is declared as a statically sized array of uvm_objects.