Jump to content

Modifycation of uvm_object internals


Recommended Posts

Hi,
I would like to ask UVM familiar users/professionals to get an opinion on the following issue:

I am trying to modify uvm_object's internal fields during a run_phase of my testcase (or it could be
end_of_elaboration_phase or start_of_simulation_phase, important - environment is already built up).
Would you consider it like "this is something that should be working"?

- let's assume the object "ga_config" is agent configuration

- for simplicity there is only 1 data field "monitor_enable" in it

class ga_config extends uvm_object;

  // Variable: monitor_enable
  uvm_active_passive_enum monitor_enable = UVM_PASSIVE;

  function new (string name = "unnamed-ga_cfg");
    super.new(name);
    this.name = name;
  endfunction

  `uvm_object_utils_begin(ga_config)
    `uvm_field_enum  (uvm_active_passive_enum, monitor_enable, UVM_DEFAULT)
  `uvm_object_utils_end

endclass : ga_config

- "ga_cfg" is a name registered into uvm database in TB environment (in build phase)

  ga_cfg = ga_config::type_id::create("ga_cfg");
  uvm_config_db#(ga_config)::set(this, "ga_env0*", "ga_cfg", ga_cfg);


- "ga_cfg" is sourced from uvm database in agent monitor (in build phase)
 

class ga_monitor extends uvm_monitor;

  ga_config cfg;

...

  function void build_phase (uvm_phase phase);

   ...

  uvm_config_db#(ga_config)::get(this, "", "ga_cfg", cfg);

   ...

  endfunction

  …

endclass

 

  i.e I am expecting here to create a pointer to object "ga_cfg"


- NOW in testcase for example end_of_elaboration_phase I WANT TO MODIFY "monitor_enable" field
 

class my_testcase extends uvm_test;

...

  function void end_of_elaboration_phase (uvm_phase phase);

  uvm_config_db#(uvm_active_passive_enum)::set(this, "tb_env0.ga_env0.ga2.monitor.cfg", "monitor_enable", UVM_ACTIVE);

  endfunction

  …

endclass

 

  Note: assume the path "tb_env0.ga_env0.ga2.monitor.cfg" is something you can extract from
  hierarchy report (print_topology).


Unfortunately this latest command doesn't have desired effect. I’d expect to see monitor_enable value set to UVM_ACTIVE,

but I still see UVM_PASSIVE. Can anybody explain why?

 

I have seen some comments regarding issues w/ uvm_object hierarchy and UVM 1.1. Is it related to what I am trying to describe here?

Thanks Josef

Link to comment
Share on other sites

You did remember that field automation macros never do a uvm_config_db::get() for you? Most people don't realize this, and many other problems including their performance are why we do not recommend using them. Please see this link.

 

But even if it did to the get(), only the set()s that came before it would have an effect. So at the end of elaboration, you need to get the handle to your ga_cfg and set cfg.montitor_enable = UVM_ACTIVE;

Link to comment
Share on other sites

  • 4 weeks later...

To be a little more precise here, the field macros do call uvm_config_db::get() for component fields in the component's build_phase.  uvm_config_db::get() is not called for non-phased objects like uvm_sequence_items or plain uvm_objects. 

 

well, the field macros do not call ::get(), it's the uvm_component's apply-config_settings() method which iterates over the defined fields and pulls the values from the config_db and assigns them to the local fields via set_*_local(). 

 

the above scenario should work IF the monitor::build_phase() first retrieves the config object and then invokes super.build_phase() to have auto configuration applied. in that particular case 

 

::set(this, "tb_env0.ga_env0.ga2.monitor", "cfg.monitor_enable", UVM_ACTIVE)

 

should set the field as desired..

/uwe

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...