In reply to chris_le:
Hi,
The original code is like this.
class A ;
function void disp ();
$display(" Non-Virtual from A ");
endfunction
virtual function void vdisp ();
$display(" Virtual from A ");
endfunction
endclass
class EA extends A ;
function void disp ();
$display(" Non-Virtual from EA ");
endfunction
virtual function void vdisp ();
$display(" Virtual from EA ");
endfunction
endclass
module main ;
function void disp( A a);
a.disp();
a.vdisp();
endfunction
A my_a;
EA my_ea;
initial
begin
my_a = new();
my_ea = new();
disp(my_a);
disp(my_ea);
end
endmodule
Would you let me know why do we have to have virtual to all functions?
Actually, the original example isn’t assigned virtual in non-virtual function as you can see the above code.
So I’ve got the below results,
Non-Virtual from A
Virtual from A
Non-Virtual from A
Virtual from EA
I think this example is how vitual work in Systemverilog. But I didn’t get it, do we need vitual keyword for all function?