Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Parisa
Beginner
130 Views

Index 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

0 Kudos
3 Replies
sstrell
Honored Contributor II
117 Views

Is this a typo: "for(i-0;..."?  Shouldn't it be i=0?

And what's the backslash?

And what's your data type for length_in? 

I think you need to show more of the code here and/or fix these potential typos.

BoonBengT_Intel
Moderator
83 Views

Hi @Parisa,

 

Thank you for posting in Intel community forum, hope this message find you well.
Please do let us know if you are still facing the difficulties mention after correcting the type mention and we would get back to you as soon as possible.

 

Best Wishes
BB

BoonBengT_Intel
Moderator
52 Views

Hi @Parisa,

 

Greetings, as we do not receive any further clarification on what is provided. Hence thread will now be transitioned to community support and we will no longer monitor this thread. For new queries, please feel free to open a new thread and we will be right with you. Pleasure having you here.

 

Best Wishes
BB

Reply