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…
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
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)
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)
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.
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
//-------------------------------------------
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;
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
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
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
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.