When your loop index i
reaches the value n-1 then you are trying to access Num(n)
. However, Num
is only defined for the range of (n-1 downto 0)
.
A Numeric example would be for n=4, as is your default case:
You generate for i
values from 1 to 3, but access Num(i+1)
, therefore Num(4)
. But, as stated above, Num
is only defined in the range 3 downto 0
.