Altera_Forum
Honored Contributor
9 years agoProblem with while loop in an array
I need to check how many cells in an array are "filled" and how many are zeroed.
The array is a one-dimensional array of 64 bits vector. Declaration in package:package my_pack is
type commands_array is array (natural range <>) of std_logic_vector(63 downto 0);
end package; Declaration in entity port: packets_in : in commands_array(0 to 17); This is the while loop: process(packets_in)
Begin
while (packets_in(num_packets) /= X"00000000") loop
num_packets <= num_packets + 1;
end loop;
end process; This is the declaration of the signal num_packets: signal num_packets : integer range 0 to 20:= 0; So the logic behind this is that I have several functions that fill the array with packets (each of 64 bits, as I've stated before). Initially, each function zeroes all cells of the array. Theoretically this array can have 18 packets, but in truth each function inserts between 10-12 packets into the array. The array is an output from one module and an input in the next one (where the while loop is). I want the while loop to understand on it's own how many cells were filled with packets and insert the number into num_packets. I'm getting this error: Error (10536): VHDL Loop Statement error at <vhdl file>: loop must terminate within 10,000 iterations I'm not sure why the loop doesn't terminate within 10,000 iterations, it should terminate after 18, the way I see it. I've thought about having the clock in my sensitivity list and doing a simple counter, but I don't want it to be clock dependent, and thought this could be a chance to learn about while loops in VHDL. Any help would be appreciated, thank you. Edit: another question, if I had a much larger vector, say 128 bits - is there a way to check if it is completely zeroed by doing something like this? if (my_vector = (others => '0'))