Process is existing as a dreference error during the sim

User: "JainamShah"
Altair Community Member

class processtest;
  process p[];  event ev[];
  function new(); 

  p = new[5];

    ev = new[5];

  endfunction
  task start_prcess(int idx,int delay);

    fork

      begin 

      $display("starting process for idx=%d tiem: %0t",idx, $time);   

    p[idx] = process::self;

     wait(ev[idx].triggered); 

      $display("process is done idx=%d time: %0t",idx, $time );   

  end  

  join_none   

endtask
  function void process_accepted(int idx); 

  ->ev[idx];
  endfunction 

function void print_process_status(int idx);

    process::state pstat;
    pstat = p[idx].status(); 

  $display("idx=%d process_status=%d", idx,p[idx].status);
  endfunction

endclass

module process_test;

  initial begin

    static processtest pt = new(); 

  pt.start_prcess(0,100);   

pt.start_prcess(1,100); 

  pt.start_prcess(2,10); 

  pt.start_prcess(3,1000); 

  pt.start_prcess(4,200); 

     pt.print_process_status(0); 

  pt.process_accepted(1); 

  endmodule

when I run this code I get following error which I am not able to explain. If I remove the pt.print_process_status(0); then this error goes away

S:Begin run-time elaboration and static initialization...=N:[dumpMXD] preparing MXD dump to 'waves.mxd'.=N:[dump] Dump started at time 0=N:Starting event scheduler...=F:[NullRef] null handle 'p' dereferenced @ testbench \processTest.sv:41:14=N:[dumpMXD] closing MXD dump=T:Simulation terminated due to null handle dereference.=N:Backtrace:


PS: is there a better way to put the code in the question?

Find more posts tagged with

Sort by:
1 - 4 of 41

    It is better to attach your source code as files rather than paste their contents as comments.

    Did you look at line 41 of processTest.sv? That's what the error message says:

    =F:[NullRef] null handle 'p' dereferenced @ testbench \processTest.sv:41:14

    Did you initialize 'p'?

    User: "d3jones"
    Altair Employee

    Subtle point: when you fork…join_none, the children do not start running until the parent blocks. In your code, you have the parent call print_process_status() immediately after forking. If no process has started at that point then the p array will be uninitialized.

    Try adding a #0 just before the call to print_process_status() to see if behavior changes. That will delay the parent into the inactive region, allowing the children to start in the active region and initialize the array.

    User: "JainamShah"
    Altair Community Member
    OP

    Yup this was the case. some other simulator ignored it . Thanks for catching it

    @JainamShah Did d3jones comment resolve your issue? If so, could you please mark it as "Accepted"?