So what all have been added in Systemverrilog ?
In Verilog, we are familiar with module :
module test;
...
.....
endmodule
If a module has interfaces, it shall look like :
module test(in_1, out_1);
in in_1;
out out_1;
...
.....
endmodule
In Systemverilog, Classes are user-defined data types. SV has moved towards Object Oriented Programming and all the basic implementations of C++ kind of language added to create Systemverilog. Object Oriented Programming (OOP) is a programming language philosophy which wraps data in a container and define ways to write functions and tasks inside container that shall operate on the set of data. In addition, the creation of objects out of these classes are created with a concept named constructor. Similarly, to destruct the object, another concept destructor is implemented.
Overall, Classes are used for abstracting the data set within a container.
class Test;
int p;
function new(string name = "Test");
$display("Constructor");
endfunction: new
task set (int i);
x = i;
endtask
function int get;
return x;
endfunction;
endclass
The object creation can be done as follows -
Test t = new();
If there is a testbench, the class object can be created and the task/functions can be used as follows -
initial
begin
t.set(10);
$display("Test class item x = %d", t.get());
end
-------------------------
Inheritance
An important part of Object Oriented Programming is Inheritance where classes can be derived from another class. That means, A class can have all the data items of the base class and in addition, may have extended set of data items. The class which extends the base class is called derived class and owns all the properties of base class. The derived class may have new properties, can implement more functions and tasks to operate on the internal data items.
The implementation of inherited class is as follows -
class derivedTest extends Test;
int p;
function new(string name = "derivedTest");
super.new() // This shall ensure object creation of the base class.
endfunction: new
task setp(int j);
p = j;
endtask
function getp;
return(p);
endfunction
endclass
In derivedTest, the data items are introduced in addition to base class data items. the derived class may have more functions/tasks to operate on data items.

