Is "assign_vi" the only way to pass interface to the components from environment?

Hello all…
I am creating an ovm environment for a simple counter… in my top i had instantiated the interface, dut and the program block… i want to pass the interface from top to my driver block… IS assign_vi THE ONLY WAY TO PASS THE INTERFACE TO MY DRIVER BLOCK??? if not n if there is any way kindly let me know… !! i had seen in vmm method, interface can be passed through the “new” constructor operator? can that be applicable inside ovm env…?? let me know out…

thank in adv.
with regards
anjani… :(

The assign_vi method is absolutely not the only way to do this!

It is the scheme that the xbus example uses, so unfortunately I think people assume that is the “official” method. There are definitely better ways to get the real interface connected to your drivers and monitors.

You do not want to use constructor arguments to do this - it suffers from the same disadvantage that assign_vi has (you must do extra work in many classes that do not need the interface, they merely pass it on). Also, you would not be able to create those modules with the factory.

You can

  1. Declare a virtual interface handle in a package, which then becomes a global variable that is visible to any classes defined in that module (easiest to implement, but some people don’t like to create global variables)

  2. Create a wrapper class and use the set/get_config_object calls to pass it directly to the objects that need it (similar in concept to (1) above, but a little more work. It has the advantage of avoiding a global variable)

  3. Bypass the use of virtual interfaces altogether and create a module wrapper containing transactor classes that acts as a kind of BFM.

A quick search of this forum board should yield more discussion and examples for you to see.

-Kurt

hi Kurt,
thanku for ur nice ideas…
so if i want to implement the first method as you said:
Eg:
//------------------------------------------
package int_package;
virtual interface inter inter0;
endpackage
//-------------------------------------------

//-------------------------------------------
`include “int_package.sv”
import int_package::*;

module top_mo;
inter inter0;
dutt dutt0;
endmodule
//--------------------------------------------

class drv extends ovm_driver;

  task  drv::write();
   inter0.data = 'ha;
  endtask  

endclass

does this works out ?? its enough if declared in interface and import the package globally ?? can you post some examples if you have?

thanks in advance…

anjni

Hi kurtz…

I just tryed like that, declaring the interface in the package and declared it globally so that it holds good to all class, but when did so its giving thiss error…

Error-[SV-UFRI] Undefined forward-referenced interface
…/tb/me_ctl_pkg.sv, 8
me_ctl_if
The definition for the forward-referenced interface ‘mem_ctl_if’ is missing
Check to see if the interface definition file/work library is missing.

1 error

// the package i declared is this
package me_ctl_pkg;

`define TB_TIMEOUT_DELAY 10000;
typedef enum {RD, WR, RST} me_ctl_opr;
parameter DATA_WIDTH = 8;
parameter ADDR_WIDTH = 3;
virtual interface me_ctl_if me_ctl_if0;
endpackage: me_ctl_pkg

can u help me out from here…

thanks in adv
anjani

Hi Anjani,

As far as I know,
The best way to pass the interface to any OVM component(class) is to wrap the interface handle in one class. (The 2nd one which is suggested by Kurtz)

Step 1:You can create any class which will be derived from ovm_object and in that class u can pass the handle of an interface.

class if_wrapper extends ovm_object;
virtual intf v_intf;
function new(string name);
super.new(name);
endfunction
endclass

Step2 :Now you can instantiate this class in the top module.
and you can pass this instance across the environment using set_config_object…

module top;
intf int();
if_wrapper wrapper = new(“wrapper”);
initial
begin
wrapper.v_intf = int; //PAss an actual handle interface
set_config_object(“*”,“wrapper”,wrapper,0);
end
endmodule

Step 3: Any component inside the VE(driver in ur case) can access the interface if it creates an instance of wrapper class with “wrapper” name.

class driver extends ovm_driver;
if_wrapper wrapper;
virtual intf driver_if;

`ovm_obejct_utils(wrapper,OVM_ALL_ON)

function void build();
super.build();
driver_if = wrapper.v_intf; //This will get the actual interface
endfunction
endclass

Hope this helps.

Quick suggestion for step 1

class vm_wrapper #(type T=int) extends ovm_object;

T m;

function new(string name="");
super.new(name);
endfunction

endclass

This wrapper works for all interfaces and all specializations of interface instances. Then step 2 is

typedef virtual intf v_intf_t;

vm_wrapper #(v_intf_t) vintf = new();

intf itf();

initial
begin
         v_intf.m = itf;  //PAss an actual handle interface
         set_config_object("*","wrapper",wrapper,0);
end

endmodule

Dave

Wht didn’t this strike to ma mind? :)
Anyways Thanks Dave…

Hello all,
Thanks a lots for giving a clear cute ideas…

With Regards,
Anju

Dave,

Tried this in Cadence IUS8.2 and got the following message pointing to the specialization using virtual interface.

vm_wrapper #(v_intf_t) vintf = new();
|
ncvlog: *E,SVTPCO (vm_wrapper.sv,23|20): Currently type parameter override is not supported for this datatype.
module worklib.test:sv
errors: 1, warnings: 0

Is this supported ??

Works for me. You’ll have to ask someone at Cadence support.

Works for me. You’ll have to ask someone at Cadence support.

Anyone from Cadence can answer?

Is “virtual interface as parameter for parameterized class” supported in IES?

Quick suggestion for step 1

class vm_wrapper #(type T=int) extends ovm_object;
T m;
function new(string name="");
super.new(name);
endfunction
endclass

This wrapper works for all interfaces and all specializations of interface instances. Then step 2 is

typedef virtual intf v_intf_t;
vm_wrapper #(v_intf_t) vintf = new();
intf itf();
initial
begin
v_intf.m = itf;  //PAss an actual handle interface
set_config_object("*","wrapper",wrapper,0);
end
endmodule

Dave

So instead of passing a interface, can I pass a struct?

Any type will work.

About the second way - with the package:
Can I define all kinds of variables in a package?
Where should I write the package declaration?

Thank you

Ssan,

This is a long thread - which second way - with a package are you referring to?

Never mind, I’ve got it at last, thank you very much anyway

Hi kurts,
thanks for the solution. I was also stuck with the assign_vi approach, beacuse xbus is the only working env with me too…

In reply to Lai:

Hi,
In the step 2 what is the difference if we pass an actual interface to virtual interface wrapper in the constructor as my comments below and direct assignment “v_intf.m = itf;” as shown:

typedef virtual intf v_intf_t;

vm_wrapper #(v_intf_t) vintf = new();
//My comments:pass actual interface to virtual interface wrapper in the new() constructor
vm_wrapper #(v_intf_t) vintf = new(“vintf”,itf);

intf itf();

initial
begin
//My comments:Below assignment not required
v_intf.m = itf; //PAss an actual handle interface
set_config_object(“*”,“wrapper”,wrapper,0);
end

endmodule

Thanks,

In reply to Kausar:

As a general rule, we do not recommend adding arguments to any OVM/UVM class constructor. The arguments should be fixed by the base class. Although it may not be a problem in this case, it does prevent you from using the factory, and results in bloating arguments lists as you continue to extend the class.