Parisa
New Contributor
4 years agoIndex out of range in for loop
Hi everyone,
I have a code that has a for loop within an if condition. the for loop starts at 0 and is suppose to go up to less than (length_in - 1). length_in is an input and can have max value of 20. so the loop is suppose to start at 0 and in worst case scenario go up to less than 19 which means 0 to 18. but I get an error that index [19] is out of range [18:0] when I try to synthesize the code on quartus pro 20.1. even when I make it length_in - 10, I still get this error. Can someone help me please?
the code is:
if(pure ==0) begin
for(i-0; i<length_in-1; i=i+1)begin
gini_impurity = (count_one[i]*count_zero[i])\(count_one[i]+count_zero[i]);
end
end
the error is index [19] is out of range [18:0] for count_one