Systemverilog : scope

Hi :
In below code, Can I say the object classHandle points to( line 10) is destructed when the block2 exits ?
Second question : When an initial block(thread) exits, Is this initial block thread killed ? or exists until to end of simulation.

Thanks


   module test;
     initial begin : block1
      $display(..);
      ....

      begin : block2
        classType classHandle = new();   -->line 10
        ....
      end :block2

      ...
     end : block1
endmodule

In reply to VE:

In below code, Can I say the object classHandle points to( line 10) is destructed when the block2 exits ?

No. It depends on what happens in your “…” ( line 11 ) and in your class constructor. If you do anything there that results in preserving a handle to the object, the object will live on. Also, even if the object is in a state where it could be destroyed, it can hang around until the garbage collector decides it needs to remove it.

Second question : When an initial block(thread) exits, Is this initial block thread killed ? or exists until to end of simulation.

Assuming it wasn’t killed or blocked, it should just finish once the last statement has executed.

In reply to VE:

The code you wrote is illegal according to the LRM. You are not allowed to place initializations on variables whose lifetimes implicitly default to static. See function arguments not initializing variable inside the body | Verification Academy