VPI: which Verilog task is running

Hi guys, I have a basic question since I started with VPI and couldn’t find any answer for that.
Let’s say I have this Verilog code:


module test;
    wire a, b, c;
    pipe p1 ( a, b, c );
	task t1;
		begin
			#100ns;
			$display("display:Inside task1: %t", $realtime);
		end
	endtask
	
	task t2;
	  begin
	  #200ns;
	  $display("Inside task2");
	  end
	endtask
	
	task t3;
	  begin
	  #300ns;
	  $display("Inside task3");
	  end
	endtask
	
	//Experiment
	initial
	begin
	t1;
	#50ns;
	t2;
	#30ns;
	t3;	
	end
	
endmodule

and I want to see which task is running during the simulation besed on VPI programming. I am looking for C function to retrieve data and show me the current task (t1, t2, t3)is running.

Thanks for your answer.

In reply to Alireza MokhtariDoust:

You want to look at section 37.41 Frames in the 1800-2017 LRM

In reply to dave_59:

In reply to Alireza MokhtariDoust:
You want to look at section 37.41 Frames in the 1800-2017 LRM

Dear Dave, I went through this but couldn’t achieve what I was looking for. I could only print the systemTask name, but not the task name.I want something like $stacktrace; that prints

Verilog Stack Trace:
0: task test.t1 at ./test.v:17
1: initial block in test at ./test.v:37

How can I print “t1” without using stacktrace?

Thanks

In reply to Alireza:

Where did you put your system task? You did not show it. You are going to have to share a lot more code to see what might be going wrong.

In reply to dave_59:

Dear Dave, Thanks for your reply. Here is my C code:


#include "vpi_user.h"
#include "vpi_user_cds.h"

int gnt_task (){
vpiHandle netHndl;
netHndl = vpi_handle(vpiFrame, 0);
vpi_printf("Name of task: %s\n", vpi_get_str(vpiTask, netHndl));
vpi_printf("Name of task: %s\n", vpi_get_str(vpiName, netHndl));
}

void register_my_systfs(){
s_vpi_systf_data task_data_s;
p_vpi_systf_data task_data_p = &task_data_s;
task_data_p->type = vpiSysTask;
task_data_p->tfname = "$peripheri";
task_data_p->calltf = (int(*)()) gnt_task;
task_data_p->compiletf = 0;
vpi_register_systf(task_data_p);}

and my verilog code:


module mymux21test ;
reg m;
reg s;
pipe p1 ( a, s, m);
task t1;
  begin
    m = 1'b0 ;
    s = 1'b0 ;
    #50
    m = 1'b1 ;
    s = 1'b1 ;
    #100
    s = 1'b0 ;
    #100
    $display("display time: %t", $realtime);
    $peripheri(p1);
    $stacktrace;
  end 
endtask

task t2;
  begin
    m = 1'b0 ;
    s = 1'b0 ;
    #50
    m = 1'b1 ;
    s = 1'b1 ;
    #100
    s = 1'b0 ;
    #100
    $display("display time: %t", $realtime);
    $peripheri(p1);
    $stacktrace;
  end 
endtask
initial  
    begin
		t1;
		#10
		$peripheri(mymux21test.p1);
		$display("display time: %t", $realtime);
		#100
		t2;
		$finish;
     end
endmodule

it is just simple code that runs two tasks t1 and t2 and I wanna print the task name t1 and t2 during the simulation.
I tried with vpiFrame and vpiTask, but I think I didn’t put in an appropriate place. These are all information I have.