Hi,
I am trying the following code
class A;
task body(); // Class suboutines are automatic by default
for( int i = 0 ; i < 4 ; i++) begin
int j = i ; // Is 'j' automatic by default as 'body()' is automatic ?
fork
$write("%0d_",j);
join_none
end
endtask
endclass
module tb;
A a1;
/*initial begin :B1
for( int i = 0 ; i < 4 ; i++) begin
int j = i ; // Is 'j' static by default as 'initial' is static ?
fork
$write("%0d_",j);
join_none
end
end*/
initial begin:B2
a1 = new();
a1.body();
end
endmodule
I have a few questions on working of above code
(Q1) Given that the body() task is automatic by default, is the variable ājā automatic by default as well ?
(Q2) Does the LRM define the exact output for the for-loop within body() ?
Some tools give output as 0_1_2_3_ whereas some give output as 3_2_1_0_
(Q3) On uncommenting B1, why do I observe a compilation error for statement int j = i ;
As initial is a static procedural block, would ājā be static by default ?
I notice that on re-writing it as automatic int j = i; the compilation issue is resolved
With the explicit automatic declaration, the output differs across tools ( similar to Q2 )
Thanks in advance,
Arshi