Altera_Forum
Honored Contributor
9 years agoA question about parameterized structure between interface and module
Hello everyone!
I have a design that is using client/server architecture, one server module polling multiple client module periodically to check if the client module needs update, and if the client which is been polled needs update, then server retrieve some information and feedback datas depending on the retrieved information. Normally I can define a packed structure type to transmit the information from client to server, to simplify the port codes of server module and client module, just like this:
typedef struct packed {
logic sig1;
logic sig2;
} client_info_t;
module server(
...
input client_info_t client_info,
...
);
...
endmodule
module client(
...
output client_info_t client_info,
...
);
...
endmodule
But, when the server and client module are designed as parameterized module, and the bitwidth of structure's elements is depend on the instantiating parameter of client or server module, or both of them, the question is coming: How can I pass the instantiating parameter from module to the structure? The following example code can demonstrate more clearly what puzzles me:
typedef struct packed {
logic sig1;
logic sig2; // BITWIDTH_OF_SIG2 is the parameter that should be passed from client or server module.
} client_info_t;
module server# (
parameter BITWIDTH_OF_SIG2 = 3 // BITWIDTH_OF_SIG2 should be passed to the structure which is the part of module port.
) (
...
input client_info_t client_info,
...
);
...
endmodule
module client# (
parameter BIT_WIDTH_OF_SIG2 = 3 // BITWIDTH_OF_SIG2 should be passed to the structure which is the part of module port.
) (
...
output client_info_t client_info,
...
);
...
endmodule
Although I can split the structure and define multiple port connections for each element, but this method will significantly increase the complexity of module port', and that is not what I want. So, is there any better solution about it?