Vous êtes sur la page 1sur 2

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

-- Company:
-- Engineer:
--
-- Create Date: 12:28:13 09/29/2017
-- Design Name:
-- Module Name: contador - Behavioral
-- 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;

entity contador is
PORT(CLK: IN STD_LOGIC;
SALIDA7S: OUT STD_LOGIC_VECTOR(6 DOWNTO 0);
S2: BUFFER STD_LOGIC;
S2N: OUT STD_LOGIC);
end contador;

architecture Behavioral of contador is


SIGNAL CPUDIV1: INTEGER RANGE 0 TO 999999;
SIGNAL CPUDIV2: INTEGER RANGE 0 TO 999;
SIGNAL S1: STD_LOGIC;
SIGNAL U,D:INTEGER RANGE 0 TO 15;
SIGNAL BS: INTEGER RANGE 0 TO 15;

BEGIN
--****************************************--
PROCESO1: -- DIVISOR DE FRECUENCIA 1
PROCESS(CLK)
BEGIN
IF RISING_EDGE(CLK) THEN
IF CPUDIV1 = 999999 THEN
S1<= NOT S1; --SALIDA S AL CONTADOR
CPUDIV1<=0;
ELSE
CPUDIV1<=CPUDIV1+1;
END IF;
END IF;
END PROCESS;
--****************************************--
PROCESO2: -- DIVISOR DE FRECUENCIA 2
PROCESS(CLK)
BEGIN
IF RISING_EDGE(CLK) THEN
IF CPUDIV2 = 999 THEN
S2<= NOT S2; --SALIDA S A SEL
CPUDIV2<=0;
ELSE
CPUDIV2<=CPUDIV2+1;
END IF;
END IF;
END PROCESS;
--****************************************--
PROCESO3: -- DIVISOR DE FRECUENCIA
PROCESS(S1)
BEGIN
IF FALLING_EDGE(S1) THEN
--**** ****
IF U=9 THEN
IF D=9 THEN
U<=0;D<=0;
ELSE
D<=D+1;U<=0;
END IF;
ELSE
U<=U+1;
END IF;
--**** ****
END IF;

END PROCESS;
--****************************************--

BS<= U WHEN S2='0' ELSE D; --MULTIPLEXOR 2X1

--*****************************************--
WITH BS SELECT --DECODIFICADOR BCD A 7 SEGMENTOS
SALIDA7S <= NOT "1111110" WHEN 0,
NOT "0110000" WHEN 1,
NOT "1101101" WHEN 2,
NOT "1111001" WHEN 3,
NOT "0110011" WHEN 4,
NOT "1011011" WHEN 5,
NOT "0011111" WHEN 6,
NOT "1110001" WHEN 7,
NOT "1111111" WHEN 8,
NOT "1110011" WHEN 9,
"ZZZZZZZ" WHEN OTHERS;
--****************************************--
S2N<=NOT S2;

end Behavioral;