Вы находитесь на странице: 1из 5

SISTEMAS DIGITALES UTPL

UNIVERSIDAD TECNICA PARTICULAR DE LOJA


ELECTRNICA Y TELECOMUNICACIONES
SISTEMAS DIGITALES

Integrantes: Maritza Chalan y Mara Snchez


Fecha: 15/09/2017

PRCTICA: DESARROLLO DE RELOJ DIGITAL EN VHDL

OBJETIVO:

Aprender el manejo de la descripcin por comportamiento de varios bloques funcionales


dentro del lenguaje VHDL
ESPECIFICACIONES:

Se requiere el diseo y construccin de un reloj digital que cuente las horas, minutos y
segundos. La siguiente figura muestra el diagrama del bloque de ste sistema.

Fig. 1 Diagrama de b loques en VHDL del reloj digital.

CODIGO DEL RELOJ DIGITAL EN VHDL:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;

RELOJ DIGITAL
SISTEMAS DIGITALES UTPL

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(3 downto 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 to 33554432;-- 25 bits


signal clk_1hz : std_logic;

begin

-- proceso para conseguir una seal de 1HZ a partir de una seal "clk" de 50MHz

CLK_1HZ_PROC : process(clk, rst) is


begin
if (rst = '1') then

RELOJ DIGITAL
SISTEMAS DIGITALES UTPL

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 partir de la seal de 1Hz

RTC_PROC : process(clk_1hz, rst) is


begin
if (rst='1') then
segundos_LSB <= (others => '0');
segundos_MSB <= (others => '0');
minutos_LSB <= (others => '0');
minutos_MSB <= (others => '0');
horas_LSB <= (others => '0');
horas_MSB <= (others => '0');
elsif (clk_1hz'event and clk_1hz= '1') then
if (segundos_LSB = "1001" )then
segundos_LSB <= (others => '0');
if (segundos_MSB = "0101") then
segundos_MSB <= (others => '0' );
if (minutos_LSB = "1001" ) then
minutos_LSB <= (others => '0');
if (minutos_MSB = "0101" )then
minutos_MSB <= (others => '0');
if ((horas_LSB = "0011") and (horas_MSB = "0010")) then

RELOJ DIGITAL
SISTEMAS DIGITALES UTPL

horas_MSB <= (others => '0');


horas_LSB <= (others => '0');
elsif (horas_LSB = "1001") then
horas_LSB <= (others => '0');
horas_MSB <= horas_MSB + '1';
else
horas_LSB <= horas_LSB + '1';
end if;
else
minutos_MSB <= minutos_MSB + '1';
end if;
else
minutos_LSB <= minutos_LSB + '1';
end if;
else
segundos_MSB <= segundos_MSB + '1';
end if;
else
segundos_LSB <= segundos_LSB + '1';
end if;
end if;
end process RTC_PROC;

end Behavioral;

RELOJ DIGITAL
SISTEMAS DIGITALES UTPL

SIMULACIN:

En las siguientes figuras demostramos la simulacin del reloj digital, que indican el
correcto funcionamiento del programa.

Fig. 2 Simulacin del CLK

Fig. 3 Diagrama de tiempo del reloj digital

RELOJ DIGITAL

Вам также может понравиться