According to the LRM Section 5.5, the default qualifier for lifetime is static.
But the following code seems to be a counter-example.
Anyone can help on this?
Thanks.
If declare the wait_and_echo() as
task wait_and_echo();
OR
task automatic wait_and_echo();
then the output will be
obj name: B, value: 00000001
obj name: B, value: 00000002
obj name: A, value: 00000001
obj name: A, value: 00000002
If declare the wait_and_echo() as
task static wait_and_echo();
then the output is,
obj name: A, value: 00000001
obj name: A, value: 00000002
obj name: A, value: 00000003
obj name: A, value: 00000004
Code
class A;
int value;
string name;
function new(string s);
name = s;
value = 0;
endfunction // new
function void build();
fork
wait_and_echo();
wait_and_echo();
join_none;
endfunction; // build
//task automatic wait_and_echo();
//task static wait_and_echo();
task wait_and_echo();
//wait($time == 1000);
#1000;
value++;
$display("obj name: %h, value: %h", this.name, value);
endtask // wait_and_echo
endclass; // A
class B extends A;
function new(string s);
super.new(s);
endfunction // new
endclass; // B
module top;
initial begin
A a_h;
B b_h;
a_h = new("A");
a_h.build();
b_h = new("B");
b_h.build();
end
initial begin
#2000;
end
endmodule // top