Altera_Forum
Honored Contributor
17 years agoUp-down counters
Hi,
I'm new to VHDL.. i'm creating the up-down counter with async rst and a load enable signal. this load enable will determine any number within the range to be entered into the counter whereas the reset signal will reset the counter to the value of the number loaded..my problem is i didn't get the output. my code; library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity cnt is port ( CLK,RST,LE,UD : in std_logic; D : in std_logic_vector(3 downto 0); Q : out std_logic_vector(3 downto 0)); end cnt; architecture beh of cnt is signal Q_IN : std_logic_vector(3 downto 0); begin Q <= Q_IN; process( RST, CLK, LE, UD, D ) begin if RST='1' then Q_IN <= "0000"; elsif CLK='1' and CLK'event then --else if LE='1' then --Q_IN <= D; --elsif CLK='1' and CLK'event then Q_IN <= D; if UD='1' then Q_IN <= Q_IN + '1'; else Q_IN <= Q_IN - '1'; end if; end if; end if; end process; end beh; please someone help me. thanks.