In SystemVerilog and in VHDL as well, we can parameterize the length of ports on modules/entities. This means that the bit length of a port can be changed by using a parameter/generic. The required parameter/generic is specified when the module is instantiated.
Is it possible to take a parameter value and pass it to a function that will then return a value that is then used to do the actual parameterization? This could be done explicitly or implicitly.
// Explicit way
register #( .WIDTH(MyFunc(64)) ) D_rg
(
.clk(clk),
.rst(rst),
.wen(1'b1),
.D(data_in),
.Q()
);
// Implicit way - this shall call the MyFunc internally on WIDTH parameter
register #( .WIDTH(64) ) D_rg
(
.clk(clk),
.rst(rst),
.wen(1'b1),
.D(data_in),
.Q()
);
I believe that the explicit method should be possible, but I am not sure about the implicit method.