Jump to content

Ensuring users call super.function()


Recommended Posts

We have created some classes that extend uvm classes and add functionality to some of the uvm virtual functions. Our end users are supposed to extend those new classes and if they need to extend those same functions, they must call super.function(). If they forget to call the super version for some of the extended functions, they can get very strange broken behavior. Does anyone have a good idea on how to prevent such a problem? My best idea so far is to have our centralized extensions update flags and check the flag status of functions that should have been called previously, so that if a super version is not called, that flag will not be set and the next inherited function called will report an error based on that missing flag.

Link to comment
Share on other sites

Using flags is a bit messy, better of just writing a simple uvm_linter to check within function foo endfunction that super.foo() has been used.

if you use flags, you need one flag per object, then a flag for each derived object and you will need to maintain the flags for each derived object and each constructed object seperately

Make sure you test it with a combination of multiple-derivation and single-derivation objects in the same testcase.

-adiel.

Link to comment
Share on other sites

We have created some classes that extend uvm classes and add functionality to some of the uvm virtual functions. Our end users are supposed

<SNIP>

My best idea so far is to have our centralized extensions update flags and check the flag status of functions that should have been called previously, so that if a super version is not called, that flag will not be set and the next inherited function called will report an error based on that missing flag.

VMM (1.0/1.1) did precisely that for vmm_env::gen_cfg etc. and it was well accepted by the users. Yes it can be little messy/complicated for the developer(s), but it works well for end users.

Ajeetha, CVC

www.cvcblr.com/blog

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...