Altera_Forum
Honored Contributor
9 years agoHow to use a for loop for repetitive timed actions
I am trying to figure out how to use a for loop for some repetitive timed actions. A snippet of the code I am using right now is shown below, although only showing 2 repeats. I haven't been able to come up with something that seems like it would work.
Marie Stoffer CASE ten_sec_cnt IS WHEN "000" => IF ((rollovr_cnt = X"0") and (duration = X"00")) THEN next_red <= '0'; -- turn red LED on next_av_done <= avdone; next_state <= state; ELSIF ((rollovr_cnt = X"1") and (duration = X"F2")) THEN -- time = 5 sec next_red <= '1'; -- turn red LED off next_av_done <= avdone; next_state <= state; ELSIF ((rollovr_cnt = X"2") and (duration = X"B9")) THEN -- time = 7 sec, double-flash, start of 10 seconds next_red <= '0'; -- turn red LED on next_av_done <= avdone; next_state <= state; ELSIF ((rollovr_cnt = X"2") and (duration = X"D2")) THEN -- time = 7250 ms next_red <= '1'; -- turn red LED off next_av_done <= avdone; next_state <= state; ELSIF ((rollovr_cnt = X"3") and (duration = X"04")) THEN -- time = 7750 ms next_red <= '0'; -- turn red LED on next_av_done <= avdone; next_state <= state; ELSIF ((rollovr_cnt = X"3") and (duration = X"1C")) THEN -- time = 8 sec next_red <= '1'; -- turn red LED off next_av_done <= avdone; next_state <= state; ELSIF ((rollovr_cnt = X"3") and (duration = X"80")) THEN -- time = 9 sec next_red <= '0'; -- turn red LED on next_av_done <= avdone; next_state <= state; ELSIF ((rollovr_cnt = X"3") and (duration = X"99")) THEN -- time = 9250 ms next_red <= '1'; -- turn red LED off next_av_done <= avdone; next_state <= state; ELSIF ((rollovr_cnt = X"3") and (duration = X"CA")) THEN -- time = 9750 ms next_red <= '0'; -- turn red LED on next_av_done <= avdone; next_state <= state; ELSE next_red <= red; next_av_done <= avdone; next_state <= state; END IF; WHEN "001" => IF ((rollovr_cnt = X"0") and (duration = X"00")) THEN -- time = 10 sec next_red <= '1'; -- turn red LED off next_av_done <= avdone; next_state <= state; END IF; WHEN OTHERS => null; END CASE;