Você está na página 1de 3

----------------------------------------------------------------------------------

-- Company:
-- Engineer:
--
-- Create Date: 18:49:40 10/04/2013
-- Design Name:
-- Module Name: cont99 - descripconta99
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

-- Uncomment the following library declaration if using


-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating


-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity cont99 is
Port ( reseteo : in STD_LOGIC;
clk : in STD_LOGIC;
enabledisplay : out STD_LOGIC_VECTOR (3 downto 0);
Salida : out STD_LOGIC_VECTOR (6 downto 0));
end cont99;

architecture descripconta99 of cont99 is

type estado is(estadoD, estadoU); --Estado para decenas y unidades.


signal estado_pre,estado_fut:estado; --Definicion de estado actual y futuro.

begin

process (clk,reseteo)

variable unidades: integer range 0 to 10:=0;


variable decenas: integer range 0 to 9:=0;
variable retraso: integer range 0 to 25000000:=0; -- divisor de frecuencia para
conteo a 2Hz
variable visualc: integer range 0 to 10000000; -- Retardo en visualizacin de 5 Hz
(0.2seg)
variable Temporal:integer range 0 to 10;--Variable temporal.
begin

if (reseteo='1') then
unidades:=0;
decenas:=0;
estado_pre<=estadoD; --Estado inicial decenas.

elsif (clk'event and clk='1') then

retraso:=retraso+1;
if (retraso=25000000) then

if (decenas=9) then
if (unidades=9) then
unidades:=0;
decenas:=0;
end if;
end if;

unidades:=unidades+1;
if (unidades=10) then
decenas:=decenas+1;
unidades:=0;
end if;

retraso:=0;
end if; --cierra if de retraso

--Bloque de visualizacion.
visualc:=visualc+1;
if (visualc>5000000)then
estado_pre<=estado_fut;
visualc:=0;
end if;

case estado_pre is
when estadoD=>Temporal:=Decenas; enabledisplay<="1101";
estado_fut<=estadoU;
when estadoU=> Temporal:=Unidades; enabledisplay<="1110";
estado_fut<=estadoD;
end case;

case Temporal is

when 0=>salida<="1000000"; -- GFEDCBA


when 1=>salida<="1111001";
when 2=>salida<="0100100";
when 3=>salida<="0110000";
when 4=>salida<="0011001";
when 5=>salida<="0010010";
when 6=>salida<="0000010";
when 7=>salida<="1011000";
when 8=>salida<="0000000";
when 9=>salida<="0011000";
when others=>null;
end case;

end if;
end process;

end descripconta99;

Você também pode gostar