UVMF: parametrized hdl typdefs

In reply to chr_sue:

No, this solution doesn’t address and solve my issue.
As I tried to explain in the first post, my problem was the fact, that a VIP provides an interface which uses structures (or array of structures), which are parametrized. The interface is connected to a DUT, which uses the same kind of ports (structures, or array of structures). As the same type must be shared between interface, monitor_bfm_interface and driver_bfm_interface one would define it, as @chr_sue rightly pointed, in a common package:


package my_interface_pkd_hdl;
//my_interface_pkg_hdl.sv
typedef struct{
 logic [WIDTH_A-1 : 0] a;
 logic [WIDTH_B-1 : 0] b;
} MY_STRUCT_T;
endinterface

Of course this package, thus the whole VIP, will not compile, as all types inside VIP’s packages must be fixed. During my_interface_pkd_hdl compilation WIDTH_A and WIDTH_B are undefined.

Eventually, I solved this issue by passing to the interfaces (if, monitor_bfm, driver_bfm) not WIDTH_* parameters which would define the structure, but the type of the structure itself:


interface my_if #(type MY_STRUCT_T)();
   tri MY_STRUCT_T my;
endinterface

interface my_monitor_bfm #(type MY_STRUCT_T)(my_if bus);
   tri MY_STRUCT_T my_i;
   assign my_i = bus.my;
endinterface

The type is defined in a package of the DUT and provided to the VIP interfaces in top level HDL module:


module hdl_top;
   my_if #(DUT_common_pkg::MY_STRUCT_T) if();
   my_monitor_bfm #(DUT_common_pkg::MY_STRUCT_T) monitor_bfm(if);
endmodule