Jump to content
Sign in to follow this  
cliffc

UVM phase method names and arguments - are they really necessary?

Recommended Posts

Hi, All -

UVM uses a different phase-calling syntax than OVM. Examples:

function void build_phase(uvm_phase phase);

super.build_phase(phase); ...

task run_phase (uvm_phase phase); ...

I see the value of having "phase" with the run_phase(s) because I am going to do:

phase.raise_objection(this);

phase.drop_objection(this);

But I am trying to understand why I would use this syntax with function-phases where I will not raise/drop objections. In fact, in the src/base/uvm_component.svh file, the code for the connect_phase() is the following:

function void uvm_component::connect_phase(uvm_phase phase);

connect();

return;

endfunction

So the function just appears to call the simpler-syntax connect() method. I had a student in UVM training that chose to use the simple names and the labs worked just fine. Only the final_phase() does not have a simpler OVM counterpart and there is also a final keyword in the SystemVerilog language.

Any experts care to comment on the more complex calling syntax with no readily apparent value?

Regards - Cliff Cummings

www.sunburst-design.com

Share this post


Link to post
Share on other sites

As far as I recall, it was for symmetry.

Also, should accessing the phase object be useful/necessary in a future release, this approach made it readily accessible. It would not have been possible to add this argument in a subsequent release as you cannot modify the signature of virtual methods in SV.

Share this post


Link to post
Share on other sites

Thanks, Janick -

I had a hunch that this capability might be related to reserving the capability for a future enhancement, although I can't imagine what that enhancement might be for the function phases (hence, the term enhancement!)

Good point about setting the prototype signature for that possible future enhancement, although it could be argued that using the existing phase names would still allow the creation of the name_phase(uvm_phase phase) syntax in the future when such enhancements made sense. Considering the much simpler syntax of the old function-phase() name syntax, and am mildly inclined to promote the older syntax until I can justify the extra verbosity of the newer syntax. I will have to think this one through. It would mean that the final_phase() would be an exception and exceptions can be equally confusing.

Regards - Cliff Cummings

www.sunburst-design.com

Share this post


Link to post
Share on other sites

The phase methods without the "*_phase(uvm_phase phase)" signature were never part UVM. They were left there to ease migration from OVM to UVM and are officially deprecated.

Thou shalt not use them.

Share this post


Link to post
Share on other sites

Cliff,

The older syntax is already deprecated - it's only there for backward compatibility with OVM. You will create confusion if people assume that connect and connect_phase are just syntactic synonyms for each other and people start extending their classes with connect() from classes already using connect_phase()or vice versa - these methods will not be called in the right order.

I can see some purpose in using the phase argument when calling common routines for reporting or debugging to know which phase you were called from.

Share this post


Link to post
Share on other sites

Okay, Janick & Dave have convinced me to keep teaching the proper name_phase(uvm_phase phase) syntax. I was wavering, but when Janick used the "Thou shalt not use them" commandment, I decided to obey!

Dave - have you used the phase argument in any reporting and debugging calls from the function phases?

Regards - Cliff Cummings

www.sunburst-design.com

Share this post


Link to post
Share on other sites

have you used the phase argument in any reporting and debugging calls from the function phases?

No, only with the time consuming phases. My point was that knowing what phase you are in could be used for something other than objections, not that I was promoting its use.

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  

×