2
\$\begingroup\$

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 (
    .a(i_intf.a),
    .b(i_intf.b),
    .c(i_intf.c),
    .i_scl_in(i_i2c_intf.i_scl_in),
    .o_sda_out(i_i2c_intf.o_sda_out)
   );
  
endmodule

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

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

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:

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

to:

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

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

\$\endgroup\$

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.