In reply to dave_59:
Hi Dave,
Thanks for your reply. I understood the concept and now able to do what I want.
But I faced few difficulties in calling SystemVerilog tasks from C functions to insert delay.
I am receiving Fatal error as below
Fatal: (vsim-3743) DPI task ‘import_task’ returned non-zero value indicating disable when thread was not disabled.
If I comment printf(" C: After calling export function\n"); of C_file.c then it works.
I am unable to execute the remaining lines of C function after calling SV task.
Below is the code that I am trying to run.
//C_file.c
extern int export_task(int *t);
int import_task(int *t)
{
printf("C : Before calling export\n");
export_task(t);
printf(" C: After calling export function\n");
}
//SV_file.sv
program main;
export "DPI-C" task export_task;
import "DPI-C" context task import_task(output int t);
int a;
task export_task(output int t);
$display("SV: Entered the export function . wait for some time : %0d ",$time);
#100 t = $stime;
$display("SV: After waiting %0d",$time);
endtask
initial
begin
$display("SV: Before calling import function %0d",$time);
import_task(a);
$display("SV: After calling import function A=%0d Time=%0d",a,$time);
end
endprogram
//Run commands
vlib work
vlog SV_file.sv C_file.c
vsim -c main -do "run -all; exit"