Jump to content
Sign in to follow this  
dudi

How to produce a warning for unused config_db "sets" and factory overrides

Recommended Posts

Hi

Is there a way to produce a uvm_warning for unused config_db "sets" and factory overrides?

By "unused" I mean a set to the config_db that received a corresponding "get", and a factory override that was never required.

Since the factory and the config_db is string based, a small typo is hard to debug.

Is there an automatic way to produce the warning?

I know I can turn on the "trace" function by adding +UVM_RESOURCE_DB_TRACE to the command line (BTW - there is a bug in UVM, it ignores +UVM_CONFIG_DB_TRACE and only uses the resource_db options class) but it still requires me to parse the log. An automatic warning can be very helpful.

Thanks for your help!

Share this post


Link to post
Share on other sites

hi,

1. there is a "spellchecker" capability. the RSRCNF message is like this one:

UVM_WARNING test.sv(48) @ 0: uvm_test_top.dad.child2 [RSRCNF] resource flag in scope uvm_test_top.dad.child2 not found
uvm_test_top.dad.child2: flag = 0
mde not located
 did you mean mode?

2. in order to get the unused resources you may use the following:

uvm_component::
 // Function: check_config_usage
 //
 // Check all configuration settings in a components configuration table
 // to determine if the setting has been used, overridden or not used.
 // When ~recurse~ is 1 (default), configuration for this and all child
 // components are recursively checked. This function is automatically
 // called in the check phase, but can be manually called at any time.
 //
 // To get all configuration information prior to the run phase, do something 
 // like this in your top object:
 //|  function void start_of_simulation_phase(uvm_phase phase);
 //|    check_config_usage();
 //|  endfunction

here is a testcase: http://uvm.git.sourceforge.net/git/gitweb.cgi?p=uvm/uvm;a=blob_plain;f=tests/10resources/01simple/test.sv;hb=refs/heads/UVM_1_1_BUGFIX

Share this post


Link to post
Share on other sites

Hi Uwes, thanks for the response!

I think the spell checker only works for the resource_db and not for the config_db (correct me if I'm wrong). And I mostly use config_db...

check_config_usage() covers this though - I call it on the check_phase of the test like this:

virtual function void check_phase(uvm_phase phase);
   super.check_phase(phase);
   uvm_root root=uvm_root::get();
   root.check_config_usage(1);
endfunction
I'll probably implement my own function though, because it uses $display.

I still need something for the factory overrides ( set_type_override / set_inst_override). Do you know anything for this?

Another thing I saw is that check_config_usage() is not called automatically - this is a documentation bug I think because I doubt it should be called automatically

Share this post


Link to post
Share on other sites

I still need something for the factory overrides ( set_type_override / set_inst_override). Do you know anything for this?

In UVM1.0 and later, you can print the factory settings, from e.g. a test class, with :

factory.print();

From the documentation:-

function void print ( int all_types =  1 )

Prints the state of the uvm_factory, including registered types, instance overrides, 
and type overrides.

When all_types is 0, only type and instance overrides are displayed.  When 
all_types is 1 (default), all registered user-defined types are printed as well, 
provided they have names associated with them.
 When all_types is 2, the UVM types (prefixed with uvm_) are included in the 
list of registered types.

Another thing I saw is that check_config_usage() is not called automatically - this is a documentation bug I think because I doubt it should be called automatically.

In UVM1.0EA, check_config_usage() was called automatically. In UVM1.0 & later, you have to call it explicitly..

Share this post


Link to post
Share on other sites

Thanks for the response Bart.

Printing the factory (with all_types = 0) will indeed print all the factory overrides, but that's not what I'm looking for. I don't want to print all the overrides, only the ones that was never used (and I want to see it as a UVM_WARNING)

I guess I'll have to implement something like this myself.

Share this post


Link to post
Share on other sites

Forgot to add - in UVM1.0 & above, you should call check_config_usage() from check_phase() or any of the post-run phases. Reason is that if you are using the configuration mechanism to set run_phase default_sequence properties of sequencers, these are only resolved during the run phase itself. Therefore checking config usage in a pre-run phase (like start_of_simulation) may incorrectly report unmatched default_sequence settings.

Share this post


Link to post
Share on other sites

Thanks for the response Bart.

Printing the factory (with all_types = 0) will indeed print all the factory overrides, but that's not what I'm looking for. I don't want to print all the overrides, only the ones that was never used (and I want to see it as a UVM_WARNING)

I guess I'll have to implement something like this myself.

Yeah OK that's a tougher one..

You can avoid string typos in type overrides by using the set_type_override_by_type variant instead of the set_type_override_by_string. In our experience this reduces override problems considerably.. and any problems you do see are usually to do with incorrect factory registration (wrong name in utility macro) rather than an incorrect type override

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...