Escolar Documentos
Profissional Documentos
Cultura Documentos
Divisor de frecuencia
Cdigo
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_arith.all;
use IEEE.STD_LOGIC_unsigned.all;
use IEEE.numeric_std.all;
entity divider is
--Entradas y salidas del divisor
Port ( clock : in std_logic;
new_clock : out std_logic
);
end divider;
architecture Behavioral of divider is
signal cont_clock : integer := 0;
signal temp : std_logic := '0';
begin
process(clock)
begin
if(rising_edge(clock)) then
--temp (y cont_clock) cambian cuando el contador
--alcanza el valor
if(cont_clock = 12599999) then
cont_clock <= 0;
temp <= not(temp);
new_clock <= temp;
else
cont_clock <= cont_clock + 1;
end if;
end if;
end process;
end Behavioral;
-------------------library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_arith.all;
use IEEE.STD_LOGIC_unsigned.all;
use IEEE.numeric_std.all;
entity P6 is
--Entradas y salidas
Port (
formato : in std_logic;
pausa : in std_logic;
suma : in std_logic;
clock : in std_logic;
num : out std_logic_vector (7 downto 0) :=
"00000000"
);
end P6;
architecture Behavioral of P6 is
component divider is
Port ( clock : in std_logic;
new_clock : out std_logic
);
end component;
--Reloj con menos frecuencia
signal new_clock : std_logic;
--Contador para incrementar/decrementar
signal cont : std_logic_vector (7 downto 0) := "00000000";
--Contador con corrimiento a la derecha
signal rcont : std_logic_vector (7 downto 0) := "00000000";
--Cuenta cuantos ciclos han pasado (para que T_Gray = 1 s)
signal check : integer := 0;
--Evitar que el compilador quite el latch que se forma porque
--rcont(7) siempre es '0'
attribute keep : string;
attribute keep of rcont : signal is "true";
attribute S : string;
attribute S of rcont : signal is "YES";
begin
nclock:
Esquema RTL
Ejecucin