Get interface type from parameter

In reply to jimmyhuang0904:

You cannot parameterize an interface, it is not a datatype. However, SystemVerilog provides a generic interface that assumes the kind of interface the port gets connected to. You can use a parameter inside the connected interface to select.

interface my_interface ( interface m_if ); // generic interface

...  if(my_if.name) == "first_interface")
    ...
  else if (m_if.name) == "second_interface")
    ...
 endinterface
interface first_interface;
  parameter string name = "first_interface";
  ...
endinterface
interface second_interface;
  parameter string name = "second_interface";
  ...
endinterface

module top;

   first_interface i1();
   second_interface i2();

   my_interface m1(i1);
   my_interface m2(i2);

endmodule