Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
15469 Discussions

Index out of range in for loop

Parisa
Beginner
222 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
209 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
175 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
144 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