Re: [sv-ec] How do I make a "Virtual Port"

From: <jonathan.bromley_at_.....>
Date: Fri Oct 03 2008 - 01:15:44 PDT
Tom

> class RegisterAccess ; 
>    logic        myPwrUp;
>    logic [15:0] myRegWr;
>    logic [15:0] myRegRd;

But... these will be variables (data members) of the object.
I suspect you would like them to be references to some
real signals in the module-based world outside the class?
 
>    function new(logic myPwrUp, [15:0] myRegWr, [15:0] myRegRd);
>       this.myPwrUp = myPwrUp;
>       this.myRegWr = myRegWr;
>       this.myRegRd = myRegRd;
>    endfunction
> 
> And here is the construction code:
> 
>    RegisterAccess RA;
>    initial begin
>       RA = new(cb.mu2mlcrwrpwrup, cb.mu2mlcrwr, cb.ml2mucrrd);

No, this won't work.  All you are doing is to use the current 
values of those three signals to initialize the values of 
data members of your class.  I guess you already knew that :-)

I suppose in some hypothetical future world you might be 
able to write

   class SignalTwiddler;
     ref logic TheSignal;
     function new(ref logic WhichSignal);
       TheSignal = WhichSignal;
     endfunction
     ...

but for the time being there is no such thing as a pointer
or reference to an individual signal.  The only ways I know
to do what you want are...

  1) the canonical approach:
  use a virtual interface variable to point to a real 
  interface instance.

  2) abstract-BFM approach:
  Make an abstract base class for your SignalTwiddler.
  Create a module that can see the required signal
  directly.  In that module, declare a class derived from
  SignalTwiddler that implements the required virtual method;
  construct an instance of that class, in an initial block
  in the module, and give a copy of the resulting object
  handle to your verification code.

I don't think there's anything especially troublesome about
using virtual interfaces here.  You just:
 - create an interface to encapsulate a group of signals 
   matching the ones you want to access in your DUT;
 - create a (static, of course) instance of that interface
   in your test harness module
 - arrange that the DUT ports are connected or otherwise
   linked to the test-access signals in the interface
 - set up a virtual interface to point to the interface 
   instance

In other words, you can have a pointer to an interface
instance (virtual interface) but you can't have a pointer
to anything else in the static module hierarchy (except
events - that might be useful...)

Forgive me if I've missed the real point of your question.
I have a bunch of examples on how to do this, so please
feel free to contact me directly if you'd like something
more specific.

Regards
-- 
Jonathan Bromley


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Oct 3 01:16:34 2008

This archive was generated by hypermail 2.1.8 : Fri Oct 03 2008 - 01:17:50 PDT