Jump to content

Getting the Current Phase


Recommended Posts

Let's say that hypothetically you want a task that is spawned by the run phase to be able to print out the name of the currently running run-time phase (ie are we in the reset, configure, main, or shutdown phase)?

How could you do it? There doesn't seem to be any function or field that would implement uvm_top.get_current_phase().

My solution is not particularly elegant, so I'm wondering if there is a better one. Basically, I have a component that has a field:

uvm_phase current_phase;

And then I implement every single run-time phase to set the current_phase field to be the phase that's passed in.

virtual task pre_main_phase(uvm_phase phase);
   current_phase = phase;
endtask

virtual task main_phase(uvm_phase phase);
   current_phase = phase;
...

Again, not very elegant.

Any thoughts?

Link to comment
Share on other sites

The same can be achieved with the UVM phase_started function.

virtual function void phase_started(uvm_phase phase);
  super.phase_started(phase);
  current_phase = phase;
endfunction : phase_started

Ah, that is far more clever.

I still feel like the uvm_root component should have a get_current_phase function, though.

Thanks!

Link to comment
Share on other sites

hi,

the reason that there is not get_current_phase() is very simple. there is simply NO single current phase. at any time there is a SET of active phases (during simulation time it would be "run" + one of the 12 runtime phases + any user defined phases). the only way to know a "current" phase is to hook into the notification from the phasing system (phase_started, phase_ended and the xxxx_phase tasks). this however is only safe until "time" is spend (because the phaser could proceed to the successor phases (could be a set!), or jump, ...)

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.

 Share

×
×
  • Create New...