IMPORTANT NOTICE: Please be advised that the Verification Academy Forums will be offline for scheduled maintenance on Sunday, April 6th at 2:00 US/Pacific.
I export a dynamic task to C++ test bench, but the task looks skip forever loop.
How can I resolve it?
export "DPI-C" task freq;
task automatic freq(); // global task
bit a = xDUV.aa;
bit b = xDUV.bb;
$display($time,">>> a= %b, b=%b", a, b); // display OK
fork
forever begin: checking
$display("forever start"); // No displaying
@(negedge b)
$display($time,"b enabled");
@(posedge a);
@(posedge a)
if(!b)
$display($time,"ERROR");
disable checking;
end
join_none
endtask
The variables ‘a’ and ‘b’ are assigned values when the task is called. These values will never change, hence it appears that your forever loop never executes.
the frever loop never executes if assigned value would not be chaged. But even though I think the first $diaplay(“forever start”) should be worked.
I re-tested your comment as below, but the first display works well in usual verilog task call, not by DPI-C.
//export "DPI-C" task freq;
//Call in verilog module
task automatic freq(); // global task
bit a = 1;
bit b = 1;
$display($time,">>> a= %b, b=%b", a, b); // display OK
fork
forever begin: checking
$display("forever start"); // diaplay OK
@(negedge b)
$display($time,"b enabled");
@(posedge a);
@(posedge a)
if(!b)
$display($time,"ERROR");
disable checking;
end
join_none
endtask