Professional Documents
Culture Documents
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity BANCO_REGISTRO is
Port(selA,selB,selD: in std_logic_vector(1 downto 0);
clk, ena: in std_logic;
data: in std_logic_vector(7 downto 0);
A,B : out std_logic_vector(7 downto 0));
end BANCO_REGISTRO;
end solucion;
SECUENCIA DE BITS 10011001 CON LOAD
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity cadenabits is
port(clk,load:in std_logic;
z: out std_logic);
end cadenabits;
process(clk)
begin
if rising_edge(clk) then
cuenta<=cuenta+1;
if cuenta=2500000 then
cuenta<=(others=>'0');
x<=not x;
end if;
end if;
end process;
process(x)
begin
if rising_edge(x) then
if load='1' then
cuentita<=cuentita+1;
if cuentita=8 then
cuentita<=0;
end if;
end if;
end if;
end process;
end solucion;
PERSONAS QUE ENTRAN Y SALEN DE UN LOCAL
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity cantidad_personas is
Port(clk,pe,ps: in std_logic;
unidades, decenas: buffer std_logic_vector(3 downto 0));
end cantidad_personas;
entity codificador_prioridad is
port(Q: in std_logic_vector(6 downto 0);
M: out std_logic_vector(2 downto 0));
end codificador_prioridad;
entity comparador4_bits2 is
port(A,B: in std_logic_vector(3 downto 0);
MAY,IGUAL,MEN: out std_logic);
end comparador4_bits2;
entity comparador4_bits is
port(A,B: in std_logic_vector(3 downto 0);
MAY,IGUAL,MEN: out std_logic);
end comparador4_bits;
entity CONSEJO_FACULTAD is
Port(doc,alum,adm: in integer range 0 to 7;
z: out std_logic);
end CONSEJO_FACULTAD;
entity CONTA_0A20 is
Port(ena, set, clr,clk: in std_logic;
q:buffer std_logic_vector(4 downto 0));
end CONTA_0A20;
entity conta_0a7 is
Port(clk,ud: in std_logic;
display: out std_logic_vector(7 downto 0));
end conta_0a7;
process(x)
begin
if rising_edge(x) then
if ud='0' then
y<=y+1;
else
y<=y-1;
end if;
end if;
end process;
--pgfedcba
with y select display <= "11000000" when "000",
"11111001" when "001",
"10100100" when "010",
"10110000" when "011",
"10011001" when "100",
"10010010" when "101",
"10000011" when "110",
"11111000" when others;
end solucion;
CONTADOR CENTESIMAS DE SEGUNDOS Y SEGUNDOS CON LEDS
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity contador_segcent is
Port(clk,s_r,reset: in std_logic;
cent: buffer std_logic_vector(6 downto 0);
seg: buffer std_logic_vector(3 downto 0));
end contador_segcent;
process(x,reset)
begin
if reset='1' then
seg<=(others=>'0');
cent<=(others=>'0');
elsif rising_edge(x) then
if s_r='1' then
cent<=cent+1;
if cent=100 then
cent<=(others=>'0');
seg<=seg+1;
end if;
end if;
end if;
end process;
end solucion;
CONTADOR 0-99 CON 2 DISPLAYS
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity contador99_display is
port(clk,reset: in std_logic;
display,enable: out std_logic_vector(7 downto 0);
uni,dec: buffer std_logic_vector(3 downto 0));
end contador99_display;
process(x,reset)
begin
if reset='1' then
uni<=(others=>'0');
dec<=(others=>'0');
elsif rising_edge(x) then
uni<=uni+1;
if uni=9 then
uni<=(others=>'0');
dec<=dec+1;
if dec=9 then
dec<=(others=>'0');
end if;
end if;
end if;
end process;
--pgfedcba
with uni select display1 <= "11000000" when "0000",
"11111001" when "0001",
"10100100" when "0010",
"10110000" when "0011",
"10011001" when "0100",
"10010010" when "0101",
"10000010" when "0110",
"11111000" when "0111",
"10000000" when "1000",
"10011000" when others;
--pgfedcba
with dec select display2 <= "11000000" when "0000",
"11111001" when "0001",
"10100100" when "0010",
"10110000" when "0011",
"10011001" when "0100",
"10010010" when "0101",
"10000010" when "0110",
"11111000" when "0111",
"10000000" when "1000",
"10011000" when others;
end solucion;
DECODIFICADOR DE 3 A 8
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity DEC3A8_ENA is
Port ( A : in std_logic;
B : in std_logic;
C : in std_logic;
ENA : in std_logic;
Y : out std_logic_vector(7 downto 0));
end DEC3A8_ENA;
architecture Behavioral of DEC3A8_ENA is
signal ENTRADA: std_logic_vector(2 downto 0);
signal SALIDAS: std_logic_vector(7 downto 0);
begin
ENTRADA <= C & B & A;
with ENTRADA select SALIDAS <= "00000001" when "000",
DECODIFICADOR DE 2 A 4
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity DECO2A4 is
Port(SEL: in std_logic_vector(1 downto 0);
Y: out std_logic_vector(3 downto 0));
end DECO2A4;
DECODIFICADOR DE 7 SEGMENTOS
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity deco7 is
port(entrada: in std_logic_vector(3 downto 0);
display: out std_logic_vector(7 downto 0));
end deco7;
entity decoder7_prioridad is
Port(switch:in std_logic_vector(3 downto 0);
sel: in std_logic_vector(2 downto 0);
display: out std_logic_vector(7 downto 0);
habilitador: out std_logic_vector(7 downto 0));
end decoder7_prioridad;
end solucion;
DESPLAZAMIENDO DERECHA-IZQUIERDA
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity DESPLAZO1 is
Port(sel: in std_logic_vector(1 downto 0);
data: in std_logic_vector(7 downto 0);
Q: out std_logic_vector(7 downto 0));
end DESPLAZO1;
end solucion;
entity display_fiee2015 is
Port(clk: in std_logic;
d0,d1,d2,d3: out std_logic_vector(7 downto 0));
end display_fiee2015;
d3<=a;
d2<=b;
d1<=c;
d0<=d;
end solucion;
entity display2_sc is
Port(clk: in std_logic;
buzz: out std_logic;
display, enable: out std_logic_vector(8 downto 0));
end display2_sc;
architecture solucion of display2_sc is
signal x: std_logic;
signal cuenta: std_logic_vector(17 downto 0);
begin
buzz<='1';
display<= "10010010" when x='0' else "11000110";
enable <= "11111110" when x='0' else "11111101";
process(clk)
begin
if rising_edge(clk) then
cuenta<=cuenta+1;
if cuenta=250000 then
cuenta<=(others=>'0');
x<=not x;
end if;
end if;
end process;
end solucion;
DIVISOR DE CLOCK
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity divisor is
Port(clk:in std_logic;
sel: in std_logic_vector(1 downto 0);
z: out std_logic);
end divisor;
DIVISOR DE 1 HZ
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity divisor1hz is
port(clk: in std_logic;
z: buffer std_logic);
end divisor1hz;
DIVISOR 1KHZ
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity DIVISOR1K is
Port(clk,push: in std_logic;
z:buffer std_logic);
end DIVISOR1K;
architecture solucion of DIVISOR1K is
signal cuenta: std_logic_vector(25 downto 0);
begin
process(clk,push)
begin
if rising_edge(clk) then
cuenta<=cuenta+1;
if cuenta=25000 then
cuenta<=(others=>'0');
z<=not z;
end if;
if push='1' then
cuenta<=cuenta+1;
if cuenta=50000 then
cuenta<=(others=>'0');
z<=not z;
end if;
end if;
end if;
end process;
end solucion;
DUTY CICLE
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity duty_cycle is
Port(clk: in std_logic;
sel: in std_logic_vector(1 downto 0);
z: out std_logic);
end duty_cycle;
FLIP-FLOP TIPO D
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity FF_D is
Port(clk,clr,D: in std_logic;
Q: out std_logic);
end FF_D;
GENERADOR DE PULSOS
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity generador is
Port(clk: in std_logic;
z: out std_logic);
end generador;
process(clk)
begin
if rising_edge(clk) then
cuenta <= cuenta + 1;
if cuenta=19 then
cuenta<=0;
end if;
end if;
end process;
end solucion;
entity hola_peru is
Port(clk: in std_logic;
habilitador: out std_logic_vector(7 downto 0);
display: out std_logic_vector(7 downto 0));
end hola_peru;
end solucion;
entity maquina1 is
Port(D,clk: in std_logic;
Q: out std_logic);
end maquina1;
process(EP,D)
begin
ES<=EP;
case EP is
when S0=> Q<='0';
if D='1' then ES<=S1; else ES<=S0; end if;
when S1=> Q<='0';
if D='1' then ES<=S1; else ES<=S2; end if;
when S2=> Q<='0';
if D='1' then ES<=S3; else ES<=S0; end if;
when S3=> Q<='0';
if D='1' then ES<=S4; else ES<=S2; end if;
when S4=> Q<='0';
if D='1' then ES<=S1; else ES<=S5; end if;
when S5=> Q<='0';
if D='1' then ES<=S3; else ES<=S0; end if;
end case;
end process;
end solucion;
entity MAQUINA2 is
Port(clk,d: in std_logic;
z:out std_logic);
end MAQUINA2;
entity maquina3 is
port(clk,boton: in std_logic;
z: out std_logic);
end maquina3;
entity matriz8 is
Port(clk: in std_logic;
fila, columna: out std_logic_vector(7 downto 0));
end matriz8;
MUX 2 A 1
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity MUX2A1 is
Port(A,B,SEL: in std_logic;
Z1,Z2: out std_logic);
end MUX2A1;
MUX DE 4 A 1
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mux4a1_fd is
Port(e: in std_logic_vector(3 downto 0);
sel: in std_logic_vector(1 downto 0);
z: out std_logic);
end mux4a1_fd;
architecture solucion of mux4a1_fd is
begin
z<= e(0) when sel="00" else
e(1) when sel="01" else
e(2) when sel="10" else e(3);
end solucion;
MUX DE 8 A 1
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mux8a1_e is
port(entradas: in std_logic_vector(7 downto 0);
selector: in std_logic_vector(2 downto 0);
z: out std_logic);
end mux8a1_e;
PWM
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity PWM is
port(clk:in std_logic;
sel:in std_logic_vector(1 downto 0);
z: out std_logic);
end PWM;
entity register8_ena is
Port(ena,clk: in std_logic;
sel: in std_logic_vector(1 downto 0);
data: in std_logic_vector(7 downto 0);
q: buffer std_logic_vector(7 downto 0));
end register8_ena;
entity registro_8 is
Port(clk,ena,clr: in std_logic;
data: in std_logic_vector(7 downto 0);
q: out std_logic_vector(7 downto 0));
end registro_8;
process(EP,STOP)
begin
ES<=EP;
case EP is
when S0=> ROJO<='0'; A<='0'; V<='1';
if stop='1' then
ES<=S1;
else ES<=S0;
end if;
when S1=> ROJO<='0'; A<='1'; V<='0';
if contador=2 then
ES<=S2;
else ES<=S1;
end if;
when S2=> ROJO<='1'; A<='0'; V<='0';
if contador=22 then
ES<=S0;
else ES<=S2;
end if;
end case;
end process;
R<=ROJO when contador < 17 else clk;
end solucion;
entity semaforo2 is
port(clk: in std_logic;
R,V,Ro,Am,Ve: out std_logic);
end semaforo2;
process(EP)
begin
ES<=EP;
case EP is
when S0=> ROJO<='1'; V<='0'; Ro<='0'; Am<='0'; Ve<='1';
if contador=30 then ES<=S1; else ES<=S0; end if;
when S1=> ROJO<='1'; V<='0'; Ro<='0'; Am<='1'; Ve<='0';
if contador=33 then ES<=S2; else ES<=S1; end if;
when S2=> ROJO<='0'; V<='1'; Ro<='1'; Am<='0'; Ve<='0';
if contador=53 then ES<=S0; else ES<=S2; end if;
end case;
end process;
R<=ROJO when contador<47 else clk;
end solucion;
entity semaforo_conif is
Port(clk:in std_logic;
R,V:out std_logic;
ro,am,ve: buffer std_logic);
end semaforo_conif;
end solucion;
VISOR
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity visor is
Port(clk:in std_logic;
E0,E1,E2,E3,E4,E5,E6,E7: in std_logic_vector(3 downto 0);
display: out std_logic_vector(7 downto 0);
habilitador: out std_logic_vector(7 downto 0));
end visor;
entity CONTADORGRAY_4BITS is
port(clk,clr,ena: in std_logic;
grey: out std_logic_vector(3 downto 0));
end CONTADORGRAY_4BITS;
if cuenta=14 then
cuenta<=(others=>'0');
end if;
end if;
end if;
end process;
grey<=x;
end solucion;
DIVISOR DE FRECUENCIA 2017-II
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity DIVISOR_FRECUENCIA2017II is
port(clk:in std_logic;
sel: in std_logic_vector(2 downto 0);
z:out std_logic);
end DIVISOR_FRECUENCIA2017II;
end solucion;
entity suma_acarreo is
port(A,B: in std_logic_vector(3 downto 0);
ci: in std_logic;
s: out std_logic_vector(3 downto 0);
co: out std_logic);
end suma_acarreo;
end solucion;
entity suma8bits_signo is
port(A,B: in unsigned (7 downto 0);
C: in signed(7 downto 0);
D: in std_logic_vector(7 downto 0);
S: out unsigned (8 downto 0);
T: out signed (8 downto 0);
U: out signed (7 downto 0);
V: out std_logic_vector(8 downto 0));
end suma8bits_signo;
entity fulladder_2bits is
port(a,b,c: in std_logic;
sum,carry: out std_logic);
end fulladder_2bits;
entity fulladder_4bits is
port(a,b: in std_logic_vector(3 downto 0);
cin: in std_logic;
sum: out std_logic_vector(3 downto 0);
cout,v: out std_logic);
end fulladder_4bits;
entity registro_d is
port(clk,d,rst: in std_logic;
q: out std_logic);
end registro_d;