Multi thread in DPI-C structure

Hi,

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

c++ code


extern "C" void freq(void);
void TEST()
{
  freq();

  sim_printf("[INFO] Mask Test\n");  // display OK
  ....
  ....
}

In reply to uvmbee:

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.

In reply to cgales:

Thx cgales,

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