PDA

View Full Version : Local variable of one class is used in the function of some different class



vikassinghal21
01-17-2008, 04:28 AM
Code snippet from src/base/ovm_connector_base.svh:
class ovm_connector #( type IF = int ) extends ovm_connector_base;

typedef ovm_connector #( IF ) connector_type;

local int unsigned if_mask;

local ovm_if_container #(IF) m_if_container;

ovm_port_base_base #(IF) port_h;
...
endclass

Lines from src/base/ovm_connector_base.svh: typedef ovm_connector #( IF ) connector_type;

Lines from src/base/ovm_port_base.svh:
function int size(); // function of class ovm_port_base
return m_connector.m_if_container.size();
//return m_connector.size();
endfunctionin the above example m_if_container is defined as local variable in class ovm_connector and this local variable is accessed in the function size of class ovm_port_base, which, I think, is the wrong usage according to the definition of local.
Some lines from LRM:
A member identified as local is available only to methods inside the class. Further, these local members
are not visible within subclasses. Of course, nonlocal methods that access local class properties or methods
can be inherited and work properly as methods of the subclass.

dlong
01-17-2008, 06:39 AM
in the above example m_if_container is defined as local variable in class ovm_connector and this local variable is accessed in the function size of class ovm_port_base, which, I think, is the wrong usage according to the definition of local.
Some lines from LRM:
A member identified as local is available only to methods inside the class. Further, these local members
are not visible within subclasses. Of course, nonlocal methods that access local class properties or methods
can be inherited and work properly as methods of the subclass.

Looks like a simple typo to me in converting the code from AVM rather than a misunderstanding of the LRM. I think the code should read:



function int size(); // function of class ovm_port_base
return m_if_container.size();
endfunctionRegards,
Dave
==============
David Long
Doulos
http://www.doulos.com

vikassinghal21
01-17-2008, 06:56 AM
It means, this problem will be rectified in the next release of OVM.

dlong
01-17-2008, 07:19 AM
I know that members of the OVM team from Cadence and Mentor are keeping an close watch on this forum - I am sure they will make every effort to fix these type of bugs and will encourage users to report them here.

Regards,
Dave
================
David Long
Doulos
http://www.doulos.com

tfitz
01-17-2008, 07:28 AM
I know that members of the OVM team from Cadence and Mentor are keeping a close watch on this forum - I am sure they will make every effort to fix these type of bugs and will encourage users to report them here.

Absolutely! That's part of what this forum is for.
Thanks, Dave!