Quantcast
Channel: UVM Forums RSS Feed
Viewing all articles
Browse latest Browse all 756

Multithread and automatic variable

$
0
0

Hi , 

For below code , for case-1 and case-2 output is different ,

 

module my_module; 
    int a=0; 
    initial 
    begin 
      for(int i=0;i<5;i++) 
      begin     
         fork 
                // Check differance here , between 2 statements 
                // ##case 1 (declaration and assignment). automatic int j= i;
                // and 
                automatic int j;  // ##case 2 declare 
                j=i;                  //  then assign
                begin
                    $display("Chk auto %d",j);
                end    
         join_none  
      end
    end 
endmodule : my_module

 

For case-1 output is  0 1 2 3 4 

 

For case-2 output is 5 5 5 5 5 

 

Can anyone explain me how??

Thanks , 
Parth


Viewing all articles
Browse latest Browse all 756

Trending Articles