Interface function with type parameter

Hello all.

I’m trying to create a function inside an interface, like this:

interface intf();
  int msg_buffer;
  .... code ....

  task get(output int msg);
    begin
      msg = msg_buffer;
    end
  endtask

  task set(input int msg);
    begin
      msg_buffer = msg;
    end
  endtask

endinterface

So basically the method calling the interface will be able to write a single value to a bus (set) or read it (get).
But in this case, the value to be read/written is fixed to be an integer. What I need is to be able to use any type, determined at compile time.

Something like…

intf myInterface1<int>; 
myInterface.set(32'd0);

So far I’ve found out I can pass a parameter to the interface to set the size of the signals inside. But not their type. In my interface I want to be able to even set enum and struct types.

Any ideas on how to do this?
Maybe an interface is not the right choice, but what else could I use? I don’t have much experience on SV so any help would be appreciated.

Thanks and regards.

In reply to Gabalo:

User a type parameter on the interface:

interface my_if
#(
  type my_t= bit [ 23 : 0 ]
);
endinterface

my_if #( .my_t( bit [ 7 : 0 ] ) ) my_if_8bit();

my_if #( .my_t( bit [ 2 : 0 ][ 7 :0 ] ) my_if_3bytes();

Regards,
Mark