I have two interfaces:

  virtual intf vif;
  virtual i2c_intf i2c_vif;

I need to connect them at my top level.

Currently, I am connecting it like below:

module tbench_top;
  //creating instance of interface
  intf      i_intf();
  i2c_intf  i_i2c_intf();
  //Testcase instance
  test t1(i_intf);  
  //DUT instance, interface signals are connected to the DUT ports
  adder DUT (

When I construct multiple interfaces, I got the error as below:

** at environment.sv(18): Multiple constructors declared for class environment - only one allowed.

Should it be connected using named mapping, or is it the correct way to do it as above? How do I check whether they are connected? Could you guide me please?

For your understanding, here is the EDA playground link: https://www.edaplayground.com/x/utw9


1 Answer 1


The error points to line 18 in file environment.sv. In that file, you declared 2 constructor functions (named new), which is illegal. Line 18 is the 2nd attempt to declare the new function.

To fix that error, you must only declare a single function named new.

You are currently trying to add one interface argument to each of your new functions. You can add both interfaces as arguments to the function. For example, change:

  function new(virtual intf vif);
    //get the interface from test
    this.vif = vif;
  function new(virtual i2c_intf i2c_vif);
    this.i2c_intf = i2c_vif;


  function new(virtual intf vif, virtual i2c_intf i2c_vif);
    //get the interface from test
    this.vif = vif;
    this.i2c_vif = i2c_vif;

You would then need to modify how you call the new function accordingly.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.