I am trying to determine if there is a better way to handle using a parameterized type declared within an interface within a module.
SV does not allow parameterization of a package meaning any parameter declared within a package cannot be overridden unless its within a class and the class parameters are overridden during call. If I declare a type within an interface which scales based on the parameters passed to the interface I could get what I want and then pass the interface to a module. However, I can only reference signals declared within the interface using this type. Is there a way to declare a variable within a module using a type that is declared within an interface?. Is there an elegant way to do this without having to redeclare the type within the module Please see example below:
package test_pkg;
typedef struct packed {
logic en;
logic data_strobe;
logic [15:0] data;
} data_req_t;
virtual class param_structs #(parameter W = 2);
typedef struct packed {
logic [(W-1): 0] status;
data_req_t data_req;
} status_t;
endclass: param_structs
endpackage
interface test_if
#(
parameter int DATA_WIDTH = 32
)
();
typedef struct packed {
logic xfr_done;
logic data_req;
logic [(DATA_WIDTH-1):0] data;
} ld_data_req_t;
ld_data_req_t ld_req;
endinterface: test_if
module test#(parameter W = 4, parameter string P [(W-1):0] = {"A1", "A2", "A3", "A4"} )(output test_pkg::param_structs#(.W(W))::status_t status, test_if test_if);
ld_data_req_t d_req; // NOT LEGAL
endmodule