How can we invoke the stop task in ovm_component?

Dear all,
I saw a stop task in ovm_component.
How can we use this task?
Thank you!

Hi,

The stop task is called after a stop request if the component’s enable_stop_interrupt member has been set to 1.

Typically, you would wait within the stop task for some activity to complete - the simulation will continue until all of the stop tasks called have returned.

Here is a simple example that should give you the idea:

class dut_driver extends ovm_driver;
   ...  
   if_wrapper if_wr;

   function new(string name, ovm_component parent);
      super.new(name,parent);
      enable_stop_interrupt = 1;
   endfunction : new

   task stop(string ph_name);
      ovm_report_info("DRV","Waiting to stop");
      wait(if_wr.if1.driver.done == 1);
      ovm_report_info("DRV","Stopping now");
   endtask: stop

   task run();
     ...
   endtask: run
endclass: dut_driver

Regards,
Dave

Hi Dave,

How about this :

initial
begin

ovm_top.stop_timeout=16’h8;

run_test();
end

class dut_driver extends ovm_driver;

if_wrapper if_wr;
function new(string name, ovm_component parent);
super.new(name,parent);
enable_stop_interrupt = 1;
endfunction : new
task stop(string ph_name);

10000ns;

endtask: stop
task run();
ovm_top.stop_request();
endtask: run
endclass: dut_driver

Will the simulation stop after 8ns when run call ovm_top.stop_request?
Thank you!

Hi,

Will the simulation stop after 8ns when run call ovm_top.stop_request?

Yes. You should also get a message 8ns after the call to ovm_top.stop_request telling you that the stop-request timeout has expired.

Regards,
Dave

Hi Dave,
It seem my idea does not work well.
Enclosed is modified from your example.
Is there somethiing wrong when i use stop() task and stop_timeout?
Thank you!

Hi,

Is there somethiing wrong when i use stop() task and stop_timeout?

The problem with your example is that you have commented-out all of the statements in the driver’s run task so there is nothing else for it to do after stop_request is called!

If you restore the driver::run to its original state and call stop_request in the test’s run task then it should work as expected, e.g.

task run;
      tiny_transaction tx;
      tx = new;
      ovm_report_message("", "Called my_test::run");
      fork
         m_env.m_stimulus.generate_stimulus(tx, 10);
         #10 ovm_top.stop_request();
      join
    endtask: run

The output should be

...
# OVM_INFO @ 0: ovm_test_top [] Called my_test::run
# OVM_INFO @ 0: ovm_test_top.m_env [] Called my_env::run
# OVM_INFO @ 0: ovm_test_top.m_env.m_driver [] Called my_driver::run
# OVM_INFO @ 10: ovm_test_top.m_env.m_driver [] Driving cmd = R, addr =           2, data =           1}
# DUT received r0w1 = 0, addr =           2, data =           1 at 10
# OVM_WARNING @ 18 [STPTO] Stop-request timeout of 8 expired. Stopping phase 'run'
# OVM_INFO @ 18: ovm_test_top.m_env [] Called my_env::report
# ** Note: $finish    : /apps/questasim/linux/../verilog_src/ovm/base/ovm_root.svh(308)
#    Time: 18 ns  Iteration: 6  Instance: /ovm_pkg::ovm_root::run_test

Regards,
Dave

Hi Dave,
Could you share me the code and runscript in Questasim?
Thank you!

Hi,

The file is the same as the one you posted with the changes I described. I am including it anyway with a compile options file for Questa.

Regards,
Dave

P.S. you need to remember to use the +OVM_TESTNAME option to run it!

qverilog -f compile_questa.f -R +OVM_TESTNAME=my_test

Hi David long,
You are so kind!
Thanks for your great example and help!

But I still wonder why:

The problem with your example is that you have commented-out all of the statements in the driver’s run task so there is nothing else for it to do after stop_request is called!

why stop_timeout should can not work properly in my case?
why run should be running after stop_request is called?

virtual task run;
ovm_report_message("", "Called my_driver::run");
forever
begin
/*my_transaction tx;
#10
get_port.get(tx);
 
ovm_report_message("",$psprintf("Driving cmd = %s, addr = %d, data = %d}",
(tx.r0w1 ? "W" : "R"), tx.addr, tx.data));
m_dut_if.r0w1 = tx.r0w1;
m_dut_if.addr = tx.addr;
m_dut_if.data = tx.data;
*/
ovm_top.stop_request();
end
endtask: run
 
task stop(string ph_name);
#10000ns;
endtask
endclass: my_driver