I don’t know if anyone has reported this earlier or not.
Tasks/Functions defined as ‘protected’ in any OVM based driver(extended from ovm_driver, or even take xbus_master_driver of xbus example) are fully visible outside the class.–Means accessible through hierarchy of instances in testcase.
However if I am not wrong, any ‘protected’ members functions/variables of a class are same as ‘local’ except when it comes to inheritance. Which means protected variables/methods should not be accessibleusing class’s instance.
Strangely ovm_driver’s protected methods are accessible which is not true for any other OVM based class or even non-OVM simple system verilog class.
I don’t know if anyone has reported this earlier or not.
Tasks/Functions defined as ‘protected’ in any OVM based driver(extended from ovm_driver, or even take xbus_master_driver of xbus example) are fully visible outside the class.–Means accessible through hierarchy of instances in testcase.
However if I am not wrong, any ‘protected’ members functions/variables of a class are same as ‘local’ except when it comes to inheritance. Which means protected variables/methods should not be accessibleusing class’s instance.
Strangely ovm_driver’s protected methods are accessible which is not true for any other OVM based class or even non-OVM simple system verilog class.
Any clues why so?
PS: Try it with xbus example.
Even the ‘local’ members defined in driver(ovm_driver) are also accessible using class instance!!
Please find the attached 3 files, Replace them into original xbus example (of ovm-2.0.1)
xbus_master_driver
xbus_master_monitor
test_lib
All I have done is, Added following method into master driver and monitor classes. local virtual function void local_fun();
$display(“Monitor, inside local_fun”);
endfunction
From testcase I have called both the methods using hierarchial reference.
Results:
For monitor’s function it shouts an error as “Access is denied”
For driver’s function, sim works fine and I am able to see the Display statement in LOG too.
i think that you used “local” for a method, not for a member. Local member cant be accessable, but local method can be accessable. Because the method is the interface for a class.
i think that you used “local” for a method, not for a member. Local member cant be accessable, but local method can be accessable. Because the method is the interface for a class.
No that’s not the case.
I am sure SystemVerilog has same meanings to access specifiers local, protected and public what C++ has to private, protected and public respectively.
As per OOP, private members (variables or methods) cannot be accessed using class instance outside the class. Only another method inside the same class can access it!
Please check the information below:
Hiding data members inside a class and allowing their value to be changed or viewed only
through well defined methods also defined in that object leads to fewer programming errors
compared to where object data members can be changed in an ad hoc manner. System Verilog
provides the keywords local and protected to hide object data members. Properties marked
as local can be read and modified only by methods defined in the same class. Properties
marked as protected can be read and modified by methods defined in that and all classes
derived directly or indirectly from the class containing that property.
It come from the book of step-by-step functional verification with sv and ovm. That may be answer your question exactly.
System Verilog
provides the keywords local and protected to hide object data members. Properties marked
as local can be read and modified only by methods defined in the same class…
Here if you’re considering meaning of ‘object data members’ as Variables (like int, bit etc) and not Methods (like task,function etc.)
Then, This does not mean that SV provides local and protected access specifiers for ONLY object data members.
If you refer LRM, we do have ‘local’ and ‘protected’ access specifiers for Tasks and Functions.
Also, Give a quick practical try.
Take any simple non-ovm class, define task/function as ‘local’ and try to access it outside the class
using class instance. It will result into immediate Error.
For your question, you can read some paper about the syntax of systemverilog. I find a explanation in the sv 1.3a that ‘local’, ‘protected’, ‘virtual’ and so on may be not used together for a member in a class. You can find out it with ‘local’ as key word in the sv 1.3. But if it is the answei to your question, i dont know.
The SV3.1a LRM is really old; much older than the first iPhone, and older than the first release of the Firefox Web browser. Please update to the IEEE 1800-2009 LRM
local and protected may not be used together on the declaration of a member or method of a class. However there’s nothing illegal about ‘local virtual’ on a method even though it is useless to do so.