Altera_Forum
Honored Contributor
16 years agoCant Decrement Clock!??
I've been messing around with this program for quite a while now and have run out of ideas. Im can t get the clock to increment when enable -which is assigned to a switch- is high, but I am not able to get the clock to decrement when enable is low. Any help or insight is appreciated.
Thanks. Signal counter, counter2 : INTEGER; PROCESS(enable, clock_50) --VARIABLE counter: INTEGER; BEGIN IF(clock_50 = '1' AND clock_50'EVENT) then IF(enable = '1') THEN IF (counter = 52428800/15) THEN --Speed of the on board clk (50Mhz) counter <= 0; toggle_clk <= NOT toggle_clk; ELSE counter <= counter + 1; counter2 <= counter2 + 1; END IF; ELSE counter <= 0; toggle_clk <= '0'; END IF; END IF; END PROCESS; --Decelarate PROCESS(enable, clock_50) --VARIABLE counter2: INTEGER; BEGIN counter2 <= counter; toggle_clk2 <= toggle_clk; IF(clock_50 = '1' AND clock_50'EVENT) then IF(enable = '0') THEN IF (counter2 = 52428800/22) THEN --Speed of the on board clk (50Mhz) counter2 <= 0; toggle_clk2 <= not toggle_clk2; ELSE counter2 <= counter2 - 1; --counter <= counter -1; END IF; ELSE counter2 <= 0; toggle_clk2 <= '0'; END IF; END IF; END PROCESS;