I created a module for the simplest simple, for example, adding a pipeline delay. I made the data type a parameter so that it can handle complex things like struct. I have something like this:
module pipe
parameter DELAY = 0)
(
input clk,
input T data_in,
output T data_out);
T pipe[DELAY];
always_ff @(posedge clk) begin
pipe[0] <= data_in;
for(int i = 1; i<DEPTH; i++) begin
pipe[i] <= pipe[i-1];
end
end
assign data_out = pipe[DELAY-1];
endmodule
This works fine, but then I discovered that I wanted to use it with an unpacked array, and I could not figure out how to do this. It will look something like this, but I don't think it is correct:
logic [7:0] my_data [16];
logic [7:0] my_data_delayed [16];
pipe #(.T(logic [7:0] [16]), .DELAY(2)) i_pipe
(
.clk(clk),
.data_in(my_data),
.data_out(my_data_delayed)
);
Is there a way to get the type of a variable so that it can be passed to this parameter?
source
share