How to understand the run_phase in the uvm test

Hi All,

I have the code as shown below for a simple uvm test. But it hangs in the run_phase of my_driver at the beginning. any suggestion is welcome.

======== Here is my_test.sv =========
class my_test extends uvm_test;

endclass
task my_test::run_phase(uvm_phase phase);
super.run_phase(phase);
phase.raise_objection(this);


endtask

======== Here is my_driver.sv ===========
class my_driver extends uvm_driver

endclass
task my_driver::run_phase(uvm_phase phase);
my_transaction trans;
forever begin
seq_item_port.get_next_item(trans); <== here is the hang point


seq_item_port.item_done();
end
endtask : run_phase

In reply to zz8318:

If the driver hangs when calling get_next_item no seq item is available. get is a blockig method.
The test does not show what you are doing in this run_phase.

In reply to chr_sue:

In the run_phase of my_test, I tried to start the sequence as shown below.

task my_test::run_phase(uvm_phase phase);

super.run_phase(phase);
phase.raise_objection(this);
wait_cycle(100);    // customized task...
my_sequence my_seq;
......
my_seq.set_starting_phase(phase);
my_seq.start(...);
phase.drop_objection(this);

endtask : run_phase

Actually I set a breakpoint at phase.raise_objection in the run_phase above. But it never is reached…

Thank you !!!

In reply to zz8318:

Why are you calling

wait_cycle(100); // customized task...

What kind of cycles you want to wait?
The test does not know anything about clock cycles. Maybe your test is stucking there.
Do you construct your sequence? This not shown in your code.

In reply to zz8318:

You are not showing enough code that indicates where the problem might be. Since you are able to set breakpoints, you should be able to step through your code and find the problem.

In reply to chr_sue:

The test never reaches to the first line in run_phase() of my_test… So we don’t need to care what is wait-cycle() actually…

In reply to dave_59:

I set the breakpoint but it never hit. I wonder why the first line of run_phase() in my_test is never reached…

In reply to zz8318:

In reply to chr_sue:
The test never reaches to the first line in run_phase() of my_test… So we don’t need to care what is wait-cycle() actually…

Then you do not run the test. How do you start the test. Do you this from the command line?

In reply to zz8318:

Please make sure:

  • All other phases (from build_phase to start_of_simulation_phase) before run_phase are completed. Set breakpoint/display in those phases and check if they show on screen or not.
  • Please check all forever loops such as forever, while(1), etc. in your run phase or sub-phases (pre_reset to post_shutdown) of all your components that don’t comsume time (zero time).

If everything is ok, then please show us more detail about your code, you can create and post your code to edaplayground if possible. Your current code is not enough for us to help.

In reply to chr_sue:

In our current testbench (which is developed for a long time…) The run_test is called by uvm_test_top. I don’t think run_test() is not called at all…

Let me take a further look and provide more details if need help. Thank you

In reply to chris_le:

I’ll try to do that referring to your 1st suggestion . Thank you .

May I know how to understand your 2nd suggestion ? It is correct or not if I have forever loop in the run_phase of the components ?

In reply to zz8318:

In reply to chris_le:
I’ll try to do that referring to your 1st suggestion . Thank you .
May I know how to understand your 2nd suggestion ? It is correct or not if I have forever loop in the run_phase of the components ?

If you have a forever loop that doesn’t consume time (zero time statements), your simulation will hang at that loop. This is very popular issue.

But a forever loop that consumes time such as your driver component is ok (your driver will be blocked at get_next_item and finish when all objection are dropped in run_phases of all other components).

In reply to chris_le:

Thanks so much ! I debug the test and make some progress now with your suggestion !