Hi, this is the code i tried to execute,
class base;
static int i;
static function get();
int a;
a++;
$display(a);
endfunction
endclass
module top;
initial begin
base b1,b2;
b1.get();
b1.get();
b2.get();
end
endmodule
the output was
1
1
1
why a is incrementing only once? and can we declare a non static variable inside a static function?
Can anyone please explain the operation of this code…
and if I declare the same function as
static function static get()
i am getting the output
1
2
3