User guide
24-51
SystemVerilog Testbench Constructs
endfunction
endclass
class EtherPacket extends BasePacket;
function integer send(bit[31:0] data)
// body of the function
...
endfunction
endclass
EtherPacket is now a class that can be instantiated.
If a subclass which is extended from an abstract class is to be
instantiated, then all virtual methods defined in the abstract class
must have bodies either derived from the abstract class, or provided
in the subclass. For example:
program P;
virtual class Base;
virtual task print(string s);
$display("Base::print() called from %s", s);
endtask
extern virtual function string className();
endclass
class Derived extends Base;
function string className();
return "Derived";
endfunction
endclass
Derived d = new;
initial #1 d.print("");
endprogram