I have written the following working code to calculate an enable signal.
logic l_en [0:N-1];
logic [0:N-1] l_output_grant [0:M-1];
always_comb begin
for (int i=0; i<N; i++) begin
l_en[i] = |{l_output_grant[0][i],
l_output_grant[1][i],
l_output_grant[2][i],
l_output_grant[3][i],
l_output_grant[4][i]};
end
end
I am now trying to change the code to parameter the [0] through [4]. I tried the following code
logic l_en [0:N-1];
logic [0:N-1] l_output_grant [0:M-1];
always_comb begin
for(int i=0; i<N; i++) begin
for(int j=0; j<M; j++) begin
l_en[i] = |l_output_grant[j][i];
end
end
end
Which doesn't work. I assume this is because it recalculates with each iteration of j and thus clears the enable assigned by [j][i] if [j+1][i] is low.
What other ways could I do this please?