Verification Guild
A Community of Verification Professionals

 Create an AccountHome | Calendar | Downloads | FAQ | Links | Site Admin | Your Account  

Login
Nickname

Password

Security Code: Security Code
Type Security Code
BACKWARD

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Modules
· Home
· Downloads
· FAQ
· Feedback
· Recommend Us
· Web Links
· Your Account

Advertising

Who's Online
There are currently, 71 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here

  
Verification Guild: Forums

 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile  ProfileDigest    Log inLog in 

Question: Virtual Interface Defined In Constructor

 
Post new topic   Reply to topic    Verification Guild Forum Index -> Main
View previous topic :: View next topic  
Author Message
spartanthewarrior
Senior
Senior


Joined: Aug 15, 2009
Posts: 32

PostPosted: Sun Mar 11, 2012 7:04 am    Post subject: Question: Virtual Interface Defined In Constructor Reply with quote

Hi All,

I have (Class A)

class a;

function new(virtual mem_interface.MEM mem_intf_new,
virtual input_interface.IP input_intf_new,
virtual output_interface.OP output_intf_new[4] );

this.mem_intf = mem_intf_new;
this.input_intf = input_intf_new;
this.output_intf = output_intf_new;
endfunction

endclass //-- End Of Class A

class b extend a;

function new();
super.new();
endfunction

endclass

Question: How to pass arguments in (super.new) function when we have virtual interface
Back to top
View user's profile
Logger
Senior
Senior


Joined: Jun 15, 2004
Posts: 340
Location: MN

PostPosted: Mon Mar 12, 2012 12:10 am    Post subject: Reply with quote

If you are simply looking to pass values through, you'd do this.

Code:

class b extend a;

    function new(virtual mem_interface.MEM   mem_intf_new,
                 virtual input_interface.IP  input_intf_new,
                 virtual output_interface.OP output_intf_new[4] );

        super.new( mem_intf_new, input_intf_new, output_intf_new );

    endfunction

endclass


But don't get carried away with putting parameters in your constructors. I'd recommend not putting parameters in constructors unless you know what you're doing. It makes it extremely painful to refactor your code to use a factory pattern later on. UVM uses a factory pattern to good effect. If you don't use UVM, you can make your own factory, but constructor parameters become problematic.

If you're just learning the language with throw away code, this isn't a big deal. On the other hand, if you're writing code that is going to have a long life span, you'll thank yourself later. Now, how to accomplish the above without passing it in via the constructor, well that's a whole 'nother question.

-Ryan
Back to top
View user's profile
spartanthewarrior
Senior
Senior


Joined: Aug 15, 2009
Posts: 32

PostPosted: Tue Mar 13, 2012 4:15 am    Post subject: Reply with quote

thanks much !!

it worked.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Verification Guild Forum Index -> Main All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Verification Guild © 2006 Janick Bergeron
Web site engine's code is Copyright © 2003 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.113 Seconds