Forum Discussion
Altera_Forum
Honored Contributor
9 years ago0-15 counter
Hi Guys, Can anyone help me i am nee to altera programming. Can anyone help me i am trying to write an up and down counter that counts from 0-15 with 2 bushbuttons and 2 7 segments display ...
Altera_Forum
Honored Contributor
9 years agocan you help me start of guide me on how to start it this is what i got so far
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity up_down_counter2 is Port ( CLK : in STD_LOGIC; DIR : in STD_LOGIC; LED : out STD_LOGIC_VECTOR (7 downto 0)); end up_down_counter2; architecture Behavioral of up_down_counter2 is signal clk_div : STD_LOGIC_VECTOR (5 downto 0); signal count : STD_LOGIC_VECTOR (7 downto 0); begin -- clock divider process (CLK) begin if (CLK'Event and CLK = '1') then clk_div <= clk_div + '1'; end if; end process; -- up/down counter process (clk_div(5)) begin if (clk_div(5)'Event and clk_div(5) = '1') then if (DIR = '1') then -- count up to 15 then stop while (count < 15) loop count <= count + '1'; -- count up end loop; else -- count down to 0 then stop while (count > 0) loop count <= count - '1'; -- count down end loop; end if; end if; end process; LED <= not count; end Behavioral; but this does not use pushbuttons how do i implement pushbuttons and without a timer