#
In system verilog all the properties of the class are public by default or we can say it be accessed outside the class directly using the dot operator. If we want to protect the access of the class variables/properties from outside the class we can use the local keyword. Hiding the properties from being accessed outside the class is called encapsulation.
If we want to make the properties accessible in the extended classes but not outside the classes. We can declare the properties as protected. Then it will be available in the extended classes but not in the main program.
01.
class
base;
02.
local
logic
b1;
03.
protected
logic
c1;
04.
05.
function
new
(input
logic
pone);
06.
b1 = pone;
07.
endfunction
08.
endclass
09.
10.
class
sub1
extends
base;
11.
integer length;
12.
13.
function
new
(input
logic
pone);
14.
super.
new
(pone);
15.
endfunction
16.
endclass
17.
18.
class
sub2
extends
sub1;
19.
...
20.
function
new
(input
logic
pone);
21.
super.
new
(pone);
22.
endfunction
23.
endclass