Você está na página 1de 3

15/07/2019

Contador.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.all;

entity contadorupdow is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
led : out STD_LOGIC_VECTOR (3 downto 0));
end contadorupdow;

architecture Behavioral of contadorupdow is


signal contador: STD_LOGIC_VECTOR (3 downto 0);

Begin
process(clk,reset)
begin
if(reset='1')then
contador<=(others=>'0');
elsif(clk' event and clk= '1') then
contador <= contador+1;
end if;
end process;
led<=contador;
end Behavioral;

Ing. Cesar A. Romero Molano


2

1
15/07/2019

Contador ascendente descendente.


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.all;

entity contadorupdow is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
led : out STD_LOGIC_VECTOR (3 downto 0);
up_dow : in STD_LOGIC);
end contadorupdow;

architecture Behavioral of contadorupdow is


signal contador: STD_LOGIC_VECTOR (3 downto 0);

Begin
process(clk,reset)
begin
if(reset='1')then
contador<=(others=>'0');
elsif(clk' event and clk= '1') then
if up_dow ='1' then
contador <= contador+1;
else
contador <= contador-1;
end if;
end if;
end process;
led<=contador;
end Behavioral;

Ing. Cesar A. Romero Molano


4

2
15/07/2019

Contador Modulo.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.all;

entity contadorupdow is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
led : out STD_LOGIC_VECTOR (3 downto 0));
end contadorupdow;

architecture Behavioral of contadorupdow is


signal contador: STD_LOGIC_VECTOR (3 downto 0);

begin
process(clk,reset)
begin
if(reset='1')then
contador<=(others=>'0');
elsif(clk' event and clk= '1') then
if contador = "0100" then
contador <=(others=>'0') ;
else
contador <= contador+1;
end if;
end if;
end process;
led<=contador;
end Behavioral;

Ing. Cesar A. Romero Molano


6

Você também pode gostar