Ejercicios Replicas VHDL
Ejercicios Replicas VHDL
Ejercicios Replicas VHDL
INGENIERÍA EN COMPUTACIÓN
ARQUITECTURA DE ORDENADORES
Ciclo: 3 “A”
2022
LOJA- ECUADOR
1. Ejercicio 1
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity latch is
Port ( x, control : in STD_LOGIC;
z : out STD_LOGIC);
end latch;
begin
end ejemplo;
2. Ejercicio 2
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity latch1 is
Port ( dato, control : in STD_LOGIC;
salida : out STD_LOGIC);
end latch1;
begin
if control='1' then
salida <= dato
end if
end process
end Ejemplo;
Ilustración 2Creación de un latch dentro de un proceso.
3. Ejercicio 3
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity ffd is
Port ( D, clk : in STD_LOGIC;
Q : out STD_LOGIC);
end ffd;
begin
process (clk) begin
if (clk' event and clk='1') then
Q <= D;
end if;
end process;
end arq_ffd;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity FLIP is
Port ( D , clk, RESET : in STD_LOGIC;
Q : out STD_LOGIC);
end FLIP;
begin
process (clk,D,RESET) begin
if RESET='1' then
Q<= '0';
elsif (clk' event and clk ='1') then
Q <= D;
end if;
end process;
end Behavioral;
5. Ejercicio 5
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use work.std_arith.all;
entity FLIP1 is
Port ( clk, RESET, EN ,D : in STD_LOGIC;
Q : inout STD_LOGIC);
end FLIP1;
begin
process (clk, RESET, EN)
begin
if reset='l' then q_ aux<='0'
elsif (clk' event and clk' l') then
if ( EN=' l' ) then
q_aux<= D;
else
q_aux<=q;
end if;
end if;
end process;
q<=q_aux;
end FLOP;
Ilustración 5Flip-flop D con uso de señales
6. Ejercicio 6
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity ffsr is
Port ( S,R,clk : in STD_LOGIC;
Q , Qn : inout STD_LOGIC);
end ffsr;
begin
process (clk, S, R)
begin
if (clk'event and clk 'l') then
if (S = 'O'and R = '1') then
Q <= '0';
Qn <= '1';
elsif (S = 'l' and R '0') then
Q <= '1' ;
Qn <= '0';
elsif (S = '0' and R '0') then
Q <= Q;
Qn <= Qn;
else
Q <= '-';
Qn <= '-';
end if;
end if;
end process;
end a_ffsr;
Ilustración 6 Listado 3.3
7. Ejercicio 7
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity registro is
Port ( d, clk : in STD_LOGIC;
q : out STD_LOGIC);
end registro;
8. Ejercicio 8
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity registro2 is
Port ( d, clk : in STD_LOGIC;
q : out STD_LOGIC);
end registro2;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity reg is
Port ( D : in STD_LOGIC_VECTOR(0 to 7);
clk : in STD_LOGIC;
Q : out STD_LOGIC_VECTOR(0 to 7));
end reg;
begin
process (clk) begin
if(clk' event and clk='1' ) then
Q <= D;
end if;
end process;
end arqreg;
10. Ejercicio 10
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity reg4 is
Port ( D : in STD_LOGIC_VECTOR(3 downto 0);
clk, CLR : in STD_LOGIC;
Q, Qn : inout STD_LOGIC_VECTOR(3 downto 0));
end reg4;
11. Ejercicio 11
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity contador is
Port ( clk : in STD_LOGIC;
q : inout STD_LOGIC_VECTOR(3 downto 0));
end contador;
begin
process (clk)
begin
if(clk' event and clk='1') then
q <= q+1;
end if;
end process;
end cuenta;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity contador2 is
Port ( clk : in STD_LOGIC;
Q : inout STD_LOGIC_VECTOR(3 downto 0));
attribute pin_numbers of contador: entity is
" clk:1 Q(3):14 Q(2):15 Q(1):16 Q(0): 17";
end contador2;
begin
process (clk)
begin
if(clk' event and clk='1') then
q <= q+1;
end if;
end process;
end pins;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity contador3 is
Port ( clk, reset : in STD_LOGIC;
q : inout STD_LOGIC_VECTOR(3 downto 0));
end contador3;
begin
process (clk, reset)
begin
if(clk' event and clk='1') then
if(reset='1' or q="1001") then
q<="0000";
else
q<=q+1;
end if;
end if;
end process;
end modulo;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity cont is
Port ( clk, reset : in STD_LOGIC;
Q : inout integer range 0 to 15);
end cont;
begin
process(clk, reset)
begin
if(clk' event and clk='1')then
if(reset='1' or Q=9)then
Q<=0;
else
Q<=Q+1;
end if;
end if;
end process;
end arq_cont;
entity contador4 is
Port ( clk : in STD_LOGIC;
UP : in STD_LOGIC;
Q : inout STD_LOGIC_VECTOR(3 downto 0));
end contador4;
begin
process (UP, clk) begin
if(clk' event and clk ='1')then
if(UP = '0')then
Q<= Q+1;
else
Q<= Q-1;
end if;
end if;
end process;
end a_contador;
entity contador5 is
Port ( clk, LD, UP : in STD_LOGIC;
D : in STD_LOGIC_VECTOR(2 downto 0);
Q : inout STD_LOGIC_VECTOR(2 downto 0));
end contador5;
begin
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity cont1 is
Port ( P : in STD_LOGIC_VECTOR(3 downto 0);
clk, LOAD, ENP, RESET : in STD_LOGIC;
Q : inout STD_LOGIC_VECTOR(3 downto 0));
end cont1;
begin
process(clk, RESET, LOAD, ENP) begin
if(RESET = '1') then
Q <= "0000";
elsif( clk' event and clk='1')then
if(LOAD = '0' and ENP = '-')then
Q <= P;
elsif( LOAD= '1' and ENP = '0') then
Q <= Q;
elsif (LOAD = '1' AND ENP = '1')then
Q <= Q + 1;
end if;
end if;
end process;
end arq_cont1;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity ejemplogen is
Generic (contador_valor: integer:=511);
Port ( clk, ld, clr, en : in STD_LOGIC;
data : in integer range 0 to contador_valor;
Q : inout integer range 0 to contador_valor);
end ejemplogen;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity diagrama is
Port ( clk, x : in STD_LOGIC;
z : out STD_LOGIC);
end diagrama;
begin
proceso1: process(edo_presente, x)begin
case edo_presente is
when d0 => z <='0';
if x='1' then
edo_futuro <=d1;
else
edo_futuro <=d0;
end if;
when d1 => z <='0';
if x='1' then
edo_futuro <=d2;
else
edo_futuro <=d1;
end if;
when d2 => z <='0';
if x='1' then
edo_futuro <=d3;
else
edo_futuro <=d0;
end if;
when d3 =>
if x='1' then
edo_futuro <=d0;
z<='1';
else
edo_futuro <=d3;
z<= '0';
end if;
end case;
end process proceso1;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity diag is
Port ( clk,x : in STD_LOGIC;
z : out STD_LOGIC);
end diag;