
samuel@tensor-tech.io (Member) asked a question.
datatype expression support in Vivado 2018.2
datatype expression support in Vivado 2018.2I need to derive a local parameter from a data type parameter to obtain the width of a bitfield inside a packed struct. The following is a simplified example code that demonstrates what I am trying to achieve:
typedef struct packed {
logic a;
logic [15:0] b;
} data_1_t;
typedef struct packed {
logic a;
logic [31:0] b;
} data_2_t;
module test #(parameter type DATA_T = integer) ();
localparam DATA_WIDTH = (type(DATA_T) == type(data_2_t)) ? 32 :
(type(DATA_T) == type(data_1_t)) ? 16 : 8;
DATA_T data;
logic [DATA_WIDTH-1:0] c;
assign c= data.b;
endmodule
Vivado 2018.2 complains about the localparam DATA_WIDTH with the following error:ERROR: [Synth 8-26] datatype expression not implemented
Is there a workaround to avoid this error?Is there a plan to have support for the type operator in synthesizable RTL code?
localparam DATA_WIDTH = $bits( DATA_T ) - 1; // Adjust math as needed....
Regards, Mark