Jump to content
Sign in to follow this  
mastrick

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.

Share this post


Link to post
Share on other sites

yes, basically you got two options:

1. a local flag identifying correct super.function usage (set when super.function is invoked, checked when used)

2. use a linter which is capable to check super.function invocation

/uwe

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×