Reloj Digital
Aquite dejo el código de lo que te acabo de contar. He suspuesto que la frecuencia del reloj de entrada es de 50MHz para hacer el divisor. Como verás es muy fácil cambiarla:
Codigo:library IEEE;
useIEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.--library UNISIM;
--use UNISIM.VComponents.all;
entity reloj is
port (
clk : in std_logic;
rst : in std_logic;
segundos_LSB : inout std_logic_vector(3downto 0);
segundos_MSB : inout std_logic_vector(3 downto 0);
minutos_LSB : inout std_logic_vector(3 downto 0);
minutos_MSB : inout std_logic_vector(3 downto 0);
horas_LSB :inout std_logic_vector(3 downto 0);
horas_MSB : inout std_logic_vector(3 downto 0)
);
end entity reloj;
architecture Behavioral of reloj is
signal contador : integer range 0 to33554432;-- 25 bits
signal clk_1hz : std_logic;
begin -- architecture behavioral
-- proceso para conseguir una señal de 1HZ a partir de una señal "clk" de 50MHz
CLK_1HZ_PROC : process(clk,rst) is
begin
if (rst="1") then
contador <= 0;
elsif (clk"event and clk="1") then
if (contador = 25000000) then
clk_1hz <= not clk_1hz; contador <= 0;
else
contador <= contador + 1;
end if;
end if;
end process CLK_1HZ_PROC;
-- proceso que incrementa los contadores a...
Regístrate para leer el documento completo.