In reply to dave_59:
Thanks Dave,
I found that I can’t delay the execution of C code which requires outside simulator inputs.
i.e.
//SV_file.c
program main;
import "DPI-C" context function void import_task();
initial
begin
$display("SV: Print 1 %0t",$time);
#10000;
$display("SV: Print 2 %0t",$time);
for(int i=0; i<3; i++) begin
import_task();
end
$display("SV: Print 3 %0t",$time);
end
endprogram
//C_file
#include <stdio.h>
#include "cimports.h"
void import_task()
{
int a;
printf("Please input an integer value: ");
scanf("%d", &a);
printf("\nYou entered: %d\n", a);
}
//Simulation OUTPUT
run -all
1
2
3
SV: Print 1 0
SV: Print 2 10000
Please input an integer value:
You entered: 1
Please input an integer value:
You entered: 2
Please input an integer value:
You entered: 3
SV: Print 3 10000
Here I have two display statements before calling C function though I have to enter 3 inputs before SV simulation begins.
No doubt I got the outputs of C function on simulation time. But I have to delay execution of C function after displaying two statements. Is is possible?