Reputation: 21
Can I instantiate virtual interface? what is the syntax? for example : if I've the following interface:
interface if ( input in1, in2, output out1, out2 ); endinterface
virtual interface if vif;
can I instantiate vif ?
Upvotes: 0
Views: 890
Reputation: 792
Virtual interfaces can only have , another virtual interface or a instance of the interface or null assigned to it .
ifs m_ifs () ;
vifs = m_ifs ; // valid
vifs = vifs1 ; // valid
vifs = null ( this is the default value if unassigned)
If you mean
vifs = new () or new (if ) ;
something like the statement above is not allowed .
You could do this instead
Class interface_container {
virtual interface ifs vifs ;
} ;
interface_container m_interface_container[2] ;
m_interface_container[0] = new () ;
m_interface_container[1] = new () ;
So now you have 2 instances of vif within instances of the two class BUT
you still have to assign a interface instance to them . Interface instance itself cannot be dynamic as they represent physical connections.
m_interface_container[0].vifs = m_ifs ;
m_interface_container[1].vifs = m_ifs ;
So there can be many virtual interfaces , yet all the virtual interfaces ( if not null ) will eventually point to some fixed set of interface instances.
Upvotes: 1