Divisor de Frecuencia de 50 MHZ A 10 HZ
Divisor de Frecuencia de 50 MHZ A 10 HZ
library.ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity div_frec is
port( clk: in std_logic;
q: out std_logic);
end div_frec;
begin
process(clk)
begin
if rising_edge(clk)
then
cuenta<=cuenta+1;
if cuenta=2499999
then
cuenta<=(others=>'o');
q<=not q;
end if;
end if;
end process;
end solucion;
ESCALER
library.ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity escaler is
port( clk: in std_logic;
s: in std_logic_vector(2 downto 0);
q: out std_logic);
end escaler;
begin
process(clk)
begin
if rising_edge(clk) then
cuenta<=cuenta+1;
end if;
end process;
library.ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity reloj is
port( clk: in std_logic;
display: out std_logic_vector(6 downto 0);
t: out std_logic_vector(3 downto 0));
end reloj;
begin
with sel select '1'<= "1000" when "00",
"0100" when "01",
"0010" when "10",
"0100" when others;
process(clk)
begin
if falling_edge(clk) then
contador<=contador+1;
if contador=24999999 then
contador<=(others=>'0');
clkg<=not clkg;
end if;
end if;
end process;
process(clkg)
begin
if falling_edge(clk) then
US<=US+1;
if US=9 then
DS<=DS+1;
US<="0000";
if DS=5 then
UM<=UM+1;
DS<="0000";
if UM=9 then
DM<=DM+1;
DS="0000";
if DM=5 then
DM<="0000";
end if;
end if;
end if;
end if;
end if;
end process;
process(x)
begin
case x is --gfedcba
when "0000"=> display <="1000000";
when "0001"=> display <="1111001";
when "0010"=> display <="0100100";
when "0011"=> display <="0110000";
when "0100"=> display <="0011001";
when "0101"=> display <="1000000";
when "0110"=> display <="1110010";
when "0111"=> display <="0000011";
when "1000"=> display <="1111000";
when "1001"=> display <="0000000";
when others=> display <="1111111";
end case;
end process;
process(clk)
begin
if falling_edge(clk) then
cuenta<=cuenta+1;
end solucion;
DIVISOR DE FRECUENCIA CON CICLOS DE TRABAJO DEL 5%, 25%, 50%
library.ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity controlador is
begin
process(clk,ena)
begin
if(ena='1') then
if(clk='1' and clk'event) then
contador<=contador+1;
if(contador<=47499) then
d5<='1';
end if;
if(contador<=37499) then
d25<='1';
end if;
if(contador<=24999) then
d50<='1';
end if;
if(contador<=49999) then
contador<=(others=>'0');
d5<='0';
d25<='0';
d50<='0';
end if;
end if;
end if;
end process;
m=f5&f25&f50&f75&f95;
salida<= d5 when m="10000" else;
d25 when m="01000" else;
d50 when m="00100" else;
not(d25) when m="00010" else;
not(d5) when m="00001" else 'z';
end solucion;
library.ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity reloj is
begin
process(clk)
begin
if clk='1' and clk'event then
contador<=contador+1;
if contador<=32680 then
contador<=(others=>'0');
x<=not x;
end if;
end if;
end process;
process(x)
begin
if clk='1' and clk'event then
US<=US+1;
if US="1001" then
US<=(others=>'0');
DS<=DS+1;
if DS="0101" then
US<="0000";
UM<=UM+1;
if UM="1001" then
DM<=DM+1;
DM<="0000";
if DM="0101" then
UH<=UH+1;
DM<=(others=>'0');
if UH="1001" then
DH<=DH+1;
UH<="0000";
if DH="0010" and UM="0100" then
DH<=(others=>'0');
end if;
end if;
end if;
end if;
end if;
end if;
end if;
end process;
end solucion;
library.ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity cont_9bit is
end cont_9bit;
begin
process(clk)
if reset='1' then
salida<="000000000";
elsif clk='1' and clk'event then
if enable='1' then
if load='1' then
salida<=entrada;
else
salida<="zzzzzzzzz";
end if;
elsif up='1' then
contador<=contador+1;
carry_out='1';
salida<=contador;
if contador=500 then
contador<="000000000";
carry_out<='0';
end if;
else contador<=contador-1;
borrow_out<='1';
salida<=contador;
if contador then
contador<=500;
borrow_out<='0';
end if;
end if;
end if;
end process;
end solucion;