Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16597 Discussions

Index out of range in for loop

Parisa
Beginner
770 Views

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 III
757 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.

0 Kudos
BoonBengT_Intel
Moderator
723 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

0 Kudos
BoonBengT_Intel
Moderator
692 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

0 Kudos
Reply