Tuesday 31 December 2013

4 BIT BINARY UP / DOWN COUNTER (Behavioral)



library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_unsigned.all;
Entity UP_COUNTER is
port(clr,clk,pr,m:in std_logic;Q:inout std_logic_vector(3 downto 0));
end UP_COUNTER;
Architecture behavioral of UP_COUNTER is
begin
process( clr,clk,pr,Q,m)
begin
if (pr ='0') then Q<="1111";
elsif (clr ='0') then Q<="0000";
elsif clk='0' and clk'event then
if m='0' then
Q<=Q + 1;
else Q<=Q - 1;
end if;
end if;
end process;
end behavioral;

No comments:

Post a Comment