virtual class A;
virtual function void do_sth_abstract();
$display("A");
endfunction;
task do_sth();
do_sth_abstract();
endtask
endclass
class B extends A;
function void do_sth_abstract();
$display("B");
endfunction
endclass
module top;
initial begin
B b = new B();
b.do_sth();
end
endmodule
If I execute B::do_sth, why does it print “A”? I want to use the class A as an abstract class, which uses the overwritten functions from B.
Only change I made was breaking this into 2 statements (wouldn’t compile):
b = new B();
[EDIT] Also, If you look at 5.6.3 SystemVerilog for Verification (Chris Spear):
“You should avoid declaring a handle and calling the constructor, new, all in one statement. … It can create ordering problems”