Jump to content

UVM Sequencer base class - Virtual task using local class variables - bad coding style?


Recommended Posts

I see uvm_sequencer_base::wait_for_grant (UVM 1.1d) is a virtual task but accesses a local int g_request_id - is this not a bad coding style? If I were to override this virtual method for debug with much of the code intact tool throws an error for his local bar in a derived SQR class. I extended a SQR class and copied all the code for wait_for_grant and started tweaking - couldn't proceed with that debug due to this member being local. Should it be protected instead of local?

Thanks
Srini
wwww.go2uvm.org

Link to post
Share on other sites

hi,

 

normally there is nothing bad with the fact to access a local member from a virtual function/task. functionality should be exposed via functions/tasks and never via member fields. in that sense opening the access to the local implementation detail g_request_id would be the wrong solution. the right course of action would be to encapsulate the static member g_request_id into an atomic accessor like in java AtomicInteger::incrementAndGet() and expose that in the base class instead. 

in this particular situation you can probably use an own id generator instead....

 

 

/uwe

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...