I am trying to make a design with multiple counters cycling from 0 to 109. However, the counters do not reset at 109, but rather 127 (their max value) when on the FPGA. They do work in simulation though. Below is my code:
speaker_processing_r : process(us_clock)
begin
if(rising_edge(us_clock)) then
if(i_reset = '1') then
output_counter_r_0 <= 0;
output_counter_r_1 <= (sample_period);
output_counter_r_2 <= (sample_period*2);
output_counter_r_3 <= (sample_period*3);
output_counter_r_4 <= (sample_period*4);
data_r_0 <= X"00";
data_r_1 <= X"00";
data_r_2 <= X"00";
data_r_3 <= X"00";
data_r_4 <= X"00";
else
--Output Conditions based on delays calculated or inserted
if(output_counter_r_0 = 2) then
data_r_0 <= shift_register_r(0);
elsif(output_counter_r_0 = delay_1) then
data_r_1 <= shift_register_r(0);
elsif(output_counter_r_0 = delay_2) then
data_r_2 <= shift_register_r(0);
elsif(output_counter_r_0 = delay_3) then
data_r_3 <= shift_register_r(0);
elsif(output_counter_r_0 = delay_4) then
data_r_4 <= shift_register_r(0);
elsif(output_counter_r_0 = (sample_period*5-1)) then
output_counter_r_0 <= 0;
end if;
if(output_counter_r_1 = 2) then
data_r_0 <= shift_register_r(1);
elsif(output_counter_r_1 = delay_1) then
data_r_1 <= shift_register_r(1);
elsif(output_counter_r_1 = delay_2) then
data_r_2 <= shift_register_r(1);
elsif(output_counter_r_1 = delay_3) then
data_r_3 <= shift_register_r(1);
elsif(output_counter_r_1 = delay_4) then
data_r_4 <= shift_register_r(1);
elsif(output_counter_r_1 = (sample_period*5-1)) then
output_counter_r_1 <= 0;
end if;
if(output_counter_r_2 = 2) then
data_r_0 <= shift_register_r(2);
elsif(output_counter_r_2 = delay_1) then
data_r_1 <= shift_register_r(2);
elsif(output_counter_r_2 = delay_2) then
data_r_2 <= shift_register_r(2);
elsif(output_counter_r_2 = delay_3) then
data_r_3 <= shift_register_r(2);
elsif(output_counter_r_2 = delay_4) then
data_r_4 <= shift_register_r(2);
elsif(output_counter_r_2 = (sample_period*5-1)) then
output_counter_r_2 <= 0;
end if;
if(output_counter_r_3 = 2) then
data_r_0 <= shift_register_r(3);
elsif(output_counter_r_3 = delay_1) then
data_r_1 <= shift_register_r(3);
elsif(output_counter_r_3 = delay_2) then
data_r_2 <= shift_register_r(3);
elsif(output_counter_r_3 = delay_3) then
data_r_3 <= shift_register_r(3);
elsif(output_counter_r_3 = delay_4) then
data_r_4 <= shift_register_r(3);
elsif(output_counter_r_3 = (sample_period*5-1)) then
output_counter_r_3 <= 0;
end if;
if(output_counter_r_4 = 2) then
data_r_0 <= shift_register_r(4);
elsif(output_counter_r_4 = delay_1) then
data_r_1 <= shift_register_r(4);
elsif(output_counter_r_4 = delay_2) then
data_r_2 <= shift_register_r(4);
elsif(output_counter_r_4 = delay_3) then
data_r_3 <= shift_register_r(4);
elsif(output_counter_r_4 = delay_4) then
data_r_4 <= shift_register_r(4);
elsif(output_counter_r_4 = (sample_period*5-1)) then
output_counter_r_4 <= 0;
end if;
output_counter_r_0 <= output_counter_r_0 +1;
output_counter_r_1 <= output_counter_r_1 +1;
output_counter_r_2 <= output_counter_r_2 +1;
output_counter_r_3 <= output_counter_r_3 +1;
output_counter_r_4 <= output_counter_r_4 +1;
end if;
end if;
end process;
All of the delay (delay_1
, delay_2
, delay_3
, delay_4
) signals are generics as well as sample_period
. The period of us_clock
is 1 microsecond. Any insight as to why they do not reset is appreciated.