I want to access a slice with a dynamic value. I have tried to do it in different ways. In the first case reducing the logic of the module for the control of the index value etc, verilator told me that it is not a constant value and I agree with that and then I change for the second version but I got the same result.
module m1 (
input logic [1:0] in1, // 8-bit input vector 1
input logic [4:0] in2, // 8-bit index
);
logic not_cero;
always_comb begin
not_cero = in2[in1[1:0]:0] != '0;
end
//more logic
endmodule
Also, I tried:
module m1 (
input logic [1:0] in1, // 8-bit input vector 1
input logic [4:0] in2, // 8-bit index
);
logic not_cero;
always_comb begin
for (int i = 0; i < 4; i++) begin
if((in1[1:0]) == i)begin
not_cero = in2[in1[i:0]:0] != {i{1'b0}};
end
end
end
//more logic
endmodule
But I have the same compilation error:
First value of [a:b] isn’t a constant, maybe you want +: or -:
I tried to change the operand to [0*i:i], but I got another constant error.
Any ideas on how to implement this logic?