You are on page 1of 3

http://www.ehu.es/Electronica_EUITI/vhdl/pagina/express/11.

htm

Contador ascendente
library ieee;
use ieee.std_logic_1164.all;
use work.std_arith.all;
 
entity contador is port(
clk:       in std_logic;
conta: buffer std_logic_vector(3 downto 0)
);
end contador;
 
architecture archicontador of contador is
begin
process (clk)
begin
  if (clk'event and clk= '1') then
    conta <= conta + 1;
  end if;
end process;
end archicontador;

Contador ascendente con carga


ibrary ieee;
use ieee.std_logic_1164.all;
use work.std_arith.all;
 
entity contador is port(
clk, load:in std_logic;
data:    in std_logic_vector(3 downto 0);
conta:buffer std_logic_vector(3 downto 0)
);
end contador;
 
architecture archicontador of contador is
begin
process (clk)
begin
  if (clk'event and clk= '1') then
   if load = '1' then
    conta <= data;
   else
    conta <= conta + 1;
   end if;
  end if;
end process;
end archicontador;

Contador ascendente con carga y reset


library ieee;
use ieee.std_logic_1164.all;
use work.std_arith.all;
 
entity contador is port(
clk, load, reset:in std_logic;
data:    in std_logic_vector(3 downto 0);
conta:buffer std_logic_vector(3 downto 0)
);
end contador;
 
architecture archicontador of contador is
begin
process (clk,reset)
begin
  if reset = '1' then
   conta <= "0000";
  elsif (clk'event and clk= '1') then
   if load = '1' then
    conta <= data;
   else
    conta <= conta + 1;
   end if;
  end if;
end process;
end archicontador;

Contador ascendente/descendente con carga y reset


library ieee;
use ieee.std_logic_1164.all;
use work.std_arith.all;
 
entity contador is port(
clk, load, reset,arriba:in std_logic;
data:    in std_logic_vector(3 downto 0);
conta:buffer std_logic_vector(3 downto 0)
);
end contador;
 
architecture archicontador of contador is
begin
process (clk,reset)
begin
  if reset = '1' then
   conta <= "0000";
  elsif (clk'event and clk= '1') then
   if load = '1' then
    conta <= data;
   elsif arriba = '1' then
    conta <= conta + 1;
   else conta <= conta - 1;
   end if;
  end if;
end process;
end archicontador;

Contador BCD ascendente/escendente con carga y reset


library ieee;
use ieee.std_logic_1164.all;
use work.std_arith.all;
 
entity contador is port(
clk, load, reset,arriba:in std_logic;
data:    in std_logic_vector(3 downto 0);
conta:buffer std_logic_vector(3 downto 0)
);
end contador;
 
architecture archicontador of contador is
begin
process (clk,reset)
begin
  if reset = '1' then
   conta <= "0000";
  elsif (clk'event and clk= '1') then
   if load = '1' then
     conta <= data;
    elsif arriba = '1' then
     if conta = "1001" then
      conta <= "0000";
     else conta <= conta + 1;
     end if;
    else
     if conta = "0000" then
      conta <= "1001";
     else conta <= conta - 1;
    end if;
   end if;
  end if;
end process;
end archicontador;

You might also like