Exit parallel phases when watchdog timer expires

I have a watchdog timer set to value ‘n’ cycles. This is started as a separate thread at the beginning of run_phase. I also have a ‘wait’ statement inside my main_phase checking for a particular condition match. In case the ‘wait’ condition does not match even after ‘n’ cycles, I want the simulation to exit main_phase and run_phase and proceed to completion. I am unable to achieve this since my watchdog timer is in run_phase, where as the wait statement is in main_phase. How do I end the main_phase as soon as the watchdog expires? I believe it can be done by passing a variable that can be accessed from both main_phase and run_phase. Is there a simpler way to do this?

In reply to tpan:

Firstly, it is a bad coding style using run_phase and main_phase in the same environment.
To solve your problem you can use a uvm_event.

In reply to chr_sue:

You brought up an interesting point. If I have all of my stimulus being driven in reset/configure/main phases and the run_phase having only the watchdog timer, what are the potential issues with this structure?

The idea is that the watchdog timer polices the overall simulation time from start to finish. I don’t care how long each individual phases take as long as the overall time is below the watchdog timer limit.

In reply to tpan:

If you are using the sub-phases of the run_phase you have to consider the relationships between these phases. The pre_reset_phase starts with the run_phase and the run_phase ends with the post_shut_down_phase. You might jump back and forth with the sub-phases ending up in a big confusion.