# How to declare virtual interface with params in the top module (in the testbench)?

**URL:** <https://verificationacademy.com/forums/t/how-to-declare-virtual-interface-with-params-in-the-top-module-in-the-testbench/32638>\
**Category:** UVM\
**Tags:** UVM, Parameterised-interface\
**Created:** [December 12, 2016, 3:15pm UTC](https://verificationacademy.com/forums/t/how-to-declare-virtual-interface-with-params-in-the-top-module-in-the-testbench/32638 "2016-12-12T15:15:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![saritr](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/df705f/32.png) [@saritr](https://verificationacademy.com/forums/u/saritr)\
**Post date:** [December 12, 2016, 3:15pm UTC](https://verificationacademy.com/forums/t/how-to-declare-virtual-interface-with-params-in-the-top-module-in-the-testbench/32638/1 "2016-12-12T15:15:32Z")

</div>

I have the following Parameterised interface :

```verilog
interface axi_interface #(parameter DATA_SIZE = 0)
  (input bit ACLK, input bit ARESETn);
   //write address channel signals
   logic [3:0] AWID; //
   logic [31:0] AWADDR;
   .....
   .....
endinterface

```

I try to declare this interface as virtual interface in the top module (in the testbench)

```verilog
module girobo2_tb_top;
   .....
   .....
   axi_interface #(.DATA_SIZE(63)) axi_vif(tb_axi_clk, axi_arstn);
   .....
   .....
endmodule

```

But I got the following error when I try to run the simulation:

# \*\* Error: (vsim-7065) ../sv/girobo2\_tb\_top.sv(245): Illegal assignment to type ‘virtual axi\_interface’ from type ‘interface axi\_interface #(.DATA\_SIZE(63))’: Vir. ‘axi\_interface’ interface must be assigned a matching interface or virtual interface.

---

<div class="post-metadata">

**Author:** ![kerulmodi](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/kerulmodi/32/1996_2.png) [@kerulmodi](https://verificationacademy.com/forums/u/kerulmodi)\
**Post date:** [December 12, 2016, 3:32pm UTC](https://verificationacademy.com/forums/t/how-to-declare-virtual-interface-with-params-in-the-top-module-in-the-testbench/32638/2 "2016-12-12T15:32:53Z")

</div>

_In reply to [saritr](https://verificationacademy.com/forums/t/how-to-declare-virtual-interface-with-params-in-the-top-module-in-the-testbench/32638):_

Are you using any methodology package ? If you are using UVM then while setting interface in config\_db , you require to give actual type of virtual interface with same parameter.

```verilog

uvm_config_db#(virtual axi_interface #(63)) :: set (,,,,);

```

“virtual axi\_interface” type is having default parameter(i.e DATA\_SIZE = 0) so you can not assign axi\_vif (actual interface pointer) to this type. You have to change type to “**virtual axi\_interface#(64)**”

---

<div class="post-metadata">

**Author:** ![saritr](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/df705f/32.png) [@saritr](https://verificationacademy.com/forums/u/saritr)\
**Post date:** [December 12, 2016, 3:38pm UTC](https://verificationacademy.com/forums/t/how-to-declare-virtual-interface-with-params-in-the-top-module-in-the-testbench/32638/3 "2016-12-12T15:38:27Z")

</div>

_In reply to [kerulmodi](https://verificationacademy.com/forums/t/how-to-declare-virtual-interface-with-params-in-the-top-module-in-the-testbench/32638/2):_

What about the decleration?

---

<div class="post-metadata">

**Author:** ![kerulmodi](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/kerulmodi/32/1996_2.png) [@kerulmodi](https://verificationacademy.com/forums/u/kerulmodi)\
**Post date:** [December 12, 2016, 5:14pm UTC](https://verificationacademy.com/forums/t/how-to-declare-virtual-interface-with-params-in-the-top-module-in-the-testbench/32638/4 "2016-12-12T17:14:34Z")

</div>

_In reply to [saritr](https://verificationacademy.com/forums/t/how-to-declare-virtual-interface-with-params-in-the-top-module-in-the-testbench/32638/3):_

If you are declaring interface as virtual then use following syntax.

```verilog
 virtual axi_interface #(.DATA_SIZE(63)) axi_vif; // virtual interface declaration..

```

You have declared active interface correctly in top module.  
This error comes when interface assignment is having type conflict.

Check your interface assignment and make sure you have declared virtual interface with correct value of parameter.

Regards  
Kerul Modi
