Forum Discussion
24 Replies
- FvM
Super Contributor
Hi Ranesh,
as written above, dependency of variable part select on s_in_empty causes the problems. You can easily check by commenting out s_in_empty. I don't attempt to decide if System Verilog requires an indirectly dependant part select to be calculated correctly by Quartus compiler or not.
In any case, the problem can be easily bypassed by a direct comparison of the actual part select index against a constant limit.for (int c = c_IN_DESC_BYTE_CNT; c < c_OUT_DATA_BYTE_CNT; c++)
begin
int idx = W_MODULE_DATA - ((c - c_IN_DESC_BYTE_CNT) * 8);
if ((c < (c_IN_DESC_BYTE_CNT + (c_IN_DATA_BYTE_CNT - s_in_empty))) && idx >= 8 )
s_output_data[c] <= s_in_data[((W_MODULE_DATA - ((c - c_IN_DESC_BYTE_CNT) * 8)) - 1) -: 8];
end
Best regards
Frank
- ShengN_altera
Super Contributor
Hi Ranesh,
Below is the expert explanation on the second example (s_outbytecount):
s_output_data[d] <= s_in_data[((W_MODULE_DATA - ((d - s_outbytecount) * 8))- 1) -: 8]; //vector_capture_v2.sv, line number 151
In this case, array index uses logic type variable "s_outbytecount", for which synthesis generates a circuit which ensures no out of bound error happens.
In original use case, when local param is used in the index operation, they are replaced with actual values in compile time, so all possible indices get generated which cause out of bound error during loop unrolling.
e.g.
s_in_data[((W_MODULE_DATA - ((c - c_IN_DESC_BYTE_CNT) * 8)) - 1) -: 8]
Here, c is running from 16 to 31. During loop unrolling, index value is generated for all values of c which causes out of range error.
If you need further detailed explanation, may be we can set up a meeting after January 3rd with internal expert where they can explain the concept of index range being known at compile time.
Thanks,
Best regards,
Sheng