Contador 00 - 99 Ascendente - Descendente
Enviado por AlanisMarsh • 28 de Abril de 2015 • 236 Palabras (1 Páginas) • 308 Visitas
Realizar un algoritmo que cuente de manera ascendente y descendente dentro de un rango de 00 hasta 99, con ambos displays de la tarjeta Cool runner.
entity examen is
Port ( rst : in STD_LOGIC;
clk : in STD_LOGIC;
cat1 : out STD_LOGIC;
cat2 : out STD_LOGIC;
up : in STD_LOGIC;
salida : out STD_LOGIC_VECTOR (06 downto 0));
end examen;
architecture Behavioral of examen is
signal unidad: STD_LOGIC_VECTOR (3 downto 0);
signal decena: STD_LOGIC_VECTOR (3 downto 0);
signal selecc: STD_LOGIC_VECTOR (3 downto 0);
signal cont: STD_LOGIC_VECTOR (3 downto 0);
signal reloj: STD_LOGIC;
begin
process (selecc,clk)
begin
if (clk = '0')then
selecc <= unidad;
cat2 <= '1';
cat1 <= '0';
else
selecc <= decena;
cat1 <= '1';
cat2 <= '0';
end if;
case selecc is
when "0000" => salida <= "1111110";
when "0001" => salida <= "0110000";
when "0010" => salida <= "1101101";
when "0011" => salida <= "1111001";
when "0100" => salida <= "0110011";
when "0101" => salida <= "1011011";
when "0110" => salida <= "1011111";
when "0111" => salida <= "1110000";
when "1000" => salida <= "1111111";
when "1001"=> salida <= "1110011";
when "1010" => selecc <= "0000";
when "1111" => selecc <= "1001";
when others => salida <= "0000000";
end case;
end process;
process (cont)
begin
if (clk'event and clk = '1') then
if cont < "1111" then
cont <= cont + "0001";
reloj <= '1';
else reloj <= '0';
cont <= "0000";
end if;
end if;
end process;
process (rst) begin
if rst='1' then
unidad <= "0000";
decena <= "0000";
elsif (reloj'event and reloj = '1') then
if(up='1') then
unidad<=unidad+1;
if(unidad="1001") then
decena<=decena+1;
unidad<="0000";
end if;
if(decena="1001" and unidad="1001") then
unidad<="0000";
decena<="0000";
end if;
else
unidad<=unidad-1;
...