Passing an unpacked array type as a parameter

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 type T = int,
     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?

+4
source share
2 answers

You can use typedefdefine data type:

typedef logic [7:0] my_type [16];
my_type my_data;
my_type my_data_delayed;
pipe #(.T(my_type), .DELAY(2)) i_pipe
  (
   .clk(clk),
   .data_in(my_data),
   .data_out(my_data_delayed)
  );

, . EDAplayground, VCS, Riviera-PRO ( " " )


typedef struct { logic [7:0] data [16]; } my_type; . , .

+3

. type ( 6.23 IEEE 1800-2012) spec , . , :

logic [7:0] my_data [16];
logic [7:0] my_data_delayed [16];
pipe #(.T(type(my_data)), .DELAY(2)) i_pipe
  (
   .clk(clk),
   .data_in(my_data),
   .data_out(my_data_delayed)
  );

, , .

pipe.

+2

Source: https://habr.com/ru/post/1616592/


All Articles